Alexey Samsonov | a041610 | 2014-11-11 01:26:14 +0000 | [diff] [blame] | 1 | //===--- 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 Collingbourne | bf59c34 | 2015-05-11 21:39:20 +0000 | [diff] [blame] | 14 | #include "clang/Basic/LLVM.h" |
| 15 | #include "llvm/ADT/StringRef.h" |
| 16 | #include "llvm/ADT/StringSwitch.h" |
Alexey Samsonov | a041610 | 2014-11-11 01:26:14 +0000 | [diff] [blame] | 17 | |
| 18 | using namespace clang; |
| 19 | |
Peter Collingbourne | bf59c34 | 2015-05-11 21:39:20 +0000 | [diff] [blame] | 20 | SanitizerMask clang::parseSanitizerValue(StringRef Value, bool AllowGroups) { |
| 21 | SanitizerMask ParsedKind = llvm::StringSwitch<SanitizerMask>(Value) |
| 22 | #define SANITIZER(NAME, ID) .Case(NAME, SanitizerKind::ID) |
| 23 | #define SANITIZER_GROUP(NAME, ID, ALIAS) \ |
| 24 | .Case(NAME, AllowGroups ? SanitizerKind::ID##Group : 0) |
| 25 | #include "clang/Basic/Sanitizers.def" |
| 26 | .Default(0); |
| 27 | return ParsedKind; |
| 28 | } |
| 29 | |
| 30 | SanitizerMask clang::expandSanitizerGroups(SanitizerMask Kinds) { |
| 31 | #define SANITIZER(NAME, ID) |
| 32 | #define SANITIZER_GROUP(NAME, ID, ALIAS) \ |
| 33 | if (Kinds & SanitizerKind::ID##Group) \ |
| 34 | Kinds |= SanitizerKind::ID; |
| 35 | #include "clang/Basic/Sanitizers.def" |
| 36 | return Kinds; |
| 37 | } |