diff options
author | Daniel Jasper <djasper@google.com> | 2013-01-29 19:41:55 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-01-29 19:41:55 +0000 |
commit | ddaa9be9783928ecd802c433821fe7c8e05bf8b9 (patch) | |
tree | 337f50329be1ff6925bbb2458d37cc5a11d0201a /clang/lib/Format/Format.cpp | |
parent | 9a7a7a9a6f81baa36cf9456da3d30d2a544ee64a (diff) | |
download | bcm5719-llvm-ddaa9be9783928ecd802c433821fe7c8e05bf8b9.tar.gz bcm5719-llvm-ddaa9be9783928ecd802c433821fe7c8e05bf8b9.zip |
Improve formatting of code with comments.
Before:
aaaaaaa(aaaaaa( // comment
aaaaaaa));
<big mess>
After:
aaaaaaa(aaaaaa( // comment
aaaaaaaa));
function(/* parameter 1 */ aaaaaaa,
/* parameter 2 */ aaaaaaa,
/* parameter 3 */ aaaaaaa,
/* parameter 4 */ aaaaaaa);
(the latter example was only wrong in the one-arg-per-line mode, e.g. in
Google style).
llvm-svn: 173821
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rw-r--r-- | clang/lib/Format/Format.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 81c8309ef9d..ecd6f5d3854 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -617,12 +617,11 @@ private: (getPrecedence(Previous) == prec::Assignment || Previous.is(tok::kw_return))) State.Stack.back().AssignmentColumn = State.Column + Spaces; - if (Previous.is(tok::l_paren) || Previous.is(tok::l_brace) || - State.NextToken->Parent->Type == TT_TemplateOpener) + if (Current.Type != TT_LineComment && + (Previous.is(tok::l_paren) || Previous.is(tok::l_brace) || + State.NextToken->Parent->Type == TT_TemplateOpener)) State.Stack[ParenLevel].Indent = State.Column + Spaces; - if (Current.getPreviousNoneComment() != NULL && - Current.getPreviousNoneComment()->is(tok::comma) && - Current.isNot(tok::comment)) + if (Previous.is(tok::comma) && Current.Type != TT_LineComment) State.Stack[ParenLevel].HasMultiParameterLine = true; State.Column += Spaces; @@ -746,7 +745,7 @@ private: State.LineContainsContinuedForLoopSection) return UINT_MAX; if (!NewLine && State.NextToken->Parent->is(tok::comma) && - State.NextToken->isNot(tok::comment) && + State.NextToken->Type != TT_LineComment && State.Stack.back().BreakAfterComma) return UINT_MAX; // Trying to insert a parameter on a new line if there are already more than |