[cfe-commits] r172424 - in /cfe/trunk: lib/Format/Format.cpp unittests/Format/FormatTest.cpp
Daniel Jasper
djasper at google.com
Mon Jan 14 07:52:06 PST 2013
Author: djasper
Date: Mon Jan 14 09:52:06 2013
New Revision: 172424
URL: http://llvm.org/viewvc/llvm-project?rev=172424&view=rev
Log:
Fix bug that would lead to joining preprocessor directives.
Before: #include "a.h" #include "b.h"
After: #include "a.h"
#include "b.h"
Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=172424&r1=172423&r2=172424&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon Jan 14 09:52:06 2013
@@ -1427,7 +1427,8 @@
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;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=172424&r1=172423&r2=172424&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jan 14 09:52:06 2013
@@ -1133,12 +1133,12 @@
}
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>");
More information about the cfe-commits
mailing list