[cfe-commits] r172618 - in /cfe/trunk: lib/Format/Format.cpp unittests/Format/FormatTest.cpp
Daniel Jasper
djasper at google.com
Wed Jan 16 07:44:34 PST 2013
Author: djasper
Date: Wed Jan 16 09:44:34 2013
New Revision: 172618
URL: http://llvm.org/viewvc/llvm-project?rev=172618&view=rev
Log:
Disable inlining of short ifs in Google style.
Various reasons seem to speak against it, so I am disabling this for
now.
Changed tests to still test this option.
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=172618&r1=172617&r2=172618&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Wed Jan 16 09:44:34 2013
@@ -167,7 +167,7 @@
GoogleStyle.SpacesBeforeTrailingComments = 2;
GoogleStyle.BinPackParameters = false;
GoogleStyle.ConstructorInitializerAllOnOneLineOrOnePerLine = true;
- GoogleStyle.AllowShortIfStatementsOnASingleLine = true;
+ GoogleStyle.AllowShortIfStatementsOnASingleLine = false;
GoogleStyle.ObjCSpaceBeforeProtocolList = false;
GoogleStyle.ObjCSpaceBeforeReturnType = false;
return GoogleStyle;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=172618&r1=172617&r2=172618&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Jan 16 09:44:34 2013
@@ -151,23 +151,31 @@
verifyFormat("if (true)\n f();\ng();");
verifyFormat("if (a)\n if (b)\n if (c)\n g();\nh();");
verifyFormat("if (a)\n if (b) {\n f();\n }\ng();");
- verifyGoogleFormat("if (a)\n"
- " // comment\n"
- " f();");
- verifyFormat("if (a) return;", getGoogleStyleWithColumns(14));
- verifyFormat("if (a)\n return;", getGoogleStyleWithColumns(13));
+
+ FormatStyle AllowsMergedIf = getGoogleStyle();
+ AllowsMergedIf.AllowShortIfStatementsOnASingleLine = true;
+ verifyFormat("if (a)\n"
+ " // comment\n"
+ " f();", AllowsMergedIf);
+
+ verifyFormat("if (a) // Can't merge this\n"
+ " f();\n", AllowsMergedIf);
+ verifyFormat("if (a) /* still don't merge */\n"
+ " f();", AllowsMergedIf);
+ verifyFormat("if (a) { // Never merge this\n"
+ " f();\n"
+ "}", AllowsMergedIf);
+ verifyFormat("if (a) { /* Never merge this */\n"
+ " f();\n"
+ "}", AllowsMergedIf);
+
+ AllowsMergedIf.ColumnLimit = 14;
+ verifyFormat("if (a) return;", AllowsMergedIf);
verifyFormat("if (aaaaaaaaa)\n"
- " return;", getGoogleStyleWithColumns(14));
- verifyGoogleFormat("if (a) // Can't merge this\n"
- " f();\n");
- verifyGoogleFormat("if (a) /* still don't merge */\n"
- " f();");
- verifyGoogleFormat("if (a) { // Never merge this\n"
- " f();\n"
- "}");
- verifyGoogleFormat("if (a) { /* Never merge this */\n"
- " f();\n"
- "}");
+ " return;", AllowsMergedIf);
+
+ AllowsMergedIf.ColumnLimit = 13;
+ verifyFormat("if (a)\n return;", AllowsMergedIf);
}
TEST_F(FormatTest, ParseIfElse) {
More information about the cfe-commits
mailing list