SanitizerMetadata.h 1.6 KB

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