aboutsummaryrefslogtreecommitdiff
path: root/clang/lib
diff options
context:
space:
mode:
authorOwen Pan <owenpiano@gmail.com>2024-12-18 12:42:26 -0800
committerGitHub <noreply@github.com>2024-12-18 12:42:26 -0800
commitf03bf8c45f430c4fbf9f3a60c67bf2e69459d7a5 (patch)
treea3d4d659d815e4bb1a029c9d7257f99d03ad3aab /clang/lib
parent9b3d85f0f43a9337223f8d69bbe71d5b4f41fd33 (diff)
downloadllvm-f03bf8c45f430c4fbf9f3a60c67bf2e69459d7a5.zip
llvm-f03bf8c45f430c4fbf9f3a60c67bf2e69459d7a5.tar.gz
llvm-f03bf8c45f430c4fbf9f3a60c67bf2e69459d7a5.tar.bz2
[clang-format] Don't change breaking before CtorInitializerColon (#119522)
Don't change breaking before CtorInitializerColon with `ColumnLimit: 0`. Fixes #119519.
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp5
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp3
2 files changed, 4 insertions, 4 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 9ffdc04..554b55f 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -461,9 +461,8 @@ bool ContinuationIndenter::mustBreak(const LineState &State) {
getColumnLimit(State) ||
CurrentState.BreakBeforeParameter) &&
(!Current.isTrailingComment() || Current.NewlinesBefore > 0) &&
- (Style.AllowShortFunctionsOnASingleLine != FormatStyle::SFS_All ||
- Style.BreakConstructorInitializers != FormatStyle::BCIS_BeforeColon ||
- Style.ColumnLimit != 0)) {
+ (Style.BreakConstructorInitializers != FormatStyle::BCIS_BeforeColon ||
+ Style.ColumnLimit > 0 || Current.NewlinesBefore > 0)) {
return true;
}
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 05c86db..a1b551a 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -492,7 +492,8 @@ private:
ProbablyFunctionType && CurrentToken->Next &&
(CurrentToken->Next->is(tok::l_paren) ||
(CurrentToken->Next->is(tok::l_square) &&
- Line.MustBeDeclaration))) {
+ (Line.MustBeDeclaration ||
+ PrevNonComment->isTypeName(LangOpts))))) {
OpeningParen.setType(OpeningParen.Next->is(tok::caret)
? TT_ObjCBlockLParen
: TT_FunctionTypeLParen);