diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-05-09 19:45:46 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-05-09 19:45:46 +0000 |
commit | 77d2b2537b1d0c5107bbc5c4cfc129bc70cbb506 (patch) | |
tree | 459fca9f4af5a636bf11f0e3a49c819ec893b809 /lib/Parse/ParseDecl.cpp | |
parent | 00f43c390b0626bba117e87005c615f5ab0df723 (diff) | |
download | clang-77d2b2537b1d0c5107bbc5c4cfc129bc70cbb506.tar.gz |
Simplify tracking of end of consumed decl-specifier sequence.
Patch by Tyker!
Differential Revision: https://reviews.llvm.org/D60934
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@360369 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDecl.cpp')
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index bf13dd9611..86fb8897e6 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -3004,12 +3004,12 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, while (1) { bool isInvalid = false; bool isStorageClass = false; - bool isAlreadyConsumed = false; const char *PrevSpec = nullptr; unsigned DiagID = 0; - // This value need to be set when isAlreadyConsumed is set to true. - SourceLocation RangeEnd; + // This value needs to be set to the location of the last token if the last + // token of the specifier is already consumed. + SourceLocation ConsumedEnd; // HACK: MSVC doesn't consider _Atomic to be a keyword and its STL // implementation for VS2013 uses _Atomic as an identifier for one of the @@ -3566,8 +3566,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, SourceLocation ExplicitLoc = Loc; SourceLocation CloseParenLoc; ExplicitSpecifier ExplicitSpec(nullptr, ExplicitSpecKind::ResolvedTrue); - isAlreadyConsumed = true; - RangeEnd = ExplicitLoc; + ConsumedEnd = ExplicitLoc; ConsumeToken(); // kw_explicit if (Tok.is(tok::l_paren)) { if (getLangOpts().CPlusPlus2a) { @@ -3575,7 +3574,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, BalancedDelimiterTracker Tracker(*this, tok::l_paren); Tracker.consumeOpen(); ExplicitExpr = ParseConstantExpression(); - RangeEnd = Tok.getLocation(); + ConsumedEnd = Tok.getLocation(); if (ExplicitExpr.isUsable()) { CloseParenLoc = Tok.getLocation(); Tracker.consumeClose(); @@ -3934,10 +3933,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, continue; } - assert((!isAlreadyConsumed || RangeEnd != SourceLocation()) && - "both or neither of isAlreadyConsumed and " - "RangeEnd needs to be set"); - DS.SetRangeEnd(isAlreadyConsumed ? RangeEnd : Tok.getLocation()); + DS.SetRangeEnd(ConsumedEnd.isValid() ? ConsumedEnd : Tok.getLocation()); // If the specifier wasn't legal, issue a diagnostic. if (isInvalid) { @@ -3958,7 +3954,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, Diag(Loc, DiagID) << PrevSpec; } - if (DiagID != diag::err_bool_redeclaration && !isAlreadyConsumed) + if (DiagID != diag::err_bool_redeclaration && ConsumedEnd.isInvalid()) // After an error the next token can be an annotation token. ConsumeAnyToken(); |