Properly replace (cxxscope, template-id) annotation tokens with a
single typename annotation token when backtracing. Fixes PR5350.

llvm-svn: 86034
diff --git a/clang/lib/Parse/ParseTemplate.cpp b/clang/lib/Parse/ParseTemplate.cpp
index 045acd8..9957883 100644
--- a/clang/lib/Parse/ParseTemplate.cpp
+++ b/clang/lib/Parse/ParseTemplate.cpp
@@ -809,12 +809,11 @@
   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);
 
-  // We might be backtracking, in which case we need to replace the
-  // template-id annotation token with the type annotation within the
-  // set of cached tokens. That way, we won't try to form the same
-  // class template specialization again.
-  PP.ReplaceLastTokenWithAnnotation(Tok);
+  // Replace the template-id annotation token, and possible the scope-specifier
+  // that precedes it, with the typename annotation token.
+  PP.AnnotateCachedTokens(Tok);
   TemplateId->Destroy();
 }