]> granicus.if.org Git - clang/commitdiff
Never break inside something that was a preprocessor directive.
authorManuel Klimek <klimek@google.com>
Thu, 31 Jan 2013 15:58:48 +0000 (15:58 +0000)
committerManuel Klimek <klimek@google.com>
Thu, 31 Jan 2013 15:58:48 +0000 (15:58 +0000)
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

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

index e724c69eb8281124b23f3c23c80ff933063cb22f..19bca8d860ddc7d5ab68505ed29444e4153d450a 100644 (file)
@@ -215,7 +215,7 @@ void UnwrappedLineParser::parsePPDirective() {
   nextToken();
 
   if (FormatTok.Tok.getIdentifierInfo() == NULL) {
-    addUnwrappedLine();
+    parsePPUnknown();
     return;
   }
 
index 5ffd3518891c3d181016e790454015f024d74935..bffbbf53316b5f56d83eebddad28baa287bc2fe8 100644 (file)
@@ -714,8 +714,10 @@ TEST_F(FormatTest, DoesNotBreakPureVirtualFunctionDefinition) {
                "                   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;");
 }