Clang Project

clang_source_code/lib/CodeGen/SanitizerMetadata.h
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/SourceLocation.h"
18
19namespace llvm {
20class GlobalVariable;
21class Instruction;
22class MDNode;
23}
24
25namespace clang {
26class VarDecl;
27
28namespace CodeGen {
29
30class CodeGenModule;
31
32class SanitizerMetadata {
33  SanitizerMetadata(const SanitizerMetadata &) = delete;
34  void operator=(const SanitizerMetadata &) = delete;
35
36  CodeGenModule &CGM;
37public:
38  SanitizerMetadata(CodeGenModule &CGM);
39  void reportGlobalToASan(llvm::GlobalVariable *GVconst VarDecl &D,
40                          bool IsDynInit = false);
41  void reportGlobalToASan(llvm::GlobalVariable *GVSourceLocation Loc,
42                          StringRef NameQualType Tybool IsDynInit = false,
43                          bool IsBlacklisted = false);
44  void disableSanitizerForGlobal(llvm::GlobalVariable *GV);
45  void disableSanitizerForInstruction(llvm::Instruction *I);
46private:
47  llvm::MDNode *getLocationMetadata(SourceLocation Loc);
48};
49}  // end namespace CodeGen
50}  // end namespace clang
51
52#endif
53
clang::CodeGen::SanitizerMetadata::CGM
clang::CodeGen::SanitizerMetadata::reportGlobalToASan
clang::CodeGen::SanitizerMetadata::reportGlobalToASan
clang::CodeGen::SanitizerMetadata::disableSanitizerForGlobal
clang::CodeGen::SanitizerMetadata::disableSanitizerForInstruction
clang::CodeGen::SanitizerMetadata::getLocationMetadata