Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/Format/TokenAnnotator.cpp
Show First 20 Lines • Show All 2,470 Lines • ▼ Show 20 Lines | static bool isFunctionDeclarationName(const FormatToken &Current, | ||||
if (Line.Last->is(tok::l_brace)) | if (Line.Last->is(tok::l_brace)) | ||||
return true; | return true; | ||||
if (Next->Next == Next->MatchingParen) | if (Next->Next == Next->MatchingParen) | ||||
return true; // Empty parentheses. | return true; // Empty parentheses. | ||||
// If there is an &/&& after the r_paren, this is likely a function. | // If there is an &/&& after the r_paren, this is likely a function. | ||||
if (Next->MatchingParen->Next && | if (Next->MatchingParen->Next && | ||||
Next->MatchingParen->Next->is(TT_PointerOrReference)) | Next->MatchingParen->Next->is(TT_PointerOrReference)) | ||||
return true; | return true; | ||||
// Check for K&R C function definitions, e.g.: | |||||
// int f(i) | |||||
// { | |||||
// return i + 1; | |||||
// } | |||||
if (Next->Next && Next->Next->is(tok::identifier) && | |||||
!(Next->MatchingParen->Next && Next->MatchingParen->Next->is(tok::semi))) | |||||
return true; | |||||
for (const FormatToken *Tok = Next->Next; Tok && Tok != Next->MatchingParen; | for (const FormatToken *Tok = Next->Next; Tok && Tok != Next->MatchingParen; | ||||
Tok = Tok->Next) { | Tok = Tok->Next) { | ||||
if (Tok->is(TT_TypeDeclarationParen)) | if (Tok->is(TT_TypeDeclarationParen)) | ||||
return true; | return true; | ||||
if (Tok->isOneOf(tok::l_paren, TT_TemplateOpener) && Tok->MatchingParen) { | if (Tok->isOneOf(tok::l_paren, TT_TemplateOpener) && Tok->MatchingParen) { | ||||
Tok = Tok->MatchingParen; | Tok = Tok->MatchingParen; | ||||
continue; | continue; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,797 Lines • Show Last 20 Lines |