[ASan] Move error reporting code away from file with interceptors

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@161570 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/asan/asan_interceptors.cc b/lib/asan/asan_interceptors.cc
index ec03fff..59903f7 100644
--- a/lib/asan/asan_interceptors.cc
+++ b/lib/asan/asan_interceptors.cc
@@ -17,6 +17,7 @@
 #include "asan_interface.h"
 #include "asan_internal.h"
 #include "asan_mapping.h"
+#include "asan_report.h"
 #include "asan_stack.h"
 #include "asan_stats.h"
 #include "asan_thread_registry.h"
@@ -190,11 +191,9 @@
   const char *offset1 = (const char*)_offset1; \
   const char *offset2 = (const char*)_offset2; \
   if (RangesOverlap(offset1, length1, offset2, length2)) { \
-    AsanReport("ERROR: AddressSanitizer %s-param-overlap: " \
-               "memory ranges [%p,%p) and [%p, %p) overlap\n", \
-               name, offset1, offset1 + length1, offset2, offset2 + length2); \
-    PRINT_CURRENT_STACK(); \
-    ShowStatsAndAbort(); \
+    GET_STACK_TRACE_HERE(kStackTraceMax); \
+    ReportStringFunctionMemoryRangesOverlap(name, offset1, length1, \
+                                            offset2, length2, &stack); \
   } \
 } while (0)
 
diff --git a/lib/asan/asan_report.cc b/lib/asan/asan_report.cc
index 05d9386..bf6c7d3 100644
--- a/lib/asan/asan_report.cc
+++ b/lib/asan/asan_report.cc
@@ -62,5 +62,14 @@
   ShowStatsAndAbort();
 }
 
+void ReportStringFunctionMemoryRangesOverlap(
+    const char *function, const char *offset1, uptr length1,
+    const char *offset2, uptr length2, AsanStackTrace *stack) {
+  AsanReport("ERROR: AddressSanitizer %s-param-overlap: "
+             "memory ranges [%p,%p) and [%p, %p) overlap\n", \
+             function, offset1, offset1 + length1, offset2, offset2 + length2);
+  stack->PrintStack();
+  ShowStatsAndAbort();
+}
 
 }  // namespace __asan
diff --git a/lib/asan/asan_report.h b/lib/asan/asan_report.h
index 952a4ba..5e0e2de 100644
--- a/lib/asan/asan_report.h
+++ b/lib/asan/asan_report.h
@@ -24,5 +24,8 @@
                                              AsanStackTrace *stack);
 void NORETURN ReportAsanGetAllocatedSizeNotOwned(uptr addr,
                                                  AsanStackTrace *stack);
+void NORETURN ReportStringFunctionMemoryRangesOverlap(
+    const char *function, const char *offset1, uptr length1,
+    const char *offset2, uptr length2, AsanStackTrace *stack);
 
 }  // namespace __asan