[PATCH] D134475: Add C++11 attribute msvc::constexpr
Richard Dzenis via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 21 08:17:46 PDT 2023
RIscRIpt updated this revision to Diff 515740.
RIscRIpt added a comment.
A proper implementation
In D134475#4224082 <https://reviews.llvm.org/D134475#4224082>, @erichkeane wrote:
> I don't have a good idea, I don't think any sort of RAII object is the right way (since it will be wrong on child calls/etc), and the ParentMap is definitely not the right way. Perhaps just a flag for CheckConstexprFunction? I've not spent too much time in this section of the compiler, so hopefully someone else can come along and help. I suspect it is a property of `CallStackFrame`? But that already contains a link to the FucntionDecl, right? As far as the 'on return statement', I think the bit on CallStackFrame/EvalInfo is probably what is necessary.
> But that already contains a link to the FucntionDecl, right?
Yes, but we need to know current context (whether we're in `[[msvc::constexpr]] return` statement).
> As far as the 'on return statement', I think the bit on CallStackFrame/EvalInfo is probably what is necessary.
That's what I ended-up doing. This was the most reasonable approach I could come-up with.
I added a property to `CallStackFrame`, because it's a property of current function: whether we are in valid context which permits evaluation of `[[msvc::constexpr]]`. Additionally I added `MSConstexprContextRAII` which is used in `case Stmt::AttributedStmtClass:` to alter the property.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134475/new/
https://reviews.llvm.org/D134475
Files:
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticASTKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/AST/ExprConstant.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaStmtAttr.cpp
clang/test/AST/msvc-attrs-invalid.cpp
clang/test/AST/msvc-attrs.cpp
clang/test/AST/msvc-constexpr-new.cpp
clang/test/Misc/pragma-attribute-supported-attributes-list.test
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134475.515740.patch
Type: text/x-patch
Size: 17294 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230421/a3dd16d2/attachment-0001.bin>
More information about the cfe-commits
mailing list