diff options
author | Daniel Jasper <djasper@google.com> | 2013-01-18 09:19:33 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-01-18 09:19:33 +0000 |
commit | 997b08ce3cb6d4de8c2ddb784884aea5f833c038 (patch) | |
tree | dbf9a5f11d718a5b2d8d164af9f32f5ef398e16d /clang/lib/Format/Format.cpp | |
parent | aa701fa3adbce77357d60c8a494c6492fd1e206a (diff) | |
download | bcm5719-llvm-997b08ce3cb6d4de8c2ddb784884aea5f833c038.tar.gz bcm5719-llvm-997b08ce3cb6d4de8c2ddb784884aea5f833c038.zip |
Also align trailing line comments in include directives.
Before:
#include <a> // for x
#include <a/b/c> // for yz
After:
#include <a> // for x
#include <a/b/c> // for yz
llvm-svn: 172799
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rw-r--r-- | clang/lib/Format/Format.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 39d70d3e5a4..50df593d85f 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -350,13 +350,15 @@ public: // Start iterating at 1 as we have correctly formatted of Token #0 above. while (State.NextToken != NULL) { - if (State.NextToken->Type == TT_ImplicitStringLiteral) - // We will not touch the rest of the white space in this - // \c UnwrappedLine. The returned value can also not matter, as we - // cannot continue an top-level implicit string literal on the next - // line. - return 0; - if (Line.Last->TotalLength <= getColumnLimit() - FirstIndent) { + if (State.NextToken->Type == TT_ImplicitStringLiteral) { + // Calculating the column is important for aligning trailing comments. + // FIXME: This does not seem to happen in conjunction with escaped + // newlines. If it does, fix! + State.Column += State.NextToken->FormatTok.WhiteSpaceLength + + State.NextToken->FormatTok.TokenLength; + State.NextToken = State.NextToken->Children.empty() ? NULL : + &State.NextToken->Children[0]; + } else if (Line.Last->TotalLength <= getColumnLimit() - FirstIndent) { addTokenToState(false, false, State); } else { unsigned NoBreak = calcPenalty(State, false, UINT_MAX); @@ -1096,7 +1098,9 @@ public: if (CurrentToken != NULL && CurrentToken->is(tok::less)) { next(); while (CurrentToken != NULL) { - CurrentToken->Type = TT_ImplicitStringLiteral; + if (CurrentToken->isNot(tok::comment) || + !CurrentToken->Children.empty()) + CurrentToken->Type = TT_ImplicitStringLiteral; next(); } } else { |