summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2013-01-15 15:50:27 +0000
committerManuel Klimek <klimek@google.com>2013-01-15 15:50:27 +0000
commit99c7baa3cfdfa73a683b65d371162cfa766ae8c0 (patch)
tree823c8b879cb9d0b199d31f7976f8cbe18842714f /clang/unittests/Format/FormatTest.cpp
parentf71e7ad3cc39d025a8f082364a9fbf62bca2157b (diff)
downloadbcm5719-llvm-99c7baa3cfdfa73a683b65d371162cfa766ae8c0.tar.gz
bcm5719-llvm-99c7baa3cfdfa73a683b65d371162cfa766ae8c0.zip
Fix formatting of preprocessor directives (incluces, warnings & errors).
Treat tokens inside <> for includes and everything from the second token of a warning / error on as an implicit string literal, e.g. do not change its whitespace at all. Now correctly formats: #include < path with space > #error Leave all white!!!!! space* alone! Note that for #error and #warning we still format the space up to the first token of the text, so: # error Text will become #error Text llvm-svn: 172536
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r--clang/unittests/Format/FormatTest.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index c6f1c8e4ec7..eb00d017ff3 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -1184,7 +1184,8 @@ TEST_F(FormatTest, HandlesIncludeDirectives) {
"#include \"a/b/string\"\n"
"#include \"string.h\"\n"
"#include \"string.h\"\n"
- "#include <a-a>");
+ "#include <a-a>\n"
+ "#include < path with space >\n");
verifyFormat("#import <string>");
verifyFormat("#import <a/b/c.h>");
@@ -1334,6 +1335,13 @@ TEST_F(FormatTest, UnderstandContextOfRecordTypeKeywords) {
" f();\n");
}
+TEST_F(FormatTest, DoNotInterfereWithErrorAndWarning) {
+ verifyFormat("#error Leave all white!!!!! space* alone!\n");
+ verifyFormat("#warning Leave all white!!!!! space* alone!\n");
+ EXPECT_EQ("#error 1", format(" # error 1"));
+ EXPECT_EQ("#warning 1", format(" # warning 1"));
+}
+
// FIXME: This breaks the order of the unwrapped lines:
// TEST_F(FormatTest, OrderUnwrappedLines) {
// verifyFormat("{\n"
OpenPOWER on IntegriCloud