[PATCH] D142844: [LTO] Demangle the function name in DiagnosticInfoDontCall message

Kyuwon Cho via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 29 12:22:38 PST 2023


ChoKyuWon updated this revision to Diff 493126.
ChoKyuWon added a comment.

Add test


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142844/new/

https://reviews.llvm.org/D142844

Files:
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/test/Linker/diagnostic_demangle.ll


Index: llvm/test/Linker/diagnostic_demangle.ll
===================================================================
--- /dev/null
+++ llvm/test/Linker/diagnostic_demangle.ll
@@ -0,0 +1,26 @@
+; RUN: not llc < %s 2>&1 | FileCheck %s
+
+declare void @foo() "dontcall-error"
+
+declare i32 @_Z3fooi(i32) "dontcall-error"
+
+declare float @_Z3barf(float) "dontcall-error"
+
+declare i32 @_RNvC1a3baz() "dontcall-error"
+
+declare i32 @_Z3fooILi79EEbU7_ExtIntIXT_EEi(i32) "dontcall-error"
+
+define void @bar() {
+  call void @foo()
+  call i32 @_Z3fooi (i32 0)
+  call float @_Z3barf(float 0.0)
+  call i32 @_RNvC1a3baz()
+  call i32 @_Z3fooILi79EEbU7_ExtIntIXT_EEi(i32 0)
+  ret void
+}
+
+; CHECK: error: call to foo marked "dontcall-error"
+; CHECK: error: call to foo(int) marked "dontcall-error"
+; CHECK: error: call to bar(float) marked "dontcall-error"
+; CHECK: error: call to a::baz marked "dontcall-error"
+; CHECK: error: call to bool foo<79>(int _ExtInt<79>) marked "dontcall-error"
\ No newline at end of file
Index: llvm/lib/IR/DiagnosticInfo.cpp
===================================================================
--- llvm/lib/IR/DiagnosticInfo.cpp
+++ llvm/lib/IR/DiagnosticInfo.cpp
@@ -15,6 +15,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/ADT/iterator_range.h"
+#include "llvm/Demangle/Demangle.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DebugInfoMetadata.h"
@@ -440,7 +441,8 @@
 }
 
 void DiagnosticInfoDontCall::print(DiagnosticPrinter &DP) const {
-  DP << "call to " << getFunctionName() << " marked \"dontcall-";
+  DP << "call to " << demangle(getFunctionName().str())
+     << " marked \"dontcall-";
   if (getSeverity() == DiagnosticSeverity::DS_Error)
     DP << "error\"";
   else


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142844.493126.patch
Type: text/x-patch
Size: 1790 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230129/c5549e7d/attachment.bin>


More information about the llvm-commits mailing list