diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -5001,7 +5001,10 @@ return false; } const FormatToken *Previous = Right.MatchingParen->Previous; - return !(Previous && (Previous->is(tok::kw_for) || Previous->isIf())); + // avoid breaking when there is an opening parens immediately following + // a closing parens, such as in cast operators and indirect function calls + return !((Previous && (Previous->is(tok::kw_for) || Previous->isIf())) || + (Right.Next && Right.Next->is(tok::l_paren))); } // Allow breaking after a trailing annotation, e.g. after a method