Fix comment alignment behavior.
In the following snippet, clang-format incorrectly aligned the
trailing comment, when only the last line was formatted:
int aaaaaa; // comment
int b;
int c; // Formatting only this line moved this comment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180173 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/WhitespaceManager.h b/lib/Format/WhitespaceManager.h
index 252997f..2833e24 100644
--- a/lib/Format/WhitespaceManager.h
+++ b/lib/Format/WhitespaceManager.h
@@ -66,6 +66,9 @@
void addUntouchableComment(unsigned Column);
+ /// \brief Try to align all stashed comments.
+ void alignComments();
+
private:
std::string getNewLineText(unsigned NewLines, unsigned Spaces);
@@ -84,9 +87,6 @@
SmallVector<StoredComment, 16> Comments;
typedef SmallVector<StoredComment, 16>::iterator comment_iterator;
- /// \brief Try to align all stashed comments.
- void alignComments();
-
/// \brief Put all the comments between \p I and \p E into \p Column.
void alignComments(comment_iterator I, comment_iterator E, unsigned Column);