Never break inside something that was a preprocessor directive.
Just put it in one unwrapped line and let the formatter handle it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174063 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp
index e724c69..19bca8d 100644
--- a/lib/Format/UnwrappedLineParser.cpp
+++ b/lib/Format/UnwrappedLineParser.cpp
@@ -215,7 +215,7 @@
nextToken();
if (FormatTok.Tok.getIdentifierInfo() == NULL) {
- addUnwrappedLine();
+ parsePPUnknown();
return;
}
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 5ffd351..bffbbf5 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -714,8 +714,10 @@
" OwningPtr<FileOutputBuffer> &buffer) = 0;");
}
-TEST_F(FormatTest, BreaksOnHashWhenDirectiveIsInvalid) {
- EXPECT_EQ("#\n;", format("#;"));
+TEST_F(FormatTest, LayoutUnknownPPDirective) {
+ EXPECT_EQ("#123 \"A string literal\"",
+ format(" # 123 \"A string literal\""));
+ EXPECT_EQ("#;", format("#;"));
verifyFormat("#\n;\n;\n;");
}