blob: 166f0e6c9b580ac10d097556ddbcb910c20ec5a7 [file] [log] [blame]
Stephen Hines176edba2014-12-01 14:53:08 -08001//===--- 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
Stephen Hines0e2c34f2015-03-23 12:09:02 -070016#include "clang/AST/Type.h"
Stephen Hines176edba2014-12-01 14:53:08 -080017#include "clang/Basic/LLVM.h"
18#include "clang/Basic/SourceLocation.h"
Stephen Hines176edba2014-12-01 14:53:08 -080019
20namespace llvm {
21class GlobalVariable;
22class Instruction;
23class MDNode;
24}
25
26namespace clang {
27class VarDecl;
28
29namespace CodeGen {
30
31class CodeGenModule;
32
33class SanitizerMetadata {
Stephen Hines0e2c34f2015-03-23 12:09:02 -070034 SanitizerMetadata(const SanitizerMetadata &) = delete;
35 void operator=(const SanitizerMetadata &) = delete;
Stephen Hines176edba2014-12-01 14:53:08 -080036
37 CodeGenModule &CGM;
38public:
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);
47private:
48 llvm::MDNode *getLocationMetadata(SourceLocation Loc);
49};
50} // end namespace CodeGen
51} // end namespace clang
52
53#endif