summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2013-08-12 23:51:33 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2013-08-12 23:51:33 +0000
commitfa9f5aef0583535f3ac1fa444f2cf62db324537e (patch)
tree10613e639be941f0d8bab5eaffa2578135e82ab9 /lib
parent249cdca5989af3b55e42460283ca63096aeddfeb (diff)
[dfsan] Begin a private header and move shadow_for there.
Differential Revision: http://llvm-reviews.chandlerc.com/D1348 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@188231 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/dfsan/dfsan.cc8
-rw-r--r--lib/dfsan/dfsan.h32
2 files changed, 36 insertions, 4 deletions
diff --git a/lib/dfsan/dfsan.cc b/lib/dfsan/dfsan.cc
index de9137887..02f64deeb 100644
--- a/lib/dfsan/dfsan.cc
+++ b/lib/dfsan/dfsan.cc
@@ -24,6 +24,10 @@
#include "sanitizer_common/sanitizer_common.h"
#include "sanitizer_common/sanitizer_libc.h"
+#include "dfsan/dfsan.h"
+
+using namespace __dfsan;
+
typedef atomic_uint16_t atomic_dfsan_label;
static const dfsan_label kInitializingLabel = -1;
@@ -68,10 +72,6 @@ static atomic_dfsan_label *union_table(dfsan_label l1, dfsan_label l2) {
return &(*(dfsan_union_table_t *) kUnionTableAddr)[l1][l2];
}
-static dfsan_label *shadow_for(void *ptr) {
- return (dfsan_label *) ((((uintptr_t) ptr) & ~0x700000000000) << 1);
-}
-
// Resolves the union of two unequal labels. Nonequality is a precondition for
// this function (the instrumentation pass inlines the equality test).
extern "C" SANITIZER_INTERFACE_ATTRIBUTE
diff --git a/lib/dfsan/dfsan.h b/lib/dfsan/dfsan.h
new file mode 100644
index 000000000..873eb31a5
--- /dev/null
+++ b/lib/dfsan/dfsan.h
@@ -0,0 +1,32 @@
+//===-- dfsan.h -------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is a part of DataFlowSanitizer.
+//
+// Private DFSan header.
+//===----------------------------------------------------------------------===//
+
+#ifndef DFSAN_H
+#define DFSAN_H
+
+#include "sanitizer/dfsan_interface.h"
+
+namespace __dfsan {
+
+inline dfsan_label *shadow_for(void *ptr) {
+ return (dfsan_label *) ((((uintptr_t) ptr) & ~0x700000000000) << 1);
+}
+
+inline const dfsan_label *shadow_for(const void *ptr) {
+ return shadow_for(const_cast<void *>(ptr));
+}
+
+} // namespace __dfsan
+
+#endif // DFSAN_H