]> granicus.if.org Git - clang/commitdiff
clang-format: Fix import statements with ColumnLimit: 0
authorDaniel Jasper <djasper@google.com>
Mon, 5 May 2014 08:08:07 +0000 (08:08 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 5 May 2014 08:08:07 +0000 (08:08 +0000)
These used to interact badly with AlwaysBreakBeforeMultilineStrings.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207955 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/ContinuationIndenter.cpp
unittests/Format/FormatTest.cpp

index e3088a0f945dcef1ae6ff79de75f226f4d05c41f..f18984bb15bd6a19667f8f404dca14584fbf02ec 100644 (file)
@@ -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
index 62534c6fbaec9aa0ce347f4f88111dd35341ca2a..009df106e4d3b437d861bcdf314bc72784c25bec 100644 (file)
@@ -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);
 }
 
 //===----------------------------------------------------------------------===//