From: Daniel Jasper Date: Mon, 5 May 2014 08:08:07 +0000 (+0000) Subject: clang-format: Fix import statements with ColumnLimit: 0 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=df4eadab62feb70d64fe947fed0418d1f9814183;p=clang clang-format: Fix import statements with ColumnLimit: 0 These used to interact badly with AlwaysBreakBeforeMultilineStrings. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207955 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index e3088a0f94..f18984bb15 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/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/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 62534c6fba..009df106e4 100644 --- a/unittests/Format/FormatTest.cpp +++ b/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); } //===----------------------------------------------------------------------===//