SanitizerBlacklist.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //===--- SanitizerBlacklist.cpp - Blacklist for sanitizers ----------------===//
  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. // User-provided blacklist used to disable/alter instrumentation done in
  10. // sanitizers.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #include "clang/Basic/SanitizerBlacklist.h"
  14. using namespace clang;
  15. SanitizerBlacklist::SanitizerBlacklist(
  16. const std::vector<std::string> &BlacklistPaths, SourceManager &SM)
  17. : SSCL(SanitizerSpecialCaseList::createOrDie(BlacklistPaths)), SM(SM) {}
  18. bool SanitizerBlacklist::isBlacklistedGlobal(SanitizerMask Mask,
  19. StringRef GlobalName,
  20. StringRef Category) const {
  21. return SSCL->inSection(Mask, "global", GlobalName, Category);
  22. }
  23. bool SanitizerBlacklist::isBlacklistedType(SanitizerMask Mask,
  24. StringRef MangledTypeName,
  25. StringRef Category) const {
  26. return SSCL->inSection(Mask, "type", MangledTypeName, Category);
  27. }
  28. bool SanitizerBlacklist::isBlacklistedFunction(SanitizerMask Mask,
  29. StringRef FunctionName) const {
  30. return SSCL->inSection(Mask, "fun", FunctionName);
  31. }
  32. bool SanitizerBlacklist::isBlacklistedFile(SanitizerMask Mask,
  33. StringRef FileName,
  34. StringRef Category) const {
  35. return SSCL->inSection(Mask, "src", FileName, Category);
  36. }
  37. bool SanitizerBlacklist::isBlacklistedLocation(SanitizerMask Mask,
  38. SourceLocation Loc,
  39. StringRef Category) const {
  40. return Loc.isValid() &&
  41. isBlacklistedFile(Mask, SM.getFilename(SM.getFileLoc(Loc)), Category);
  42. }