Fix bug that would lead to joining preprocessor directives.

Before: #include "a.h" #include "b.h"
After:  #include "a.h"
        #include "b.h"
llvm-svn: 172424
This commit is contained in:
Daniel Jasper 2013-01-14 15:52:06 +00:00
parent 39825eaff5
commit 2ab0d01a8e
2 changed files with 8 additions and 7 deletions

View File

@ -1427,7 +1427,8 @@ private:
std::vector<AnnotatedLine>::iterator E,
unsigned Limit) {
AnnotatedLine &Line = *I;
if (!(I + 1)->InPPDirective) return;
if (!(I + 1)->InPPDirective || (I + 1)->First.FormatTok.HasUnescapedNewline)
return;
if (I + 2 != E && (I + 2)->InPPDirective &&
!(I + 2)->First.FormatTok.HasUnescapedNewline)
return;

View File

@ -1133,12 +1133,12 @@ TEST_F(FormatTest, LineStartsWithSpecialCharacter) {
}
TEST_F(FormatTest, HandlesIncludeDirectives) {
verifyFormat("#include <string>");
verifyFormat("#include <a/b/c.h>");
verifyFormat("#include \"a/b/string\"");
verifyFormat("#include \"string.h\"");
verifyFormat("#include \"string.h\"");
verifyFormat("#include <a-a>");
verifyFormat("#include <string>\n"
"#include <a/b/c.h>\n"
"#include \"a/b/string\"\n"
"#include \"string.h\"\n"
"#include \"string.h\"\n"
"#include <a-a>");
verifyFormat("#import <string>");
verifyFormat("#import <a/b/c.h>");