[PATCH] [dfsan] Begin a private header and move shadow_for there.

Peter Collingbourne peter at pcc.me.uk
Fri Aug 9 19:03:51 PDT 2013


Hi eugenis,

http://llvm-reviews.chandlerc.com/D1348

Files:
  lib/dfsan/dfsan.cc
  lib/dfsan/dfsan.h

Index: lib/dfsan/dfsan.cc
===================================================================
--- lib/dfsan/dfsan.cc
+++ 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 @@
   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
Index: lib/dfsan/dfsan.h
===================================================================
--- /dev/null
+++ 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1348.1.patch
Type: text/x-patch
Size: 1851 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130809/e4e4d2b1/attachment.bin>


More information about the llvm-commits mailing list