SanitizerMetadata.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //===--- SanitizerMetadata.h - Metadata for sanitizers ----------*- C++ -*-===//
  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. // Class which emits metadata consumed by sanitizer instrumentation passes.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_CLANG_LIB_CODEGEN_SANITIZERMETADATA_H
  13. #define LLVM_CLANG_LIB_CODEGEN_SANITIZERMETADATA_H
  14. #include "clang/AST/Type.h"
  15. #include "clang/Basic/LLVM.h"
  16. #include "clang/Basic/SourceLocation.h"
  17. namespace llvm {
  18. class GlobalVariable;
  19. class Instruction;
  20. class MDNode;
  21. }
  22. namespace clang {
  23. class VarDecl;
  24. namespace CodeGen {
  25. class CodeGenModule;
  26. class SanitizerMetadata {
  27. SanitizerMetadata(const SanitizerMetadata &) = delete;
  28. void operator=(const SanitizerMetadata &) = delete;
  29. CodeGenModule &CGM;
  30. public:
  31. SanitizerMetadata(CodeGenModule &CGM);
  32. void reportGlobalToASan(llvm::GlobalVariable *GV, const VarDecl &D,
  33. bool IsDynInit = false);
  34. void reportGlobalToASan(llvm::GlobalVariable *GV, SourceLocation Loc,
  35. StringRef Name, QualType Ty, bool IsDynInit = false,
  36. bool IsExcluded = false);
  37. void disableSanitizerForGlobal(llvm::GlobalVariable *GV);
  38. void disableSanitizerForInstruction(llvm::Instruction *I);
  39. private:
  40. llvm::MDNode *getLocationMetadata(SourceLocation Loc);
  41. };
  42. } // end namespace CodeGen
  43. } // end namespace clang
  44. #endif