[Mlir-commits] [clang] [llvm] [mlir] [LLVM][TableGen] Change all `Init` pointers to const (PR #112705)

Craig Topper llvmlistbot at llvm.org
Thu Oct 17 11:55:07 PDT 2024


================
@@ -551,18 +552,18 @@ std::string BitsInit::getAsString() const {
 
 // resolveReferences - If there are any field references that refer to fields
 // that have been filled in, we can propagate the values now.
-Init *BitsInit::resolveReferences(Resolver &R) const {
+const Init *BitsInit::resolveReferences(Resolver &R) const {
   bool Changed = false;
-  SmallVector<Init *, 16> NewBits(getNumBits());
+  SmallVector<const Init *, 16> NewBits(getNumBits());
 
-  Init *CachedBitVarRef = nullptr;
-  Init *CachedBitVarResolved = nullptr;
+  const Init *CachedBitVarRef = nullptr;
+  const Init *CachedBitVarResolved = nullptr;
 
   for (unsigned i = 0, e = getNumBits(); i != e; ++i) {
-    Init *CurBit = getBit(i);
-    Init *NewBit = CurBit;
+    const Init *CurBit = getBit(i);
+    const Init *NewBit = CurBit;
 
-    if (VarBitInit *CurBitVar = dyn_cast<VarBitInit>(CurBit)) {
+    if (const VarBitInit *CurBitVar = dyn_cast<VarBitInit>(CurBit)) {
----------------
topperc wrote:

Could use `auto *CurBitVar` here and on all the other dyn_cast/cast. But you don't have to.

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


More information about the Mlir-commits mailing list