[PATCH] D136815: [clang][Interp] Unify visiting variable declarations

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 1 07:33:05 PST 2022


tbaeder marked 4 inline comments as done.
tbaeder added inline comments.


================
Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:1127
         return false;
-      if (!this->emitInitGlobal(*T, *I, VD))
+    }
+  } else {
----------------
aaron.ballman wrote:
> tbaeder wrote:
> > aaron.ballman wrote:
> > > and if we have no `GlobalIndex`?
> > > 
> > > Should this instead be:
> > > ```
> > > if (auto GlobalIndex = P.getGlobal(VD); !GlobalIndex || !this->emitGetPtrGlobal(*GlobalIndex, VD))
> > >   return false;
> > > ```
> > > 
> > I mean, that shouldn't happen because the `visitVarDecl` call before would've returned `false` in that case.
> The use of an `if` makes it seem like it could fail. Perhaps we should drop the `if` and use an `assert`?
What do you think about returning a `tuple(valid, offset)` from `visitVarDecl`? Although that might make the call in `ByteCodeStmtGen.cpp` a little awkward.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136815/new/

https://reviews.llvm.org/D136815



More information about the cfe-commits mailing list