]> granicus.if.org Git - clang/commitdiff
Don't break comments after includes.
authorDaniel Jasper <djasper@google.com>
Mon, 6 May 2013 10:24:51 +0000 (10:24 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 6 May 2013 10:24:51 +0000 (10:24 +0000)
LLVM/Clang basically don't use such comments and for Google-style,
include-lines are explicitly exempt from the column limit. Also, for
most cases, where the column limit is violated, the "better" solution
would be to move the comment to before the include, which clang-format
cannot do (yet).

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

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

index d251d4f9e67e77d3a353dd7ad2d4231fd19d278f..68626d29ca06d33bb51a24fffeadb86ce36eae47 100644 (file)
@@ -643,7 +643,9 @@ private:
       if (!DryRun)
         BBC->alignLines(Whitespaces);
       Token.reset(BBC);
-    } else if (Current.Type == TT_LineComment) {
+    } else if (Current.Type == TT_LineComment &&
+               (Current.Parent == NULL ||
+                Current.Parent->Type != TT_ImplicitStringLiteral)) {
       Token.reset(new BreakableLineComment(SourceMgr, Current, StartColumn));
     } else {
       return 0;
index 98e6d47c4f440116654dd0683010ba02d58645af..4c948e89e9807a1bf79db9912d3e03b9825db3ca 100644 (file)
@@ -2763,6 +2763,7 @@ TEST_F(FormatTest, HandlesIncludeDirectives) {
                "#include \"string.h\"\n"
                "#include <a-a>\n"
                "#include < path with space >\n"
+               "#include \"abc.h\" // this is included for ABC\n"
                "#include \"some very long include paaaaaaaaaaaaaaaaaaaaaaath\"",
                getLLVMStyleWithColumns(35));