Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/Format/TokenAnnotator.cpp
Show First 20 Lines • Show All 2,275 Lines • ▼ Show 20 Lines | for (; Next; Next = Next->Next) { | ||||
continue; | continue; | ||||
} | } | ||||
if ((Next->isSimpleTypeSpecifier() || Next->is(tok::identifier)) && | if ((Next->isSimpleTypeSpecifier() || Next->is(tok::identifier)) && | ||||
Next->Next && Next->Next->isOneOf(tok::star, tok::amp, tok::ampamp)) { | Next->Next && Next->Next->isOneOf(tok::star, tok::amp, tok::ampamp)) { | ||||
// For operator void*(), operator char*(), operator Foo*(). | // For operator void*(), operator char*(), operator Foo*(). | ||||
Next = Next->Next; | Next = Next->Next; | ||||
continue; | continue; | ||||
} | } | ||||
if (Next->is(TT_TemplateOpener) && Next->MatchingParen) { | |||||
Next = Next->MatchingParen; | |||||
continue; | |||||
} | |||||
break; | break; | ||||
} | } | ||||
return nullptr; | return nullptr; | ||||
}; | }; | ||||
// Find parentheses of parameter list. | // Find parentheses of parameter list. | ||||
const FormatToken *Next = Current.Next; | const FormatToken *Next = Current.Next; | ||||
▲ Show 20 Lines • Show All 513 Lines • ▼ Show 20 Lines | return Right.Tok.isLiteral() || Right.is(TT_BlockComment) || | ||||
tok::l_paren) && | tok::l_paren) && | ||||
(Style.PointerAlignment != FormatStyle::PAS_Right && | (Style.PointerAlignment != FormatStyle::PAS_Right && | ||||
!Line.IsMultiVariableDeclStmt) && | !Line.IsMultiVariableDeclStmt) && | ||||
Left.Previous && | Left.Previous && | ||||
!Left.Previous->isOneOf(tok::l_paren, tok::coloncolon, | !Left.Previous->isOneOf(tok::l_paren, tok::coloncolon, | ||||
tok::l_square)); | tok::l_square)); | ||||
if (Right.is(tok::star) && Left.is(tok::l_paren)) | if (Right.is(tok::star) && Left.is(tok::l_paren)) | ||||
return false; | return false; | ||||
if (Right.is(tok::star) && Left.is(tok::star)) | |||||
return false; | |||||
if (Right.isOneOf(tok::star, tok::amp, tok::ampamp)) { | if (Right.isOneOf(tok::star, tok::amp, tok::ampamp)) { | ||||
const FormatToken *Previous = &Left; | const FormatToken *Previous = &Left; | ||||
MyDeveloperDay: I'm not happy about this it feels way too general. | |||||
while (Previous && !Previous->is(tok::kw_operator)) { | while (Previous && !Previous->is(tok::kw_operator)) { | ||||
if (Previous->is(tok::identifier) || Previous->isSimpleTypeSpecifier()) { | if (Previous->is(tok::identifier) || Previous->isSimpleTypeSpecifier()) { | ||||
Previous = Previous->getPreviousNonComment(); | Previous = Previous->getPreviousNonComment(); | ||||
continue; | continue; | ||||
} | } | ||||
if (Previous->is(TT_TemplateCloser) && Previous->MatchingParen) { | if (Previous->is(TT_TemplateCloser) && Previous->MatchingParen) { | ||||
Previous = Previous->MatchingParen->getPreviousNonComment(); | Previous = Previous->MatchingParen->getPreviousNonComment(); | ||||
continue; | continue; | ||||
▲ Show 20 Lines • Show All 1,145 Lines • Show Last 20 Lines |
I'm not happy about this it feels way too general.