diff options
author | Daniel Jasper <djasper@google.com> | 2013-02-06 20:07:35 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-02-06 20:07:35 +0000 |
commit | 94f0e1382a8e623ea128caa8a6c41d2cd694604d (patch) | |
tree | af0702fe42ef17f304ce29faa45e107642a9f8df /clang/lib/Format/Format.cpp | |
parent | 8911b8640059817c1d73f9f981d4d00c124d5d42 (diff) | |
download | bcm5719-llvm-94f0e1382a8e623ea128caa8a6c41d2cd694604d.tar.gz bcm5719-llvm-94f0e1382a8e623ea128caa8a6c41d2cd694604d.zip |
Align trailing block comments like trailing line comments.
llvm-svn: 174537
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rw-r--r-- | clang/lib/Format/Format.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 3660b4ac03e..4128785f637 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -80,6 +80,11 @@ FormatStyle getChromiumStyle() { return ChromiumStyle; } +static bool isTrailingComment(const AnnotatedToken &Tok) { + return Tok.is(tok::comment) && + (Tok.Children.empty() || Tok.Children[0].MustBreakBefore); +} + /// \brief Manages the whitespaces around tokens and their replacements. /// /// This includes special handling for certain constructs, e.g. the alignment of @@ -99,8 +104,7 @@ public: // Align line comments if they are trailing or if they continue other // trailing comments. - if (Tok.Type == TT_LineComment && - (Tok.Parent != NULL || !Comments.empty())) { + if (isTrailingComment(Tok) && (Tok.Parent != NULL || !Comments.empty())) { if (Style.ColumnLimit >= Spaces + WhitespaceStartColumn + Tok.FormatTok.TokenLength) { Comments.push_back(StoredComment()); @@ -115,7 +119,7 @@ public: } // If this line does not have a trailing comment, align the stored comments. - if (Tok.Children.empty() && Tok.Type != TT_LineComment) + if (Tok.Children.empty() && !isTrailingComment(Tok)) alignComments(); storeReplacement(Tok.FormatTok, std::string(NewLines, '\n') + std::string(Spaces, ' ')); @@ -207,11 +211,6 @@ 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, |