blob: 166f0e6c9b580ac10d097556ddbcb910c20ec5a7 [file] [log] [blame]
Alexey Samsonov4b8de112014-08-01 21:35:28 +00001//===--- 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//===----------------------------------------------------------------------===//
Benjamin Kramer2f5db8b2014-08-13 16:25:19 +000013#ifndef LLVM_CLANG_LIB_CODEGEN_SANITIZERMETADATA_H
14#define LLVM_CLANG_LIB_CODEGEN_SANITIZERMETADATA_H
Alexey Samsonov4b8de112014-08-01 21:35:28 +000015
Chandler Carruth0d9593d2015-01-14 11:29:14 +000016#include "clang/AST/Type.h"
Alexey Samsonov4b8de112014-08-01 21:35:28 +000017#include "clang/Basic/LLVM.h"
18#include "clang/Basic/SourceLocation.h"
19
20namespace llvm {
21class GlobalVariable;
Kostya Serebryany4ee69042014-08-26 02:29:59 +000022class Instruction;
Alexey Samsonovd9ad5ce2014-08-02 00:35:50 +000023class MDNode;
Alexey Samsonov4b8de112014-08-01 21:35:28 +000024}
25
26namespace clang {
27class VarDecl;
28
29namespace CodeGen {
30
31class CodeGenModule;
32
33class SanitizerMetadata {
Aaron Ballmanabc18922015-02-15 22:54:08 +000034 SanitizerMetadata(const SanitizerMetadata &) = delete;
35 void operator=(const SanitizerMetadata &) = delete;
Alexey Samsonov4b8de112014-08-01 21:35:28 +000036
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,
Alexey Samsonova0ac3c22014-10-17 22:37:33 +000043 StringRef Name, QualType Ty, bool IsDynInit = false,
Alexey Samsonov4b8de112014-08-01 21:35:28 +000044 bool IsBlacklisted = false);
45 void disableSanitizerForGlobal(llvm::GlobalVariable *GV);
Kostya Serebryany4ee69042014-08-26 02:29:59 +000046 void disableSanitizerForInstruction(llvm::Instruction *I);
Alexey Samsonovd9ad5ce2014-08-02 00:35:50 +000047private:
48 llvm::MDNode *getLocationMetadata(SourceLocation Loc);
Alexey Samsonov4b8de112014-08-01 21:35:28 +000049};
50} // end namespace CodeGen
51} // end namespace clang
52
53#endif