aboutsummaryrefslogtreecommitdiff
path: root/unittests
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
commit9fdc00a237fe19b892f22780321ddfd1a3691d61 (patch)
tree0a9bbb21f6f5324cc394d90e85600f86ca8a35ef /unittests
parent03852c8717b45ece934f7740a100de526a734641 (diff)
downloadclang-9fdc00a237fe19b892f22780321ddfd1a3691d61.tar.gz
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178261 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Format/FormatTest.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 7fbb9f3ac4..83c7a2adbf 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/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"