[cfe-commits] r95555 - in /cfe/trunk: include/clang/Lex/Token.h lib/Lex/PPCaching.cpp lib/Parse/ParseTemplate.cpp lib/Parse/Parser.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Mon Feb 8 11:35:18 PST 2010


Author: cornedbee
Date: Mon Feb  8 13:35:18 2010
New Revision: 95555

URL: http://llvm.org/viewvc/llvm-project?rev=95555&view=rev
Log:
When placing an annotation token over an existing annotation token, make sure that the new token's range extends to the end of the old token. Assert that in AnnotateCachedTokens. Fixes PR6248.

Modified:
    cfe/trunk/include/clang/Lex/Token.h
    cfe/trunk/lib/Lex/PPCaching.cpp
    cfe/trunk/lib/Parse/ParseTemplate.cpp
    cfe/trunk/lib/Parse/Parser.cpp

Modified: cfe/trunk/include/clang/Lex/Token.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Token.h?rev=95555&r1=95554&r2=95555&view=diff

==============================================================================
--- cfe/trunk/include/clang/Lex/Token.h (original)
+++ cfe/trunk/include/clang/Lex/Token.h Mon Feb  8 13:35:18 2010
@@ -124,6 +124,10 @@
     UintData = L.getRawEncoding();
   }
 
+  SourceLocation getLastLoc() const {
+    return isAnnotation() ? getAnnotationEndLoc() : getLocation();
+  }
+
   /// getAnnotationRange - SourceRange of the group of tokens that this
   /// annotation token represents.
   SourceRange getAnnotationRange() const {

Modified: cfe/trunk/lib/Lex/PPCaching.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPCaching.cpp?rev=95555&r1=95554&r2=95555&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/PPCaching.cpp (original)
+++ cfe/trunk/lib/Lex/PPCaching.cpp Mon Feb  8 13:35:18 2010
@@ -91,7 +91,7 @@
 void Preprocessor::AnnotatePreviousCachedTokens(const Token &Tok) {
   assert(Tok.isAnnotation() && "Expected annotation token");
   assert(CachedLexPos != 0 && "Expected to have some cached tokens");
-  assert(CachedTokens[CachedLexPos-1].getLocation() == Tok.getAnnotationEndLoc()
+  assert(CachedTokens[CachedLexPos-1].getLastLoc() == Tok.getAnnotationEndLoc()
          && "The annotation should be until the most recent cached token");
 
   // Start from the end of the cached tokens list and look for the token

Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=95555&r1=95554&r2=95555&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Mon Feb  8 13:35:18 2010
@@ -836,7 +836,7 @@
   Tok.setAnnotationValue(Type.isInvalid()? 0 : Type.get());
   if (SS && SS->isNotEmpty()) // it was a C++ qualified type name.
     Tok.setLocation(SS->getBeginLoc());
-  Tok.setAnnotationEndLoc(TemplateId->TemplateNameLoc);
+  // End location stays the same
 
   // Replace the template-id annotation token, and possible the scope-specifier
   // that precedes it, with the typename annotation token.

Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=95555&r1=95554&r2=95555&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Mon Feb  8 13:35:18 2010
@@ -944,9 +944,10 @@
       return false;
     }
 
+    SourceLocation EndLoc = Tok.getLastLoc();
     Tok.setKind(tok::annot_typename);
     Tok.setAnnotationValue(Ty.isInvalid()? 0 : Ty.get());
-    Tok.setAnnotationEndLoc(Tok.getLocation());
+    Tok.setAnnotationEndLoc(EndLoc);
     Tok.setLocation(TypenameLoc);
     PP.AnnotateCachedTokens(Tok);
     return true;





More information about the cfe-commits mailing list