From bb37a2f6f34f787c93c983a7cc1e7d9495c7e73b Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 1 Feb 2016 11:20:55 +0000 Subject: clang-format: Fix alignment of trailing multiline columns. llvm-svn: 259351 --- clang/lib/Format/WhitespaceManager.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'clang/lib/Format/WhitespaceManager.cpp') diff --git a/clang/lib/Format/WhitespaceManager.cpp b/clang/lib/Format/WhitespaceManager.cpp index d6e6ed2c2ba..0673dfb3ace 100644 --- a/clang/lib/Format/WhitespaceManager.cpp +++ b/clang/lib/Format/WhitespaceManager.cpp @@ -372,16 +372,20 @@ void WhitespaceManager::alignTrailingComments() { unsigned CommentColumn = SourceMgr.getSpellingColumnNumber( Changes[i].OriginalWhitespaceRange.getEnd()); for (unsigned j = i + 1; j != e; ++j) { - if (Changes[j].Kind != tok::comment) { // Skip over comments. - unsigned NextColumn = SourceMgr.getSpellingColumnNumber( - Changes[j].OriginalWhitespaceRange.getEnd()); - // The start of the next token was previously aligned with the - // start of this comment. - WasAlignedWithStartOfNextLine = - CommentColumn == NextColumn || - CommentColumn == NextColumn + Style.IndentWidth; - break; - } + if (Changes[j].Kind == tok::comment || + Changes[j].Kind == tok::unknown) + // Skip over comments and unknown tokens. "unknown tokens are used for + // the continuation of multiline comments. + continue; + + unsigned NextColumn = SourceMgr.getSpellingColumnNumber( + Changes[j].OriginalWhitespaceRange.getEnd()); + // The start of the next token was previously aligned with the + // start of this comment. + WasAlignedWithStartOfNextLine = + CommentColumn == NextColumn || + CommentColumn == NextColumn + Style.IndentWidth; + break; } } if (!Style.AlignTrailingComments || FollowsRBraceInColumn0) { -- cgit v1.2.3