diff options
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.cpp')
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 94de217eb8e..abd9be6d223 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -493,7 +493,8 @@ private: if (Line.MustBeDeclaration && Contexts.size() == 1 && !Contexts.back().IsExpression && Line.First->isNot(TT_ObjCProperty) && (!Tok->Previous || - !Tok->Previous->isOneOf(tok::kw_decltype, TT_LeadingJavaAnnotation))) + !Tok->Previous->isOneOf(tok::kw_decltype, TT_LeadingJavaAnnotation, + TT_FunctionAnnotation))) Line.MightBeFunctionDecl = true; break; case tok::l_square: @@ -915,9 +916,16 @@ private: } else { Current.Type = TT_LineComment; } + } else if (Current.is(tok::l_paren) && Current.Previous && + Current.Previous->is(TT_FunctionAnnotation)) { + Current.Type = TT_FunctionAnnotation; } else if (Current.is(tok::r_paren)) { if (rParenEndsCast(Current)) Current.Type = TT_CastRParen; + if (Current.MatchingParen && + Current.MatchingParen->is(TT_FunctionAnnotation) && Current.Next && + !Current.Next->isOneOf(tok::semi, tok::colon)) + Current.Type = TT_FunctionAnnotation; } else if (Current.is(tok::at) && Current.Next) { if (Current.Next->isStringLiteral()) { Current.Type = TT_ObjCStringLiteral; @@ -968,6 +976,11 @@ private: TT_LeadingJavaAnnotation)) { Current.Type = Current.Previous->Type; } + } else if (Current.is(tok::identifier) && + Current.TokenText == Current.TokenText.upper() && + (!Current.Previous || + Current.Previous->ClosesTemplateDeclaration)) { + Current.Type = TT_FunctionAnnotation; } } |