[PATCH] D76447: Apply ConstantEvaluated evaluation contexts to more manifestly constant evaluated scopes
Wyatt Childers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 19 13:09:23 PDT 2020
wchilders created this revision.
wchilders added reviewers: Tyker, rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
wchilders marked an inline comment as done.
wchilders added inline comments.
================
Comment at: clang/lib/Sema/SemaExpr.cpp:15597
+ (Rec.isConstantEvaluated() &&
+ Rec.ExprContext != ExpressionKind::EK_ConstexprVarInit)) {
ExprCleanupObjects.erase(ExprCleanupObjects.begin() + Rec.NumCleanupObjects,
----------------
This is my main concern with this patch. There's something subtle here, and it's unclear from an outsider's (my) perspective what the root issue is here.
Effectively we get into trouble when we first enter `ActOnCXXEnterDeclInitializer` on the `isManifestlyEvaluatedVar` branch. We then exit at `ActOnCXXExitDeclInitializer`, triggering this branch, as `Rec.isConstantEvaluated()` is true. This results in the cleanups being dropped. Then when we enter the constexpr evaluator for `VarDecl::evaluateValue`. the evaluator is unhappy as we're missing a cleanup for the created temporary.
Any input that allows this to be resolved without the special case, or that otherwise informs how this should work, and why unevaluated and constant evaluated are treated equally here, would be awesome. I'll note that in reviewing the revision history, this condition dates back to when `ConstantEvaluated` was created, so perhaps this is a "historical artifact" of that time?
This patch attempts to update application of evaluation contexts to better represent, what is manifestly constant evaluated.
There are some outstanding concerns I'll mark with inline comments.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D76447
Files:
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Parse/ParseStmt.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Sema/TreeTransform.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76447.251450.patch
Type: text/x-patch
Size: 8823 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200319/f838106c/attachment-0001.bin>
More information about the cfe-commits
mailing list