aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2010-02-08 19:35:18 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2010-02-08 19:35:18 +0000
commit39d67117f896c6e2faa727671ef64b3c04b0e3fe (patch)
treef4b36f79c196936db5b10bfaf1b65090ad3252ae
parent4c72d3ec68b88868a75b3e6bbe5520dcefe86a95 (diff)
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95555 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Lex/Token.h4
-rw-r--r--lib/Lex/PPCaching.cpp2
-rw-r--r--lib/Parse/ParseTemplate.cpp2
-rw-r--r--lib/Parse/Parser.cpp3
4 files changed, 8 insertions, 3 deletions
diff --git a/include/clang/Lex/Token.h b/include/clang/Lex/Token.h
index 604eae1027..b5dde9a700 100644
--- a/include/clang/Lex/Token.h
+++ b/include/clang/Lex/Token.h
@@ -124,6 +124,10 @@ public:
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 {
diff --git a/lib/Lex/PPCaching.cpp b/lib/Lex/PPCaching.cpp
index 7c3780ffc0..6aeb6fa3a2 100644
--- a/lib/Lex/PPCaching.cpp
+++ b/lib/Lex/PPCaching.cpp
@@ -91,7 +91,7 @@ const Token &Preprocessor::PeekAhead(unsigned N) {
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
diff --git a/lib/Parse/ParseTemplate.cpp b/lib/Parse/ParseTemplate.cpp
index 797c1dfe3e..12f26bfcb9 100644
--- a/lib/Parse/ParseTemplate.cpp
+++ b/lib/Parse/ParseTemplate.cpp
@@ -836,7 +836,7 @@ void Parser::AnnotateTemplateIdTokenAsType(const CXXScopeSpec *SS) {
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.
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp
index 2558b66758..e5bed3096d 100644
--- a/lib/Parse/Parser.cpp
+++ b/lib/Parse/Parser.cpp
@@ -944,9 +944,10 @@ bool Parser::TryAnnotateTypeOrScopeToken(bool EnteringContext) {
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;