From 9509f18836479f70467337f64bffabe0dab6179e Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 5 May 2014 08:08:07 +0000 Subject: [PATCH] clang-format: Fix import statements with ColumnLimit: 0 These used to interact badly with AlwaysBreakBeforeMultilineStrings. llvm-svn: 207955 --- clang/lib/Format/ContinuationIndenter.cpp | 2 +- clang/unittests/Format/FormatTest.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index e3088a0f945d..f18984bb15bd 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -1012,7 +1012,7 @@ unsigned ContinuationIndenter::getColumnLimit(const LineState &State) const { bool ContinuationIndenter::nextIsMultilineString(const LineState &State) { const FormatToken &Current = *State.NextToken; - if (!Current.isStringLiteral()) + if (!Current.isStringLiteral() || Current.Type == TT_ImplicitStringLiteral) return false; // We never consider raw string literals "multiline" for the purpose of // AlwaysBreakBeforeMultilineStrings implementation as they are special-cased diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 62534c6fbaec..009df106e4d3 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -4928,6 +4928,11 @@ TEST_F(FormatTest, HandlesIncludeDirectives) { // Protocol buffer definition or missing "#". verifyFormat("import \"aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaa\";", getLLVMStyleWithColumns(30)); + + FormatStyle Style = getLLVMStyle(); + Style.AlwaysBreakBeforeMultilineStrings = true; + Style.ColumnLimit = 0; + verifyFormat("#import \"abc.h\"", Style); } //===----------------------------------------------------------------------===//