Index: lib/Lex/PPCaching.cpp =================================================================== --- lib/Lex/PPCaching.cpp +++ lib/Lex/PPCaching.cpp @@ -97,8 +97,19 @@ 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].getLastLoc() == Tok.getAnnotationEndLoc() - && "The annotation should be until the most recent cached token"); + + // The annotation should be until the most recent cached token. Since + // `Tok` length could be bigger than one (e.g. greatergreater '>>'), account + // for that cases before checking the assertion. + Token CachedLastTok = CachedTokens[CachedLexPos - 1]; + unsigned CachedLastTokLoc = CachedLastTok.getLastLoc().getRawEncoding(); + unsigned TokAnnEndLoc = Tok.getAnnotationEndLoc().getRawEncoding(); + if (CachedLastTokLoc != TokAnnEndLoc && !CachedLastTok.isAnnotation()) + CachedLastTokLoc += CachedLastTok.getLength() - 1; + (void)CachedLastTokLoc; + (void)TokAnnEndLoc; + assert(CachedLastTokLoc == TokAnnEndLoc && + "The annotation should be until the most recent cached token"); // Start from the end of the cached tokens list and look for the token // that is the beginning of the annotation token. Index: test/Parser/objcxx11-protocol-in-template.mm =================================================================== --- test/Parser/objcxx11-protocol-in-template.mm +++ test/Parser/objcxx11-protocol-in-template.mm @@ -8,3 +8,11 @@ vector> v; vector>> v2; + +@protocol PA; +@protocol PB; + +@class NSArray; +typedef int some_t; + +id FA(NSArray> *h, some_t group);