[llvm] [TableGen] Fix source location for anonymous records (PR #110935)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 2 16:37:17 PDT 2024


================
@@ -2292,11 +2292,12 @@ static void ProfileVarDefInit(FoldingSetNodeID &ID, Record *Class,
     ID.AddPointer(I);
 }
 
-VarDefInit::VarDefInit(Record *Class, unsigned N)
-    : TypedInit(IK_VarDefInit, RecordRecTy::get(Class)), Class(Class),
+VarDefInit::VarDefInit(SMLoc Loc, Record *Class, unsigned N)
+    : TypedInit(IK_VarDefInit, RecordRecTy::get(Class)), Loc(Loc), Class(Class),
       NumArgs(N) {}
 
-VarDefInit *VarDefInit::get(Record *Class, ArrayRef<ArgumentInit *> Args) {
+VarDefInit *VarDefInit::get(SMLoc Loc, Record *Class,
+                            ArrayRef<ArgumentInit *> Args) {
   FoldingSetNodeID ID;
   ProfileVarDefInit(ID, Class, Args);
----------------
jurahul wrote:

Just a note: The folding set only uses the class and args as the key, and not the loc. This means that if there are multiple anonymous instantiations with the same args, we still generate a single record, but just use the Loc for the first VarDefInit that ends up instantiating the record.

https://github.com/llvm/llvm-project/pull/110935


More information about the llvm-commits mailing list