summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2013-03-28 18:40:55 +0000
committerAlexander Kornienko <alexfh@google.com>2013-03-28 18:40:55 +0000
commitefd98385c075ac1cb60700132e8f98df10663043 (patch)
tree4ac453ba7f093dfa52238df9bc4b5d03d1112990 /clang/unittests/Format/FormatTest.cpp
parent52d988650035cc57a6ad8aca764c17bec50974f5 (diff)
downloadbcm5719-llvm-efd98385c075ac1cb60700132e8f98df10663043.tar.gz
bcm5719-llvm-efd98385c075ac1cb60700132e8f98df10663043.zip
Fixed handling of comments before preprocessor directives.
Comments before preprocessor directives used to be stored with InPPDirective flag set, which prevented correct comment splitting in this case. Fixed by flushing comments before switching on InPPDirective. Added a new test and fixed one of the existing tests. llvm-svn: 178261
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r--clang/unittests/Format/FormatTest.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 7fbb9f3ac4e..83c7a2adbf2 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -699,6 +699,13 @@ TEST_F(FormatTest, SplitsLongCxxComments) {
"//Don't add leading\n"
"//whitespace",
format("//Don't add leading whitespace", getLLVMStyleWithColumns(20)));
+ EXPECT_EQ("// A comment before\n"
+ "// a macro\n"
+ "// definition\n"
+ "#define a b",
+ format("// A comment before a macro definition\n"
+ "#define a b",
+ getLLVMStyleWithColumns(20)));
}
TEST_F(FormatTest, SplitsLongLinesInComments) {
@@ -1203,13 +1210,13 @@ TEST_F(FormatTest, IndentsPPDirectiveInReducedSpace) {
}
TEST_F(FormatTest, HandlePreprocessorDirectiveContext) {
- EXPECT_EQ("// some comment\n"
+ EXPECT_EQ("// somecomment\n"
"#include \"a.h\"\n"
"#define A( \\\n"
" A, B)\n"
"#include \"b.h\"\n"
"// somecomment\n",
- format(" // some comment\n"
+ format(" // somecomment\n"
" #include \"a.h\"\n"
"#define A(A,\\\n"
" B)\n"
OpenPOWER on IntegriCloud