[compiler-rt] [ubsan] Drop terminal "in " from reports without functions (PR #77163)

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 5 17:05:10 PST 2024


https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/77163

>From f79754922035ca6ce245e27707c6b35174f8e058 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Fri, 5 Jan 2024 16:17:03 -0800
Subject: [PATCH] [ubsan] Drop terminal "in " from reports without functions

Pull Request: https://github.com/llvm/llvm-project/pull/77163
---
 compiler-rt/lib/ubsan/ubsan_diag.cpp                  | 2 +-
 compiler-rt/test/ubsan/TestCases/Misc/print_summary.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/compiler-rt/lib/ubsan/ubsan_diag.cpp b/compiler-rt/lib/ubsan/ubsan_diag.cpp
index aac27041531851..67e884e4916c50 100644
--- a/compiler-rt/lib/ubsan/ubsan_diag.cpp
+++ b/compiler-rt/lib/ubsan/ubsan_diag.cpp
@@ -88,7 +88,7 @@ static void MaybeReportErrorSummary(Location Loc, ErrorType Type) {
       AI.file = internal_strdup(SLoc.getFilename());
       AI.line = SLoc.getLine();
       AI.column = SLoc.getColumn();
-      AI.function = internal_strdup("");  // Avoid printing ?? as function name.
+      AI.function = nullptr;
       ReportErrorSummary(ErrorKind, AI, GetSanititizerToolName());
       AI.Clear();
       return;
diff --git a/compiler-rt/test/ubsan/TestCases/Misc/print_summary.c b/compiler-rt/test/ubsan/TestCases/Misc/print_summary.c
index b67a0614dd2f11..17885094b6ad76 100644
--- a/compiler-rt/test/ubsan/TestCases/Misc/print_summary.c
+++ b/compiler-rt/test/ubsan/TestCases/Misc/print_summary.c
@@ -2,8 +2,8 @@
 // RUN: %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT
 // RUN: %env_ubsan_opts=print_summary=0 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NO_SUMMARY
 
-// CHECK-DEFAULT: SUMMARY: UndefinedBehaviorSanitizer: {{.*}}
-// CHECK-NO_SUMMARY-NOT: SUMMARY: UndefinedBehaviorSanitizer: {{.*}}
+// CHECK-DEFAULT: SUMMARY: UndefinedBehaviorSanitizer: {{.*}}print_summary.c{{[:0-9 ]*$}}
+// CHECK-NO_SUMMARY-NOT: SUMMARY: UndefinedBehaviorSanitizer:
 
 int main(int argc, char **argv) {
   int arr[argc - 2];



More information about the llvm-commits mailing list