r174063 - Never break inside something that was a preprocessor directive.
Manuel Klimek
klimek at google.com
Thu Jan 31 07:58:48 PST 2013
Author: klimek
Date: Thu Jan 31 09:58:48 2013
New Revision: 174063
URL: http://llvm.org/viewvc/llvm-project?rev=174063&view=rev
Log:
Never break inside something that was a preprocessor directive.
Just put it in one unwrapped line and let the formatter handle it.
Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=174063&r1=174062&r2=174063&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Thu Jan 31 09:58:48 2013
@@ -215,7 +215,7 @@ void UnwrappedLineParser::parsePPDirecti
nextToken();
if (FormatTok.Tok.getIdentifierInfo() == NULL) {
- addUnwrappedLine();
+ parsePPUnknown();
return;
}
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=174063&r1=174062&r2=174063&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Jan 31 09:58:48 2013
@@ -714,8 +714,10 @@ TEST_F(FormatTest, DoesNotBreakPureVirtu
" OwningPtr<FileOutputBuffer> &buffer) = 0;");
}
-TEST_F(FormatTest, BreaksOnHashWhenDirectiveIsInvalid) {
- EXPECT_EQ("#\n;", format("#;"));
+TEST_F(FormatTest, LayoutUnknownPPDirective) {
+ EXPECT_EQ("#123 \"A string literal\"",
+ format(" # 123 \"A string literal\""));
+ EXPECT_EQ("#;", format("#;"));
verifyFormat("#\n;\n;\n;");
}
More information about the cfe-commits
mailing list