@@ -149,36 +149,36 @@ class AnnotatingParser {
149149 }
150150
151151 bool parseAngle () {
152- if (!CurrentToken || !CurrentToken->Previous )
152+ if (!CurrentToken)
153+ return false ;
154+
155+ auto *Left = CurrentToken->Previous ; // The '<'.
156+ if (!Left)
153157 return false ;
154- if (NonTemplateLess.count (CurrentToken->Previous ) > 0 )
158+
159+ if (NonTemplateLess.count (Left) > 0 )
155160 return false ;
156161
157- if (const auto &Previous = *CurrentToken->Previous ; // The '<'.
158- Previous.Previous ) {
159- if (Previous.Previous ->Tok .isLiteral ())
162+ const auto *BeforeLess = Left->Previous ;
163+
164+ if (BeforeLess) {
165+ if (BeforeLess->Tok .isLiteral ())
160166 return false ;
161- if (Previous. Previous ->is (tok::r_brace))
167+ if (BeforeLess ->is (tok::r_brace))
162168 return false ;
163- if (Previous.Previous ->is (tok::r_paren) && Contexts.size () > 1 &&
164- (!Previous.Previous ->MatchingParen ||
165- Previous.Previous ->MatchingParen ->isNot (
166- TT_OverloadedOperatorLParen))) {
169+ if (BeforeLess->is (tok::r_paren) && Contexts.size () > 1 &&
170+ !(BeforeLess->MatchingParen &&
171+ BeforeLess->MatchingParen ->is (TT_OverloadedOperatorLParen))) {
167172 return false ;
168173 }
169- if (Previous.Previous ->is (tok::kw_operator) &&
170- CurrentToken->is (tok::l_paren)) {
174+ if (BeforeLess->is (tok::kw_operator) && CurrentToken->is (tok::l_paren))
171175 return false ;
172- }
173176 }
174177
175- FormatToken *Left = CurrentToken->Previous ;
176178 Left->ParentBracket = Contexts.back ().ContextKind ;
177179 ScopedContextCreator ContextCreator (*this , tok::less, 12 );
178180 Contexts.back ().IsExpression = false ;
179181
180- const auto *BeforeLess = Left->Previous ;
181-
182182 // If there's a template keyword before the opening angle bracket, this is a
183183 // template parameter, not an argument.
184184 if (BeforeLess && BeforeLess->isNot (tok::kw_template))
@@ -229,6 +229,10 @@ class AnnotatingParser {
229229 next ();
230230 return true ;
231231 }
232+ if (BeforeLess && BeforeLess->is (TT_TemplateName)) {
233+ next ();
234+ continue ;
235+ }
232236 if (CurrentToken->is (tok::question) &&
233237 Style.Language == FormatStyle::LK_Java) {
234238 next ();
0 commit comments