[PATCH] D158502: [clang][Interp] Actually consider ConstantExpr result
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 14 00:28:18 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG293ae0b4b45f: [clang][Interp] Actually consider ConstantExpr result (authored by tbaeder).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D158502/new/
https://reviews.llvm.org/D158502
Files:
clang/lib/AST/Interp/ByteCodeExprGen.cpp
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===================================================================
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -634,8 +634,14 @@
template <class Emitter>
bool ByteCodeExprGen<Emitter>::VisitConstantExpr(const ConstantExpr *E) {
- // TODO: Check if the ConstantExpr already has a value set and if so,
- // use that instead of evaluating it again.
+ // Try to emit the APValue directly, without visiting the subexpr.
+ // This will only fail if we can't emit the APValue, so won't emit any
+ // diagnostics or any double values.
+ std::optional<PrimType> T = classify(E->getType());
+ if (T && E->hasAPValueResult() &&
+ this->visitAPValue(E->getAPValueResult(), *T, E))
+ return true;
+
return this->delegate(E->getSubExpr());
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158502.556746.patch
Type: text/x-patch
Size: 853 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230914/ad2686f7/attachment.bin>
More information about the cfe-commits
mailing list