[cfe-commits] r99973 - /cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp

Argiris Kirtzidis akyrtzi at gmail.com
Tue Mar 30 17:38:09 PDT 2010


Author: akirtzidis
Date: Tue Mar 30 19:38:09 2010
New Revision: 99973

URL: http://llvm.org/viewvc/llvm-project?rev=99973&view=rev
Log:
Add a few asserts to be on the safe side.

Modified:
    cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp

Modified: cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp?rev=99973&r1=99972&r2=99973&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp (original)
+++ cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp Tue Mar 30 19:38:09 2010
@@ -189,6 +189,9 @@
     if (LM.TemplateScope)
       Actions.ActOnReenterTemplateScope(CurScope, LM.D);
 
+    // Save the current token position.
+    SourceLocation origLoc = Tok.getLocation();
+
     assert(!LM.Toks.empty() && "Empty body!");
     // Append the current token at the end of the new token stream so that it
     // doesn't get lost.
@@ -207,6 +210,11 @@
 
     if (Tok.is(tok::kw_try)) {
       ParseFunctionTryBlock(LM.D);
+      assert(!PP.getSourceManager().isBeforeInTranslationUnit(origLoc,
+                                                           Tok.getLocation()) &&
+             "ParseFunctionTryBlock went over the cached tokens!");
+      assert(Tok.getLocation() == origLoc &&
+             "ParseFunctionTryBlock left tokens in the token stream!");
       continue;
     }
     if (Tok.is(tok::colon))
@@ -216,6 +224,11 @@
 
     // FIXME: What if ParseConstructorInitializer doesn't leave us with a '{'??
     ParseFunctionStatementBody(LM.D);
+    assert(!PP.getSourceManager().isBeforeInTranslationUnit(origLoc,
+                                                           Tok.getLocation()) &&
+           "We consumed more than the cached tokens!");
+    assert(Tok.getLocation() == origLoc &&
+           "Tokens were left in the token stream!");
   }
 
   for (unsigned I = 0, N = Class.NestedClasses.size(); I != N; ++I)





More information about the cfe-commits mailing list