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 
15 #include "clang/AST/Type.h"
16 #include "clang/Basic/LLVM.h"
17 #include "clang/Basic/Sanitizers.h"
18 #include "clang/Basic/SourceLocation.h"
19 
20 namespace llvm {
21 class GlobalVariable;
22 class Instruction;
23 class MDNode;
24 } // namespace llvm
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 
39 public:
40   SanitizerMetadata(CodeGenModule &CGM);
41   void reportGlobal(llvm::GlobalVariable *GV, const VarDecl &D,
42                     bool IsDynInit = false);
43   void reportGlobal(llvm::GlobalVariable *GV, SourceLocation Loc,
44                     StringRef Name, QualType Ty = {},
45                     SanitizerMask NoSanitizeAttrMask = {},
46                     bool IsDynInit = false);
47   void disableSanitizerForGlobal(llvm::GlobalVariable *GV);
48   void disableSanitizerForInstruction(llvm::Instruction *I);
49 };
50 } // end namespace CodeGen
51 } // end namespace clang
52 
53 #endif
54