[PATCH] D158502: [clang][Interp] Actually consider ConstantExpr result

Corentin Jabot via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 24 23:36:32 PDT 2023


cor3ntin added a comment.

FYI there are build failures. you probably need to rebase (visitAPValue does not seem to actually exist)



================
Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:767-772
+  std::optional<PrimType> T = classify(E->getType());
+  if (T && E->hasAPValueResult() &&
+      this->visitAPValue(E->getAPValueResult(), *T, E))
+    return true;
+
   return this->delegate(E->getSubExpr());
----------------
tbaeder wrote:
> cor3ntin wrote:
> > so if `visitAPValue` fails, we continue. Couldn't that lead to duplicated diagnostics? Shouldn't we simply return whatever `visitAPValue` returns unconditionally?
> I did it this way because we don't handle all types of APValues in `visitAPValue()` (think lvalues with an lvalue path), so in those cases we need to visit the expression instead. If there is an `APValue` we're visting, we're not emitting any diagnostics I think.
Can you add a comment explaining that? I think it would help! thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158502



More information about the cfe-commits mailing list