[llvm] 576aa3a - [TableGen] Resolve References at top level (#104578)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 19 08:35:43 PDT 2024
Author: Akshat Oke
Date: 2024-08-19T21:05:39+05:30
New Revision: 576aa3a50960f02e4dfe2d6ed2c55aa66006adcf
URL: https://github.com/llvm/llvm-project/commit/576aa3a50960f02e4dfe2d6ed2c55aa66006adcf
DIFF: https://github.com/llvm/llvm-project/commit/576aa3a50960f02e4dfe2d6ed2c55aa66006adcf.diff
LOG: [TableGen] Resolve References at top level (#104578)
Add a dummy resolver to resolve references outside records. This invokes
Fold() with isFinal to force resolution.
Fixes #102447
Co-authored-by: Akshat Oke <Akshat.Oke at amd.com>
Added:
Modified:
llvm/lib/TableGen/TGParser.cpp
llvm/test/TableGen/dump.td
Removed:
################################################################################
diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp
index ce9da960545c23..d1d46105c814e9 100644
--- a/llvm/lib/TableGen/TGParser.cpp
+++ b/llvm/lib/TableGen/TGParser.cpp
@@ -4460,8 +4460,13 @@ bool TGParser::ParseDump(MultiClass *CurMultiClass, Record *CurRec) {
if (CurRec)
CurRec->addDump(Loc, Message);
- else
- addEntry(std::make_unique<Record::DumpInfo>(Loc, Message));
+ else {
+ HasReferenceResolver resolver{nullptr};
+ resolver.setFinal(true);
+ // force a resolution with a dummy resolver
+ Init *ResolvedMessage = Message->resolveReferences(resolver);
+ addEntry(std::make_unique<Record::DumpInfo>(Loc, ResolvedMessage));
+ }
return false;
}
diff --git a/llvm/test/TableGen/dump.td b/llvm/test/TableGen/dump.td
index 633e73802ffa3e..7f021755e2e821 100644
--- a/llvm/test/TableGen/dump.td
+++ b/llvm/test/TableGen/dump.td
@@ -101,3 +101,6 @@ def Three : BaseClassForSet;
}
// CHECK: [[FILE]]:[[@LINE+1]]:1: note: TheSet = [Subset_One, Subset_Two, Three]
dump "TheSet = " # !repr(TheSet);
+
+// CHECK: [[FILE]]:[[@LINE+1]]:1: note: 0
+dump !repr(!exists<BaseClassForSet>("non-existent-record"));
\ No newline at end of file
More information about the llvm-commits
mailing list