[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 02:46:32 PST 2022


tbaeder marked 3 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:
> 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.


================
Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:1161
+      if (VarT) {
+        if (!this->visit(Init))
           return false;
----------------
aaron.ballman wrote:
> What if `Init` is `nullptr`?
Global variables (or local constexpr ones) must have an initializer, no?


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

https://reviews.llvm.org/D136815



More information about the cfe-commits mailing list