1 //===- Sanitizers.cpp - C Language Family Language Options ----------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file defines the classes from Sanitizers.h 10 // 11 //===----------------------------------------------------------------------===// 12 13 #include "clang/Basic/Sanitizers.h" 14 #include "llvm/ADT/StringSwitch.h" 15 16 using namespace clang; 17 18 SanitizerMask clang::parseSanitizerValue(StringRef Value, bool AllowGroups) { 19 SanitizerMask ParsedKind = llvm::StringSwitch<SanitizerMask>(Value) 20 #define SANITIZER(NAME, ID) .Case(NAME, SanitizerKind::ID) 21 #define SANITIZER_GROUP(NAME, ID, ALIAS) \ 22 .Case(NAME, AllowGroups ? SanitizerKind::ID##Group : 0) 23 #include "clang/Basic/Sanitizers.def" 24 .Default(0); 25 return ParsedKind; 26 } 27 28 SanitizerMask clang::expandSanitizerGroups(SanitizerMask Kinds) { 29 #define SANITIZER(NAME, ID) 30 #define SANITIZER_GROUP(NAME, ID, ALIAS) \ 31 if (Kinds & SanitizerKind::ID##Group) \ 32 Kinds |= SanitizerKind::ID; 33 #include "clang/Basic/Sanitizers.def" 34 return Kinds; 35 } 36