[PATCH] D158502: [clang][Interp] Actually consider ConstantExpr result
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 11 12:23:43 PDT 2023
tbaeder updated this revision to Diff 556474.
tbaeder marked 2 inline comments as done.
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
@@ -733,8 +733,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.556474.patch
Type: text/x-patch
Size: 853 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230911/e4226915/attachment.bin>
More information about the cfe-commits
mailing list