aboutsummaryrefslogtreecommitdiff
path: root/lib/Format/Format.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-02-04 08:34:57 +0000
committerDaniel Jasper <djasper@google.com>2013-02-04 08:34:57 +0000
commitcda165056890b8ccfc6e2897c711388c5fb518c0 (patch)
tree7f1c6057474934c69f113276a850985eee5a6508 /lib/Format/Format.cpp
parentfa543accd8945c39d5128612c8822d0ab4ad594c (diff)
Improve handling of trailing block comments
This is a follow up to r174309 to actually make it work. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174314 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/Format.cpp')
-rw-r--r--lib/Format/Format.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index 91cbc2efcd..47d6340cfd 100644
--- a/lib/Format/Format.cpp
+++ b/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 &&