r182003 - Don't insert a break into include lines with trailing comments.
Daniel Jasper
djasper at google.com
Thu May 16 05:59:13 PDT 2013
Author: djasper
Date: Thu May 16 07:59:13 2013
New Revision: 182003
URL: http://llvm.org/viewvc/llvm-project?rev=182003&view=rev
Log:
Don't insert a break into include lines with trailing comments.
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=182003&r1=182002&r2=182003&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Thu May 16 07:59:13 2013
@@ -777,7 +777,8 @@ private:
llvm::OwningPtr<BreakableToken> Token;
unsigned StartColumn = State.Column - Current.FormatTok.TokenLength -
UnbreakableTailLength;
- if (Current.is(tok::string_literal)) {
+ if (Current.is(tok::string_literal) &&
+ Current.Type != TT_ImplicitStringLiteral) {
// Only break up default narrow strings.
const char *LiteralData = SourceMgr.getCharacterData(
Current.FormatTok.getStartOfNonWhitespace());
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=182003&r1=182002&r2=182003&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu May 16 07:59:13 2013
@@ -2894,6 +2894,7 @@ TEST_F(FormatTest, HandlesIncludeDirecti
"#include <a-a>\n"
"#include < path with space >\n"
"#include \"abc.h\" // this is included for ABC\n"
+ "#include \"some long include\" // with a comment\n"
"#include \"some very long include paaaaaaaaaaaaaaaaaaaaaaath\"",
getLLVMStyleWithColumns(35));
More information about the cfe-commits
mailing list