diff options
| author | Daniel Jasper <djasper@google.com> | 2013-01-14 15:52:06 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2013-01-14 15:52:06 +0000 |
| commit | 2ab0d01a8e2c7002478fa49f8aca4b32cc72b432 (patch) | |
| tree | 81a57fe120c38bf26bfc7ddb8b17b2f4ce34c358 /clang | |
| parent | 39825eaff580972cc1d2913bd4278e9b581d7304 (diff) | |
| download | bcm5719-llvm-2ab0d01a8e2c7002478fa49f8aca4b32cc72b432.tar.gz bcm5719-llvm-2ab0d01a8e2c7002478fa49f8aca4b32cc72b432.zip | |
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
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Format/Format.cpp | 3 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 12 |
2 files changed, 8 insertions, 7 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index c8dc7bf55c1..742b9a8d1cc 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -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; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index c088089211c..daebc4ddab1 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -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>"); |

