diff options
Diffstat (limited to 'clang/lib/Parse/ParseCXXInlineMethods.cpp')
-rw-r--r-- | clang/lib/Parse/ParseCXXInlineMethods.cpp | 41 |
1 files changed, 2 insertions, 39 deletions
diff --git a/clang/lib/Parse/ParseCXXInlineMethods.cpp b/clang/lib/Parse/ParseCXXInlineMethods.cpp index 9ccbbf9..b461743 100644 --- a/clang/lib/Parse/ParseCXXInlineMethods.cpp +++ b/clang/lib/Parse/ParseCXXInlineMethods.cpp @@ -1205,41 +1205,6 @@ bool Parser::ConsumeAndStoreConditional(CachedTokens &Toks) { return true; } -/// A tentative parsing action that can also revert token annotations. -class Parser::UnannotatedTentativeParsingAction : public TentativeParsingAction { -public: - explicit UnannotatedTentativeParsingAction(Parser &Self, - tok::TokenKind EndKind) - : TentativeParsingAction(Self), Self(Self), EndKind(EndKind) { - // Stash away the old token stream, so we can restore it once the - // tentative parse is complete. - TentativeParsingAction Inner(Self); - Self.ConsumeAndStoreUntil(EndKind, Toks, true, /*ConsumeFinalToken*/false); - Inner.Revert(); - } - - void RevertAnnotations() { - Revert(); - - // Put back the original tokens. - Self.SkipUntil(EndKind, StopAtSemi | StopBeforeMatch); - if (Toks.size()) { - auto Buffer = std::make_unique<Token[]>(Toks.size()); - std::copy(Toks.begin() + 1, Toks.end(), Buffer.get()); - Buffer[Toks.size() - 1] = Self.Tok; - Self.PP.EnterTokenStream(std::move(Buffer), Toks.size(), true, - /*IsReinject*/ true); - - Self.Tok = Toks.front(); - } - } - -private: - Parser &Self; - CachedTokens Toks; - tok::TokenKind EndKind; -}; - /// ConsumeAndStoreInitializer - Consume and store the token at the passed token /// container until the end of the current initializer expression (either a /// default argument or an in-class initializer for a non-static data member). @@ -1277,9 +1242,7 @@ bool Parser::ConsumeAndStoreInitializer(CachedTokens &Toks, // syntactically-valid init-declarator-list, then this comma ends // the default initializer. { - UnannotatedTentativeParsingAction PA(*this, - CIK == CIK_DefaultInitializer - ? tok::semi : tok::r_paren); + TentativeParsingAction TPA(*this, /*Unannotated=*/true); Sema::TentativeAnalysisScope Scope(Actions); TPResult Result = TPResult::Error; @@ -1307,7 +1270,7 @@ bool Parser::ConsumeAndStoreInitializer(CachedTokens &Toks, // Put the token stream back and undo any annotations we performed // after the comma. They may reflect a different parse than the one // we will actually perform at the end of the class. - PA.RevertAnnotations(); + TPA.Revert(); // If what follows could be a declaration, it is a declaration. if (Result != TPResult::False && Result != TPResult::Error) |