summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-10-11 19:45:02 +0000
committerDaniel Jasper <djasper@google.com>2013-10-11 19:45:02 +0000
commit877615ccfdaadc154420dcc5a2939c56bf5fa4aa (patch)
tree880f137cbcf974224a3f0727b7f74e0fafdbe58e /clang/unittests/Format/FormatTest.cpp
parent8c46baca65347ec1334bde704a15242e2738d937 (diff)
downloadbcm5719-llvm-877615ccfdaadc154420dcc5a2939c56bf5fa4aa.tar.gz
bcm5719-llvm-877615ccfdaadc154420dcc5a2939c56bf5fa4aa.zip
clang-format: Don't remove 'unknown' tokens.
In certain macros or incorrect string literals, the token stream can contain 'unknown' tokens, e.g. a single backslash or a set of empty ticks. clang-format simply treated them as whitespace and removed them prior to this patch. This fixes llvm.org/PR17215 llvm-svn: 192490
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 c77616c96b4..59596bc5439 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -1890,6 +1890,16 @@ TEST_F(FormatTest, EndOfFileEndsPPDirective) {
EXPECT_EQ("#define A B", format("# \\\n define \\\n A \\\n B"));
}
+TEST_F(FormatTest, DoesntRemoveUnknownTokens) {
+ verifyFormat("#define A \\x20");
+ verifyFormat("#define A \\ x20");
+ EXPECT_EQ("#define A \\ x20", format("#define A \\ x20"));
+ verifyFormat("#define A ''");
+ verifyFormat("#define A ''qqq");
+ verifyFormat("#define A `qqq");
+ verifyFormat("f(\"aaaa, bbbb, \"\\\"ccccc\\\"\");");
+}
+
TEST_F(FormatTest, IndentsPPDirectiveInReducedSpace) {
verifyFormat("#define A(BB)", getLLVMStyleWithColumns(13));
verifyFormat("#define A( \\\n BB)", getLLVMStyleWithColumns(12));
OpenPOWER on IntegriCloud