summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2013-01-18 14:04:34 +0000
committerManuel Klimek <klimek@google.com>2013-01-18 14:04:34 +0000
commitd3b92fa61edb1da297697dd64108a4d8487152f2 (patch)
treea176e5c2c72c8d0d783aa1d5eb714db96d1a6503 /clang/unittests/Format/FormatTest.cpp
parent8b517f1076b3df8781d895a8cd391fdeffd69337 (diff)
downloadbcm5719-llvm-d3b92fa61edb1da297697dd64108a4d8487152f2.tar.gz
bcm5719-llvm-d3b92fa61edb1da297697dd64108a4d8487152f2.zip
Fixes problems with line merging in the face of preprocessor directives.
This patch prepares being able to test for and fix more problems (see FIXME in the test for example). Previously we would output unwrapped lines for preprocessor directives at the point where we also parsed the hash token. Since often projections only terminate (and thus output their own unwrapped line) after peeking at the next token, this would lead to the formatter seeing the preprocessor directives out-of-order (slightly earlier). To be able to correctly identify lines to merge, the formatter needs a well-defined order of unwrapped lines, which this patch introduces. llvm-svn: 172819
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r--clang/unittests/Format/FormatTest.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 806707cb4cd..6b77868776a 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -1537,6 +1537,16 @@ TEST_F(FormatTest, DoNotInterfereWithErrorAndWarning) {
EXPECT_EQ("#warning 1", format(" # warning 1"));
}
+TEST_F(FormatTest, MergeHandlingInTheFaceOfPreprocessorDirectives) {
+ FormatStyle AllowsMergedIf = getGoogleStyle();
+ AllowsMergedIf.AllowShortIfStatementsOnASingleLine = true;
+ verifyFormat("void f() { f(); }\n#error E", AllowsMergedIf);
+ verifyFormat("if (true) return 42;\n#error E", AllowsMergedIf);
+
+ // FIXME:
+ // verifyFormat("if (true)\n#error E\n return 42;", AllowsMergedIf);
+}
+
// FIXME: This breaks the order of the unwrapped lines:
// TEST_F(FormatTest, OrderUnwrappedLines) {
// verifyFormat("{\n"
OpenPOWER on IntegriCloud