diff options
author | Daniel Jasper <djasper@google.com> | 2013-02-14 09:19:04 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-02-14 09:19:04 +0000 |
commit | 66e9dee707661e91f774dbf243d68ce669e2b3ff (patch) | |
tree | 1ab8862550e81555639c5305a4bf09872c7115b3 /clang | |
parent | 5b9d426907909035fd4de8b008f070c7377d1036 (diff) | |
download | bcm5719-llvm-66e9dee707661e91f774dbf243d68ce669e2b3ff.tar.gz bcm5719-llvm-66e9dee707661e91f774dbf243d68ce669e2b3ff.zip |
Get less confused by trailing comma in Google style.
The formatter can now format:
void aaaaaaaaaaaaaaaaaa(int level,
double *min_x,
double *max_x,
double *min_y,
double *max_y,
double *min_z,
double *max_z, ) {
}
Although this is invalid code, it frequently happens during development and
clang-format should be nicer :-).
llvm-svn: 175151
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Format/Format.cpp | 3 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 11 |
2 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 1bd864e5c9d..f03b77853ce 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -781,7 +781,8 @@ private: return true; if (State.NextToken->Parent->is(tok::comma) && State.Stack.back().BreakBeforeParameter && - !isTrailingComment(*State.NextToken)) + !isTrailingComment(*State.NextToken) && + State.NextToken->isNot(tok::r_paren)) return true; // FIXME: Comparing LongestObjCSelectorName to 0 is a hacky way of finding // out whether it is the first parameter. Clean this up. diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index d5e3c24545a..e99aad7a8cf 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1817,6 +1817,17 @@ TEST_F(FormatTest, HandlesIncludeDirectives) { // Error recovery tests. //===----------------------------------------------------------------------===// +TEST_F(FormatTest, IncompleteParameterLists) { + verifyGoogleFormat("void aaaaaaaaaaaaaaaaaa(int level,\n" + " double *min_x,\n" + " double *max_x,\n" + " double *min_y,\n" + " double *max_y,\n" + " double *min_z,\n" + " double *max_z, ) {\n" + "}"); +} + TEST_F(FormatTest, IncorrectCodeTrailingStuff) { verifyFormat("void f() { return; }\n42"); verifyFormat("void f() {\n" |