blob: e71830aaa9cf26857747bcafdf57bad6ea89b656 [file] [log] [blame]
Alexey Samsonova0416102014-11-11 01:26:14 +00001//===--- Sanitizers.cpp - C Language Family Language Options ----*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines the classes from Sanitizers.h
11//
12//===----------------------------------------------------------------------===//
13#include "clang/Basic/Sanitizers.h"
Peter Collingbourne3eea6772015-05-11 21:39:14 +000014#include "llvm/Support/MathExtras.h"
Alexey Samsonova0416102014-11-11 01:26:14 +000015
16using namespace clang;
17
Peter Collingbourne3eea6772015-05-11 21:39:14 +000018SanitizerSet::SanitizerSet() : Mask(0) {}
Alexey Samsonova0416102014-11-11 01:26:14 +000019
Peter Collingbourne3eea6772015-05-11 21:39:14 +000020bool SanitizerSet::has(SanitizerMask K) const {
21 assert(llvm::countPopulation(K) == 1);
22 return Mask & K;
Alexey Samsonova0416102014-11-11 01:26:14 +000023}
24
Peter Collingbourne3eea6772015-05-11 21:39:14 +000025void SanitizerSet::set(SanitizerMask K, bool Value) {
26 assert(llvm::countPopulation(K) == 1);
27 Mask = Value ? (Mask | K) : (Mask & ~K);
Alexey Samsonova0416102014-11-11 01:26:14 +000028}
29
30void SanitizerSet::clear() {
Peter Collingbourne3eea6772015-05-11 21:39:14 +000031 Mask = 0;
Alexey Samsonova0416102014-11-11 01:26:14 +000032}
Alexey Samsonov4c12c6c2014-11-14 02:59:20 +000033
34bool SanitizerSet::empty() const {
Peter Collingbourne3eea6772015-05-11 21:39:14 +000035 return Mask == 0;
Alexey Samsonov4c12c6c2014-11-14 02:59:20 +000036}