diff options
author | Daniel Jasper <djasper@google.com> | 2013-02-04 08:34:57 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-02-04 08:34:57 +0000 |
commit | 14e40ec82896cc0d18acbec488a384987eb11f33 (patch) | |
tree | 47253cd1ab578924d8f006fd5329ca6bcfa2a7ca /clang/lib/Format/Format.cpp | |
parent | d91ae4d960aa6b22eab6e001f56493d0b5d0c452 (diff) | |
download | bcm5719-llvm-14e40ec82896cc0d18acbec488a384987eb11f33.tar.gz bcm5719-llvm-14e40ec82896cc0d18acbec488a384987eb11f33.zip |
Improve handling of trailing block comments
This is a follow up to r174309 to actually make it work.
llvm-svn: 174314
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rw-r--r-- | clang/lib/Format/Format.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 91cbc2efcd4..47d6340cfdf 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -204,6 +204,11 @@ private: tooling::Replacements Replaces; }; +static bool isTrailingComment(const AnnotatedToken &Tok) { + return Tok.is(tok::comment) && + (Tok.Children.empty() || Tok.Children[0].MustBreakBefore); +} + class UnwrappedLineFormatter { public: UnwrappedLineFormatter(const FormatStyle &Style, SourceManager &SourceMgr, @@ -464,7 +469,7 @@ private: (Previous.is(tok::l_paren) || Previous.is(tok::l_brace) || State.NextToken->Parent->Type == TT_TemplateOpener)) State.Stack[ParenLevel].Indent = State.Column + Spaces; - if (Previous.is(tok::comma) && Current.Type != TT_LineComment) + if (Previous.is(tok::comma) && !isTrailingComment(Current)) State.Stack[ParenLevel].HasMultiParameterLine = true; State.Column += Spaces; @@ -690,8 +695,7 @@ private: return true; if (State.NextToken->Parent->is(tok::comma) && State.Stack.back().BreakAfterComma && - (State.NextToken->isNot(tok::comment) || - !State.NextToken->Children[0].MustBreakBefore)) + !isTrailingComment(*State.NextToken)) return true; if ((State.NextToken->Type == TT_CtorInitializerColon || (State.NextToken->Parent->ClosesTemplateDeclaration && |