diff options
author | Daniel Jasper <djasper@google.com> | 2014-05-07 09:48:30 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2014-05-07 09:48:30 +0000 |
commit | 79dffb412840c1487396be5fa07e8cfb8ac0d07d (patch) | |
tree | 404c232e0fc7a4d63b01e7af686e4be4a9a1c3cd /clang/lib/Format | |
parent | 8acf822b6fdebddc08d9f1b3614e83491a43b32c (diff) | |
download | bcm5719-llvm-79dffb412840c1487396be5fa07e8cfb8ac0d07d.tar.gz bcm5719-llvm-79dffb412840c1487396be5fa07e8cfb8ac0d07d.zip |
clang-format: Be slightly more aggressive on single-line functions.
So that JS functions can also be merged into a single line.
Before:
var func = function() {
return 1;
};
After:
var func = function() { return 1; };
llvm-svn: 208176
Diffstat (limited to 'clang/lib/Format')
-rw-r--r-- | clang/lib/Format/Format.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 21334ad9c80..008b4159fa3 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -654,6 +654,10 @@ private: Tok->CanBreakBefore = true; return 1; } else if (Limit != 0 && Line.First->isNot(tok::kw_namespace)) { + // We don't merge short records. + if (Line.First->isOneOf(tok::kw_class, tok::kw_union, tok::kw_struct)) + return 0; + // Check that we still have three lines and they fit into the limit. if (I + 2 == E || I[2]->Type == LT_Invalid) return 0; @@ -672,9 +676,9 @@ private: Tok = Tok->Next; } while (Tok != NULL); - // Last, check that the third line contains a single closing brace. + // Last, check that the third line starts with a closing brace. Tok = I[2]->First; - if (Tok->getNextNonComment() != NULL || Tok->isNot(tok::r_brace)) + if (Tok->isNot(tok::r_brace)) return 0; return 2; |