Sanitizers.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. #include "clang/Basic/Sanitizers.h"
  13. #include "llvm/ADT/Hashing.h"
  14. #include "llvm/ADT/StringSwitch.h"
  15. using namespace clang;
  16. SanitizerMask clang::parseSanitizerValue(StringRef Value, bool AllowGroups) {
  17. SanitizerMask ParsedKind = llvm::StringSwitch<SanitizerMask>(Value)
  18. #define SANITIZER(NAME, ID) .Case(NAME, SanitizerKind::ID)
  19. #define SANITIZER_GROUP(NAME, ID, ALIAS) \
  20. .Case(NAME, AllowGroups ? SanitizerKind::ID##Group : SanitizerMask())
  21. #include "clang/Basic/Sanitizers.def"
  22. .Default(SanitizerMask());
  23. return ParsedKind;
  24. }
  25. SanitizerMask clang::expandSanitizerGroups(SanitizerMask Kinds) {
  26. #define SANITIZER(NAME, ID)
  27. #define SANITIZER_GROUP(NAME, ID, ALIAS) \
  28. if (Kinds & SanitizerKind::ID##Group) \
  29. Kinds |= SanitizerKind::ID;
  30. #include "clang/Basic/Sanitizers.def"
  31. return Kinds;
  32. }
  33. llvm::hash_code SanitizerMask::hash_value() const {
  34. return llvm::hash_combine_range(&maskLoToHigh[0], &maskLoToHigh[kNumElem]);
  35. }
  36. namespace clang {
  37. llvm::hash_code hash_value(const clang::SanitizerMask &Arg) {
  38. return Arg.hash_value();
  39. }
  40. } // namespace clang