diff options
| author | Daniel Jasper <djasper@google.com> | 2013-01-13 14:39:04 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2013-01-13 14:39:04 +0000 |
| commit | 22cf462234e4b634a301636df0e6e24b41a15035 (patch) | |
| tree | d13850c74985a1475c071244d4a726c10b8dc2fd | |
| parent | 953fb087e5ee32e8f2cc696ea54995bf6c4ce9b1 (diff) | |
| download | bcm5719-llvm-22cf462234e4b634a301636df0e6e24b41a15035.tar.gz bcm5719-llvm-22cf462234e4b634a301636df0e6e24b41a15035.zip | |
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;
llvm-svn: 172355
| -rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 3 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 0c8ff890491..b3671b30409 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -317,7 +317,8 @@ void UnwrappedLineParser::parseStructuralElement() { 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; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index a46c9b685bc..f3da5061f26 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -343,6 +343,7 @@ TEST_F(FormatTest, FormatsDerivedClass) { TEST_F(FormatTest, FormatsVariableDeclarationsAfterStructOrClass) { verifyFormat("class A {} a, b;"); verifyFormat("struct A {} a, b;"); + verifyFormat("union A {} a;"); } TEST_F(FormatTest, FormatsEnum) { |

