[PATCH] D98433: [clang] [C++2b] [P1102] Accept lambdas without parameter list ().
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 15 09:31:50 PDT 2021
aaron.ballman added inline comments.
================
Comment at: clang/lib/Parse/ParseExprCXX.cpp:1438
- // Parse trailing-return-type[opt].
- if (Tok.is(tok::arrow)) {
- FunLocalRangeEnd = Tok.getLocation();
- SourceRange Range;
- TrailingReturnType =
- ParseTrailingReturnType(Range, /*MayBeFollowedByDirectInit*/ false);
- TrailingReturnTypeLoc = Range.getBegin();
- if (Range.getEnd().isValid())
- DeclEndLoc = Range.getEnd();
- }
+ PrototypeScope.Exit();
+ } else if (getLangOpts().CPlusPlus2b) {
----------------
No need to call this here, it happens from the destructor of `ParseScope`.
================
Comment at: clang/lib/Parse/ParseExprCXX.cpp:1440
+ } else if (getLangOpts().CPlusPlus2b) {
+ ParseScope PrototypeScope(this, Scope::FunctionPrototypeScope |
+ Scope::FunctionDeclarationScope |
----------------
I don't know the answer to this, but... do we need a prototype scope at all when there's no parameter list? The old code was doing this, so I don't think this is an issue with your patch per se, more just curiosity whether this is necessary in this case.
================
Comment at: clang/lib/Parse/ParseExprCXX.cpp:1447
+ std::vector<DeclaratorChunk::ParamInfo> EmptyParamInfo;
+ ParseLambdaSpecifiers(/*LParenLoc=*/NoLoc, /*RParenLoc=*/NoLoc,
+ EmptyParamInfo, /*EllipsisLoc=*/NoLoc);
----------------
curdeius wrote:
> I'm not sure what I should do with `LParenLoc` and `RParenLoc`. Any idea?
What you've done here seems reasonable to me. The `SourceLocation` for the parens will be invalid, which is the behavior I'd expect when the parens are missing.
================
Comment at: clang/lib/Parse/ParseExprCXX.cpp:1450
PrototypeScope.Exit();
} else if (Tok.isOneOf(tok::kw_mutable, tok::arrow, tok::kw___attribute,
----------------
No need to call this here, it happens from the destructor of `ParseScope`.
================
Comment at: clang/test/Parser/cxx2b-lambdas.cpp:22
+auto XL1 = [] constexpr mutable constexpr {}; // expected-error{{cannot appear multiple times}}
+auto XL2 = []) constexpr mutable constexpr {}; // expected-error{{expected body}}
----------------
It'd be handy to test: `auto XL3 = []( constexpr mutable constexpr {}; ` where the parameter list is missing the closing right paren.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98433/new/
https://reviews.llvm.org/D98433
More information about the cfe-commits
mailing list