r225616 - Parse: It's cleaner to handle cxx_defaultarg_end in SkipUntil directly
David Majnemer
david.majnemer at gmail.com
Sun Jan 11 19:36:37 PST 2015
Author: majnemer
Date: Sun Jan 11 21:36:37 2015
New Revision: 225616
URL: http://llvm.org/viewvc/llvm-project?rev=225616&view=rev
Log:
Parse: It's cleaner to handle cxx_defaultarg_end in SkipUntil directly
Modified:
cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/test/Parser/cxx-member-initializers.cpp
Modified: cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp?rev=225616&r1=225615&r2=225616&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp (original)
+++ cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp Sun Jan 11 21:36:37 2015
@@ -652,6 +652,7 @@ bool Parser::ConsumeAndStoreUntil(tok::T
switch (Tok.getKind()) {
case tok::eof:
+ case tok::cxx_defaultarg_end:
case tok::annot_module_begin:
case tok::annot_module_end:
case tok::annot_module_include:
Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=225616&r1=225615&r2=225616&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Sun Jan 11 21:36:37 2015
@@ -716,16 +716,9 @@ ExprResult Parser::ParseLambdaExpression
Optional<unsigned> DiagID = ParseLambdaIntroducer(Intro);
if (DiagID) {
Diag(Tok, DiagID.getValue());
- auto SkipUntilLambdaToken = [&](tok::TokenKind LambdaToken) {
- // Don't skip past the end of the default argument.
- SkipUntil(LambdaToken, tok::cxx_defaultarg_end,
- StopAtSemi | StopBeforeMatch);
- if (Tok.is(LambdaToken))
- ConsumeAnyToken();
- };
- SkipUntilLambdaToken(tok::r_square);
- SkipUntilLambdaToken(tok::l_brace);
- SkipUntilLambdaToken(tok::r_brace);
+ SkipUntil(tok::r_square, StopAtSemi);
+ SkipUntil(tok::l_brace, StopAtSemi);
+ SkipUntil(tok::r_brace, StopAtSemi);
return ExprError();
}
Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=225616&r1=225615&r2=225616&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Sun Jan 11 21:36:37 2015
@@ -262,6 +262,10 @@ bool Parser::SkipUntil(ArrayRef<tok::Tok
// Ran out of tokens.
return false;
+ case tok::cxx_defaultarg_end:
+ // It's never desirable to consume the 'end-of-default-argument' token.
+ return false;
+
case tok::annot_pragma_openmp_end:
// Stop before an OpenMP pragma boundary.
case tok::annot_module_begin:
@@ -1948,7 +1952,7 @@ bool BalancedDelimiterTracker::diagnoseM
// token.
if (P.Tok.isNot(tok::r_paren) && P.Tok.isNot(tok::r_brace) &&
P.Tok.isNot(tok::r_square) &&
- P.SkipUntil(Close, FinalToken, tok::cxx_defaultarg_end,
+ P.SkipUntil(Close, FinalToken,
Parser::StopAtSemi | Parser::StopBeforeMatch) &&
P.Tok.is(Close))
LClose = P.ConsumeAnyToken();
Modified: cfe/trunk/test/Parser/cxx-member-initializers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-member-initializers.cpp?rev=225616&r1=225615&r2=225616&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-member-initializers.cpp (original)
+++ cfe/trunk/test/Parser/cxx-member-initializers.cpp Sun Jan 11 21:36:37 2015
@@ -103,5 +103,5 @@ class G {
void l(int x = C<int, C<int, int>::C1>().f()) {}
// This isn't, but it shouldn't crash. The diagnostics don't matter much.
- void m(int x = C<int, union int>().f()) {} // expected-error {{declaration of anonymous union must be a definition}}
-}; // expected-error {{expected a type}}
+ void m(int x = C<int, union int>().f()) {} // expected-error {{declaration of anonymous union must be a definition}} expected-error {{expected a type}}
+};
More information about the cfe-commits
mailing list