r181191 - Don't break comments after includes.
Daniel Jasper
djasper at google.com
Mon May 6 03:24:52 PDT 2013
Author: djasper
Date: Mon May 6 05:24:51 2013
New Revision: 181191
URL: http://llvm.org/viewvc/llvm-project?rev=181191&view=rev
Log:
Don't break comments after includes.
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).
Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=181191&r1=181190&r2=181191&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon May 6 05:24:51 2013
@@ -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;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=181191&r1=181190&r2=181191&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon May 6 05:24:51 2013
@@ -2763,6 +2763,7 @@ TEST_F(FormatTest, HandlesIncludeDirecti
"#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));
More information about the cfe-commits
mailing list