[cfe-commits] r172355 - in /cfe/trunk: lib/Format/UnwrappedLineParser.cpp unittests/Format/FormatTest.cpp
Daniel Jasper
djasper at google.com
Sun Jan 13 06:39:04 PST 2013
Author: djasper
Date: Sun Jan 13 08:39:04 2013
New Revision: 172355
URL: http://llvm.org/viewvc/llvm-project?rev=172355&view=rev
Log:
Format unions like structs and classes.
Note that I don't know whether we should put {} on a single line in this
case, but it is probably a theoretical issue as in practice such
structs, classes or unions won't be empty.
Before: union A {}
a;
After: union A {} a;
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=172355&r1=172354&r2=172355&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Sun Jan 13 08:39:04 2013
@@ -317,7 +317,8 @@
case tok::kw_enum:
parseEnum();
return;
- case tok::kw_struct: // fallthrough
+ case tok::kw_struct: // fallthrough
+ case tok::kw_union: // fallthrough
case tok::kw_class:
parseStructClassOrBracedList();
return;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=172355&r1=172354&r2=172355&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Sun Jan 13 08:39:04 2013
@@ -343,6 +343,7 @@
TEST_F(FormatTest, FormatsVariableDeclarationsAfterStructOrClass) {
verifyFormat("class A {} a, b;");
verifyFormat("struct A {} a, b;");
+ verifyFormat("union A {} a;");
}
TEST_F(FormatTest, FormatsEnum) {
More information about the cfe-commits
mailing list