[PATCH] D155548: [clang][ExprConst] Short-circuit ConstantExpr evaluation
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 10 04:27:28 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb4343aba9fa1: [clang][ExprConst] Short-circuit ConstantExpr evaluation (authored by tbaeder).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155548/new/
https://reviews.llvm.org/D155548
Files:
clang/lib/AST/ExprConstant.cpp
Index: clang/lib/AST/ExprConstant.cpp
===================================================================
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -15327,6 +15327,17 @@
return true;
}
+ if (const auto *CE = dyn_cast<ConstantExpr>(Exp)) {
+ if (CE->hasAPValueResult()) {
+ Result.Val = CE->getAPValueResult();
+ IsConst = true;
+ return true;
+ }
+
+ // The SubExpr is usually just an IntegerLiteral.
+ return FastEvaluateAsRValue(CE->getSubExpr(), Result, Ctx, IsConst);
+ }
+
// This case should be rare, but we need to check it before we check on
// the type below.
if (Exp->getType().isNull()) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155548.557668.patch
Type: text/x-patch
Size: 679 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20231010/930e5266/attachment.bin>
More information about the cfe-commits
mailing list