[DominatorTree] Add support for mixed pre/post CFG views.
[llvm-project.git] / compiler-rt / lib / dfsan / dfsan.h
blobd662391216e4bd75b7341277290351214f24b38b
1 //===-- dfsan.h -------------------------------------------------*- 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 // This file is a part of DataFlowSanitizer.
11 // Private DFSan header.
12 //===----------------------------------------------------------------------===//
14 #ifndef DFSAN_H
15 #define DFSAN_H
17 #include "sanitizer_common/sanitizer_internal_defs.h"
18 #include "dfsan_platform.h"
20 using __sanitizer::uptr;
21 using __sanitizer::u16;
23 // Copy declarations from public sanitizer/dfsan_interface.h header here.
24 typedef u16 dfsan_label;
26 struct dfsan_label_info {
27 dfsan_label l1;
28 dfsan_label l2;
29 const char *desc;
30 void *userdata;
33 extern "C" {
34 void dfsan_add_label(dfsan_label label, void *addr, uptr size);
35 void dfsan_set_label(dfsan_label label, void *addr, uptr size);
36 dfsan_label dfsan_read_label(const void *addr, uptr size);
37 dfsan_label dfsan_union(dfsan_label l1, dfsan_label l2);
38 } // extern "C"
40 template <typename T>
41 void dfsan_set_label(dfsan_label label, T &data) { // NOLINT
42 dfsan_set_label(label, (void *)&data, sizeof(T));
45 namespace __dfsan {
47 void InitializeInterceptors();
49 inline dfsan_label *shadow_for(void *ptr) {
50 return (dfsan_label *) ((((uptr) ptr) & ShadowMask()) << 1);
53 inline const dfsan_label *shadow_for(const void *ptr) {
54 return shadow_for(const_cast<void *>(ptr));
57 struct Flags {
58 #define DFSAN_FLAG(Type, Name, DefaultValue, Description) Type Name;
59 #include "dfsan_flags.inc"
60 #undef DFSAN_FLAG
62 void SetDefaults();
65 extern Flags flags_data;
66 inline Flags &flags() {
67 return flags_data;
70 } // namespace __dfsan
72 #endif // DFSAN_H