[ASan] Moved __asan_test_only_reported_buggy_pointer to ReportGenericError, which is needed for shared optimzied callback tests.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D114486

GitOrigin-RevId: a489d6c5e0158eb92025b27bce958595c20d3ecf
diff --git a/lib/asan/asan_report.cpp b/lib/asan/asan_report.cpp
index 1f26633..2a38fab 100644
--- a/lib/asan/asan_report.cpp
+++ b/lib/asan/asan_report.cpp
@@ -460,6 +460,10 @@
 
 void ReportGenericError(uptr pc, uptr bp, uptr sp, uptr addr, bool is_write,
                         uptr access_size, u32 exp, bool fatal) {
+  if (__asan_test_only_reported_buggy_pointer) {
+    *__asan_test_only_reported_buggy_pointer = addr;
+    return;
+  }
   if (!fatal && SuppressErrorReport(pc)) return;
   ENABLE_FRAME_POINTER;
 
diff --git a/lib/asan/asan_rtl.cpp b/lib/asan/asan_rtl.cpp
index 1b150b3..5be8ef0 100644
--- a/lib/asan/asan_rtl.cpp
+++ b/lib/asan/asan_rtl.cpp
@@ -85,12 +85,8 @@
 NOINLINE
 static void ReportGenericErrorWrapper(uptr addr, bool is_write, int size,
                                       int exp_arg, bool fatal) {
-  if (__asan_test_only_reported_buggy_pointer) {
-    *__asan_test_only_reported_buggy_pointer = addr;
-  } else {
-    GET_CALLER_PC_BP_SP;
-    ReportGenericError(pc, bp, sp, addr, is_write, size, exp_arg, fatal);
-  }
+  GET_CALLER_PC_BP_SP;
+  ReportGenericError(pc, bp, sp, addr, is_write, size, exp_arg, fatal);
 }
 
 // --------------- LowLevelAllocateCallbac ---------- {{{1