Skip to content

Commit 5a5077b

Browse files
committed
Use TT_FunctionDeclarationLParen
1 parent e367b78 commit 5a5077b

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

clang/lib/Format/ContinuationIndenter.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -803,13 +803,6 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
803803
return !Tok.Previous->isOneOf(TT_CastRParen, tok::kw_for, tok::kw_while,
804804
tok::kw_switch);
805805
};
806-
// Detecting functions is brittle. It would be better if we could annotate
807-
// the LParen type of functions/calls.
808-
auto IsFunctionDeclParen = [&](const FormatToken &Tok) {
809-
return Tok.is(tok::l_paren) && Tok.Previous &&
810-
(Tok.Previous->is(TT_FunctionDeclarationName) ||
811-
Tok.endsSequence(TT_FunctionDeclarationName, tok::coloncolon));
812-
};
813806
auto IsLambdaParameterList = [](const FormatToken *Tok) {
814807
// adapted from TokenAnnotator.cpp:isLambdaParameterList()
815808
// Skip <...> if present.
@@ -846,10 +839,11 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
846839
if (Tok.FakeLParens.size() > 0 && Tok.FakeLParens.back() > prec::Unknown)
847840
return true;
848841
if (Previous &&
849-
(IsFunctionDeclParen(*Previous) || IsFunctionCallParen(*Previous) ||
850-
IsLambdaParameterList(Previous))) {
842+
(Previous->is(TT_FunctionDeclarationLParen) ||
843+
IsFunctionCallParen(*Previous) || IsLambdaParameterList(Previous))) {
851844
return !IsOpeningBracket(Tok) && Next && !Next->isMemberAccess() &&
852-
!IsInTemplateString(Tok) && !IsFunctionDeclParen(*Next) &&
845+
!IsInTemplateString(Tok) &&
846+
!Next->is(TT_FunctionDeclarationLParen) &&
853847
!IsFunctionCallParen(*Next);
854848
}
855849
return false;

clang/unittests/Format/FormatTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9352,7 +9352,7 @@ TEST_F(FormatTest, AlignsAfterOpenBracket) {
93529352
") const noexcept -> std::vector<of_very_long_type>;",
93539353
Style);
93549354
verifyFormat(
9355-
"aaaaaaaaaaaaaaaaaaa(\n"
9355+
"x = aaaaaaaaaaaaaaa(\n"
93569356
" \"a aaaaaaa aaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaa\"\n"
93579357
");",
93589358
Style);

0 commit comments

Comments
 (0)