[PATCH] D158502: [clang][Interp] Actually consider ConstantExpr result
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 22 03:28:15 PDT 2023
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, shafik, cor3ntin.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Since we have visitAPValue now, we might as well use it here.
Not really possible to test this, so no test included.
Repository:
rG LLVM Github Monorepo
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
@@ -764,8 +764,11 @@
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.
+ 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.552297.patch
Type: text/x-patch
Size: 669 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230822/85a4e522/attachment.bin>
More information about the cfe-commits
mailing list