[llvm] [NFC][TableGen] Code cleanup in Record.h/cpp (PR #138876)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Thu May 8 13:03:23 PDT 2025


================
@@ -2893,54 +2848,38 @@ std::string RecordVal::getPrintType() const {
 }
 
 bool RecordVal::setValue(const Init *V) {
-  if (V) {
-    Value = V->getCastTo(getType());
-    if (Value) {
-      assert(!isa<TypedInit>(Value) ||
-             cast<TypedInit>(Value)->getType()->typeIsA(getType()));
-      if (const auto *BTy = dyn_cast<BitsRecTy>(getType())) {
-        if (!isa<BitsInit>(Value)) {
-          SmallVector<const Init *, 64> Bits;
-          Bits.reserve(BTy->getNumBits());
-          for (unsigned I = 0, E = BTy->getNumBits(); I < E; ++I)
-            Bits.push_back(Value->getBit(I));
-          Value = BitsInit::get(V->getRecordKeeper(), Bits);
-        }
-      }
+  if (!V) {
+    Value = nullptr;
+    return false;
+  }
+
+  Value = V->getCastTo(getType());
+  if (!Value)
+    return true;
+
+  assert(!isa<TypedInit>(Value) ||
+         cast<TypedInit>(Value)->getType()->typeIsA(getType()));
+  if (const auto *BTy = dyn_cast<BitsRecTy>(getType())) {
+    if (!isa<BitsInit>(Value)) {
+      SmallVector<const Init *, 64> Bits;
+      Bits.reserve(BTy->getNumBits());
----------------
jurahul wrote:

Done

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


More information about the llvm-commits mailing list