<div dir="ltr">Thanks!<div><br></div><div>Is it possible to do the same to tok::<span style="font-size:13px">cxx_exceptspec_end? </span><span style="font-size:13px">(I also note we don't currently use an end-of-delayed-tokens marker when delay-parsing function bodies. It probably takes a bit more work to construct a testcase that goes awry, but I suspect that case would benefit from using a synthetic tok::eof too.)</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 11, 2015 at 9:17 PM, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: majnemer<br>
Date: Sun Jan 11 23:17:40 2015<br>
New Revision: 225619<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=225619&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=225619&view=rev</a><br>
Log:<br>
Parse: Get rid of tok::cxx_defaultarg_end, use EOF instead<br>
<br>
I added setEofData/getEofData to solve this sort of problem back in<br>
r224505. Use the Param's decl to tell us if this is *our* EOF token.<br>
<br>
Modified:<br>
cfe/trunk/include/clang/Basic/TokenKinds.def<br>
cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp<br>
cfe/trunk/lib/Parse/ParseDecl.cpp<br>
cfe/trunk/lib/Parse/Parser.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Basic/TokenKinds.def<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=225619&r1=225618&r2=225619&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=225619&r1=225618&r2=225619&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)<br>
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Sun Jan 11 23:17:40 2015<br>
@@ -116,7 +116,6 @@ TOK(eof) // End of file.<br>
TOK(eod) // End of preprocessing directive (end of line inside a<br>
// directive).<br>
TOK(code_completion) // Code completion marker<br>
-TOK(cxx_defaultarg_end) // C++ default argument end marker<br>
TOK(cxx_exceptspec_end) // C++ exception-specification end marker<br>
<br>
// C99 6.4.9: Comments.<br>
<br>
Modified: cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp?rev=225619&r1=225618&r2=225619&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp?rev=225619&r1=225618&r2=225619&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp (original)<br>
+++ cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp Sun Jan 11 23:17:40 2015<br>
@@ -342,7 +342,9 @@ void Parser::ParseLexedMethodDeclaration<br>
Actions.ActOnParamDefaultArgumentError(LM.DefaultArgs[I].Param,<br>
EqualLoc);<br>
else {<br>
- if (!TryConsumeToken(tok::cxx_defaultarg_end)) {<br>
+ if (Tok.is(tok::eof) && Tok.getEofData() == LM.DefaultArgs[I].Param) {<br>
+ ConsumeAnyToken();<br>
+ } else {<br>
// The last two tokens are the terminator and the saved value of<br>
// Tok; the last token in the default argument is the one before<br>
// those.<br>
@@ -360,8 +362,11 @@ void Parser::ParseLexedMethodDeclaration<br>
"ParseAssignmentExpression went over the default arg tokens!");<br>
// There could be leftover tokens (e.g. because of an error).<br>
// Skip through until we reach the original token position.<br>
- while (Tok.getLocation() != origLoc && Tok.isNot(tok::eof))<br>
+ while (Tok.getLocation() != origLoc) {<br>
+ if (Tok.is(tok::eof) && Tok.getEofData() != LM.DefaultArgs[I].Param)<br>
+ break;<br>
ConsumeAnyToken();<br>
+ }<br>
<br>
delete Toks;<br>
LM.DefaultArgs[I].Toks = nullptr;<br>
@@ -652,7 +657,6 @@ bool Parser::ConsumeAndStoreUntil(tok::T<br>
<br>
switch (Tok.getKind()) {<br>
case tok::eof:<br>
- case tok::cxx_defaultarg_end:<br>
case tok::annot_module_begin:<br>
case tok::annot_module_end:<br>
case tok::annot_module_include:<br>
<br>
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=225619&r1=225618&r2=225619&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=225619&r1=225618&r2=225619&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)<br>
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Sun Jan 11 23:17:40 2015<br>
@@ -5631,8 +5631,9 @@ void Parser::ParseParameterDeclarationCl<br>
// stop when we parse it later on.<br>
Token DefArgEnd;<br>
DefArgEnd.startToken();<br>
- DefArgEnd.setKind(tok::cxx_defaultarg_end);<br>
+ DefArgEnd.setKind(tok::eof);<br>
DefArgEnd.setLocation(Tok.getLocation());<br>
+ DefArgEnd.setEofData(Param);<br>
DefArgToks->push_back(DefArgEnd);<br>
Actions.ActOnParamUnparsedDefaultArgument(Param, EqualLoc,<br>
(*DefArgToks)[1].getLocation());<br>
<br>
Modified: cfe/trunk/lib/Parse/Parser.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=225619&r1=225618&r2=225619&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=225619&r1=225618&r2=225619&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Parse/Parser.cpp (original)<br>
+++ cfe/trunk/lib/Parse/Parser.cpp Sun Jan 11 23:17:40 2015<br>
@@ -262,10 +262,6 @@ bool Parser::SkipUntil(ArrayRef<tok::Tok<br>
// Ran out of tokens.<br>
return false;<br>
<br>
- case tok::cxx_defaultarg_end:<br>
- // It's never desirable to consume the 'end-of-default-argument' token.<br>
- return false;<br>
-<br>
case tok::annot_pragma_openmp_end:<br>
// Stop before an OpenMP pragma boundary.<br>
case tok::annot_module_begin:<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>