diff options
author | Owen Pan <owenpiano@gmail.com> | 2023-11-27 13:01:16 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-27 13:01:16 -0800 |
commit | 39faf13dde5502cdba7aff1b967c51cd0a93bb71 (patch) | |
tree | 77b3d3142be886a78d2569f2739f1df82ae1f6c6 /clang/lib | |
parent | 9e8691962626e62382eb31da6fea49ddbb559750 (diff) | |
download | llvm-39faf13dde5502cdba7aff1b967c51cd0a93bb71.zip llvm-39faf13dde5502cdba7aff1b967c51cd0a93bb71.tar.gz llvm-39faf13dde5502cdba7aff1b967c51cd0a93bb71.tar.bz2 |
[clang-format] Add BreakAdjacentStringLiterals option (#73432)
Closes #70451.
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Format/Format.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 9 |
2 files changed, 7 insertions, 5 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index e1abcac..db0cb8a 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -965,6 +965,8 @@ template <> struct MappingTraits<FormatStyle> { IO.mapOptional("BracedInitializerIndentWidth", Style.BracedInitializerIndentWidth); IO.mapOptional("BraceWrapping", Style.BraceWrapping); + IO.mapOptional("BreakAdjacentStringLiterals", + Style.BreakAdjacentStringLiterals); IO.mapOptional("BreakAfterAttributes", Style.BreakAfterAttributes); IO.mapOptional("BreakAfterJavaFieldAnnotations", Style.BreakAfterJavaFieldAnnotations); @@ -1476,6 +1478,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) { /*SplitEmptyFunction=*/true, /*SplitEmptyRecord=*/true, /*SplitEmptyNamespace=*/true}; + LLVMStyle.BreakAdjacentStringLiterals = true; LLVMStyle.BreakAfterAttributes = FormatStyle::ABS_Leave; LLVMStyle.BreakAfterJavaFieldAnnotations = false; LLVMStyle.BreakArrays = true; diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 6ae83de..4a684e2 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -5077,11 +5077,10 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line, // it is hard to identify them in UnwrappedLineParser. if (!Keywords.isVerilogBegin(Right) && Keywords.isVerilogEndOfLabel(Left)) return true; - } else if (Style.Language == FormatStyle::LK_Cpp || - Style.Language == FormatStyle::LK_ObjC || - Style.Language == FormatStyle::LK_Proto || - Style.Language == FormatStyle::LK_TableGen || - Style.Language == FormatStyle::LK_TextProto) { + } else if (Style.BreakAdjacentStringLiterals && + (Style.isCpp() || Style.isProto() || + Style.Language == FormatStyle::LK_TableGen || + Style.Language == FormatStyle::LK_TextProto)) { if (Left.isStringLiteral() && Right.isStringLiteral()) return true; } |