• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #include "clang/AST/Type.h"
17 #include "clang/Basic/LLVM.h"
18 #include "clang/Basic/SourceLocation.h"
19 
20 namespace llvm {
21 class GlobalVariable;
22 class Instruction;
23 class MDNode;
24 }
25 
26 namespace clang {
27 class VarDecl;
28 
29 namespace CodeGen {
30 
31 class CodeGenModule;
32 
33 class SanitizerMetadata {
34   SanitizerMetadata(const SanitizerMetadata &) = delete;
35   void operator=(const SanitizerMetadata &) = delete;
36 
37   CodeGenModule &CGM;
38 public:
39   SanitizerMetadata(CodeGenModule &CGM);
40   void reportGlobalToASan(llvm::GlobalVariable *GV, const VarDecl &D,
41                           bool IsDynInit = false);
42   void reportGlobalToASan(llvm::GlobalVariable *GV, SourceLocation Loc,
43                           StringRef Name, QualType Ty, bool IsDynInit = false,
44                           bool IsBlacklisted = false);
45   void disableSanitizerForGlobal(llvm::GlobalVariable *GV);
46   void disableSanitizerForInstruction(llvm::Instruction *I);
47 private:
48   llvm::MDNode *getLocationMetadata(SourceLocation Loc);
49 };
50 }  // end namespace CodeGen
51 }  // end namespace clang
52 
53 #endif
54