blob: 000f02cf8dcf113fc87b66689687abcb0a7534cb [file] [log] [blame]
Alexey Samsonov4b8de112014-08-01 21:35:28 +00001//===--- SanitizerMetadata.h - Metadata for sanitizers ----------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Alexey Samsonov4b8de112014-08-01 21:35:28 +00006//
7//===----------------------------------------------------------------------===//
8//
9// Class which emits metadata consumed by sanitizer instrumentation passes.
10//
11//===----------------------------------------------------------------------===//
Benjamin Kramer2f5db8b2014-08-13 16:25:19 +000012#ifndef LLVM_CLANG_LIB_CODEGEN_SANITIZERMETADATA_H
13#define LLVM_CLANG_LIB_CODEGEN_SANITIZERMETADATA_H
Alexey Samsonov4b8de112014-08-01 21:35:28 +000014
Chandler Carruth0d9593d2015-01-14 11:29:14 +000015#include "clang/AST/Type.h"
Alexey Samsonov4b8de112014-08-01 21:35:28 +000016#include "clang/Basic/LLVM.h"
Mitch Phillips77475ffd2022-06-13 12:12:31 -070017#include "clang/Basic/Sanitizers.h"
Alexey Samsonov4b8de112014-08-01 21:35:28 +000018#include "clang/Basic/SourceLocation.h"
19
20namespace llvm {
21class GlobalVariable;
Kostya Serebryany4ee69042014-08-26 02:29:59 +000022class Instruction;
Mitch Phillips5d9de5f2022-06-06 21:21:15 -070023} // namespace llvm
Alexey Samsonov4b8de112014-08-01 21:35:28 +000024
25namespace clang {
26class VarDecl;
27
28namespace CodeGen {
29
30class CodeGenModule;
31
32class SanitizerMetadata {
Aaron Ballmanabc18922015-02-15 22:54:08 +000033 SanitizerMetadata(const SanitizerMetadata &) = delete;
34 void operator=(const SanitizerMetadata &) = delete;
Alexey Samsonov4b8de112014-08-01 21:35:28 +000035
36 CodeGenModule &CGM;
Mitch Phillips5d9de5f2022-06-06 21:21:15 -070037
Alexey Samsonov4b8de112014-08-01 21:35:28 +000038public:
39 SanitizerMetadata(CodeGenModule &CGM);
Mitch Phillipsf49a5842022-06-06 21:18:33 -070040 void reportGlobal(llvm::GlobalVariable *GV, const VarDecl &D,
41 bool IsDynInit = false);
42 void reportGlobal(llvm::GlobalVariable *GV, SourceLocation Loc,
Mitch Phillips77475ffd2022-06-13 12:12:31 -070043 StringRef Name, QualType Ty = {},
44 SanitizerMask NoSanitizeAttrMask = {},
45 bool IsDynInit = false);
Alexey Samsonov4b8de112014-08-01 21:35:28 +000046 void disableSanitizerForGlobal(llvm::GlobalVariable *GV);
Alexey Samsonov4b8de112014-08-01 21:35:28 +000047};
Mitch Phillips5d9de5f2022-06-06 21:21:15 -070048} // end namespace CodeGen
49} // end namespace clang
Alexey Samsonov4b8de112014-08-01 21:35:28 +000050
51#endif