Skip to content

Commit 1bc1703

Browse files
authored
DiagnosticPrinter: Use printAsOperand to handle anonymous values (#119491)
To avoid changing the behavior in the general case, only do this for anonymous functions. Otherwise, we'll end up with a leading '@' on the name, which may not be meaningful to end users.
1 parent 884f2ad commit 1bc1703

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

llvm/lib/IR/DiagnosticPrinter.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,12 @@ DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(const Twine &Str) {
9797

9898
// IR related types.
9999
DiagnosticPrinter &DiagnosticPrinterRawOStream::operator<<(const Value &V) {
100-
Stream << V.getName();
100+
// Avoid printing '@' prefix for named functions.
101+
if (V.hasName())
102+
Stream << V.getName();
103+
else
104+
V.printAsOperand(Stream, /*PrintType=*/false);
105+
101106
return *this;
102107
}
103108

0 commit comments

Comments
 (0)