From: David Majnemer Date: Mon, 12 Jan 2015 05:17:40 +0000 (+0000) Subject: Parse: Get rid of tok::cxx_defaultarg_end, use EOF instead X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=614938ef44be34559c964108dfa6fdf7b64c56b5;p=clang Parse: Get rid of tok::cxx_defaultarg_end, use EOF instead I added setEofData/getEofData to solve this sort of problem back in r224505. Use the Param's decl to tell us if this is *our* EOF token. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225619 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/TokenKinds.def b/include/clang/Basic/TokenKinds.def index c98e8d37f8..e0cc3631ff 100644 --- a/include/clang/Basic/TokenKinds.def +++ b/include/clang/Basic/TokenKinds.def @@ -116,7 +116,6 @@ TOK(eof) // End of file. TOK(eod) // End of preprocessing directive (end of line inside a // directive). TOK(code_completion) // Code completion marker -TOK(cxx_defaultarg_end) // C++ default argument end marker TOK(cxx_exceptspec_end) // C++ exception-specification end marker // C99 6.4.9: Comments. diff --git a/lib/Parse/ParseCXXInlineMethods.cpp b/lib/Parse/ParseCXXInlineMethods.cpp index ccd051721f..375041ebe1 100644 --- a/lib/Parse/ParseCXXInlineMethods.cpp +++ b/lib/Parse/ParseCXXInlineMethods.cpp @@ -342,7 +342,9 @@ void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) { Actions.ActOnParamDefaultArgumentError(LM.DefaultArgs[I].Param, EqualLoc); else { - if (!TryConsumeToken(tok::cxx_defaultarg_end)) { + if (Tok.is(tok::eof) && Tok.getEofData() == LM.DefaultArgs[I].Param) { + ConsumeAnyToken(); + } else { // The last two tokens are the terminator and the saved value of // Tok; the last token in the default argument is the one before // those. @@ -360,8 +362,11 @@ void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) { "ParseAssignmentExpression went over the default arg tokens!"); // There could be leftover tokens (e.g. because of an error). // Skip through until we reach the original token position. - while (Tok.getLocation() != origLoc && Tok.isNot(tok::eof)) + while (Tok.getLocation() != origLoc) { + if (Tok.is(tok::eof) && Tok.getEofData() != LM.DefaultArgs[I].Param) + break; ConsumeAnyToken(); + } delete Toks; LM.DefaultArgs[I].Toks = nullptr; @@ -652,7 +657,6 @@ bool Parser::ConsumeAndStoreUntil(tok::TokenKind T1, tok::TokenKind T2, 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: diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 7ff39aabeb..66366d9919 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -5631,8 +5631,9 @@ void Parser::ParseParameterDeclarationClause( // stop when we parse it later on. Token DefArgEnd; DefArgEnd.startToken(); - DefArgEnd.setKind(tok::cxx_defaultarg_end); + DefArgEnd.setKind(tok::eof); DefArgEnd.setLocation(Tok.getLocation()); + DefArgEnd.setEofData(Param); DefArgToks->push_back(DefArgEnd); Actions.ActOnParamUnparsedDefaultArgument(Param, EqualLoc, (*DefArgToks)[1].getLocation()); diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index 06a70f7fd3..7ccd2092a2 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -262,10 +262,6 @@ bool Parser::SkipUntil(ArrayRef Toks, SkipUntilFlags Flags) { // 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: