blob: f3c700a6f2fa6fcec33c68c2a758468fe81b42eb [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
16#include "clang/Basic/LLVM.h"
17#include "clang/Basic/SourceLocation.h"
Alexey Samsonova0ac3c22014-10-17 22:37:33 +000018#include "clang/AST/Type.h"
Alexey Samsonov4b8de112014-08-01 21:35:28 +000019
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 {
34 SanitizerMetadata(const SanitizerMetadata &) LLVM_DELETED_FUNCTION;
35 void operator=(const SanitizerMetadata &) LLVM_DELETED_FUNCTION;
36
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