<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 10, 2014 at 7:37 AM, Alp Toker <span dir="ltr"><<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: alp<br>
Date: Fri Jan 10 08:37:02 2014<br>
New Revision: 198942<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=198942&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=198942&view=rev</a><br>
Log:<br>
Remove unexpected code completion handling from ConsumeToken()<br>
<br>
With this change tok::code_completion is finally handled exclusively as a<br>
special token kind like other tokens that need special treatment.<br>
<br>
All callers have been updated to use the specific token consumption methods and<br>
the parser has a clear idea the current token isn't special by the time<br>
ConsumeToken() gets called, so this has been unreachable for some time.<br>
<br>
ConsumeAnyToken() behaviour is unchanged and will continue to support<br>
unexpected code completion as part of the special token path.<br>
<br>
This survived an amount of fuzzing and validation, but please ping the list if<br>
you hit a code path that previously relied on the old unexpected handler and<br>
now asserts.<br>
<br>
Modified:<br>
    cfe/trunk/include/clang/Parse/Parser.h<br>
<br>
Modified: cfe/trunk/include/clang/Parse/Parser.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=198942&r1=198941&r2=198942&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=198942&r1=198941&r2=198942&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/Parse/Parser.h (original)<br>
+++ cfe/trunk/include/clang/Parse/Parser.h Fri Jan 10 08:37:02 2014<br>
@@ -273,16 +273,12 @@ public:<br>
   bool ParseTopLevelDecl(DeclGroupPtrTy &Result);<br>
<br>
   /// ConsumeToken - Consume the current 'peek token' and lex the next one.<br>
-  /// This does not work with all kinds of tokens: strings and specific other<br>
-  /// tokens must be consumed with custom methods below.  This returns the<br>
-  /// location of the consumed token.<br>
+  /// This does not work with special tokens: string literals, code completion<br>
+  /// and balanced tokens must be handled using the specific consume methods.<br>
+  /// Returns the location of the consumed token.<br>
   SourceLocation ConsumeToken() {<br>
     assert(!isTokenSpecial() &&<br>
            "Should consume special tokens with Consume*Token");<br>
-<br>
-    if (LLVM_UNLIKELY(Tok.is(tok::code_completion)))<br>
-      return handleUnexpectedCodeCompletionToken();<br></blockquote><div><br></div><div>Is there some central place where we can mark tok::code_completion as unlikely?</div><div><br></div><div>-- Sean Silva</div><div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-<br>
     PrevTokLocation = Tok.getLocation();<br>
     PP.Lex(Tok);<br>
     return PrevTokLocation;<br>
@@ -329,7 +325,7 @@ private:<br>
   /// isTokenSpecial - True if this token requires special consumption methods.<br>
   bool isTokenSpecial() const {<br>
     return isTokenStringLiteral() || isTokenParen() || isTokenBracket() ||<br>
-           isTokenBrace();<br>
+           isTokenBrace() || Tok.is(tok::code_completion);<br>
   }<br>
<br>
   /// \brief Returns true if the current token is '=' or is a type of '='.<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></div>