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

via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 25 01:08:28 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-tablegen

Author: Jaydeep Chauhan (JaydeepChauhan14)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/205746.diff


1 Files Affected:

- (modified) llvm/lib/TableGen/TGParser.cpp (+4-3) 


``````````diff
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;

``````````

</details>


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


More information about the llvm-commits mailing list