[llvm] [TableGen] Skip non-TypedInit values in resolveInitTypes instead of leaving VTy null (PR #205746)

Jaydeep Chauhan via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 25 01:07:51 PDT 2026


https://github.com/JaydeepChauhan14 created https://github.com/llvm/llvm-project/pull/205746

Avoids a potential null dereference by skipping values that cannot be cast to TypedInit rather than proceeding with a null VTy.

>From 2dd71c8d22a7cf574119275f6efa48457e7aece9 Mon Sep 17 00:00:00 2001
From: Chauhan Jaydeep Ashwinbhai <chauhan.jaydeep.ashwinbhai at intel.com>
Date: Thu, 25 Jun 2026 01:02:32 -0700
Subject: [PATCH] [TableGen] Skip non-TypedInit values in resolveInitTypes
 instead of leaving VTy null

---
 llvm/lib/TableGen/TGParser.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp
index b1fbf3b571b2c..e0f6337880c4d 100644
--- a/llvm/lib/TableGen/TGParser.cpp
+++ b/llvm/lib/TableGen/TGParser.cpp
@@ -2750,9 +2750,10 @@ TGParser::resolveInitTypes(ArrayRef<const Init *> Inits, const Twine &ErrCtx) {
     if (isa<UnsetInit>(V))
       continue;
 
-    const RecTy *VTy = nullptr;
-    if (const auto *Vt = dyn_cast<TypedInit>(V))
-      VTy = Vt->getType();
+    const auto *Vt = dyn_cast<TypedInit>(V);
+    if (!Vt)
+      continue;
+    const RecTy *VTy = Vt->getType();
 
     if (!Type) {
       Type = VTy;



More information about the llvm-commits mailing list