diff options
author | Manuel Klimek <klimek@google.com> | 2013-01-22 16:31:55 +0000 |
---|---|---|
committer | Manuel Klimek <klimek@google.com> | 2013-01-22 16:31:55 +0000 |
commit | 86721d2a4610ac0a4b162952ec409df1fe397d58 (patch) | |
tree | f642fb02d6bf9a870cf57c7adaac5f3a8321a9d0 /lib/Format/Format.cpp | |
parent | 3298327e0e6ecb31ca8f3d0996043292e7c860f2 (diff) |
Implements more principled comment parsing.
Changing nextToken() in the UnwrappedLineParser to get the next
non-comment token. This allows us to correctly layout a whole class of
snippets, like:
if /* */(/* */ a /* */) /* */
f() /* */; /* */
else /* */
g();
Fixes a bug in the formatter where we would assume there is a previous
non-comment token.
Also adds the indent level of an unwrapped line to the debug output in
the parser.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173168 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/Format.cpp')
-rw-r--r-- | lib/Format/Format.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 08b0d97983..1405fc23e1 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -586,7 +586,8 @@ private: if (Previous.is(tok::l_paren) || Previous.is(tok::l_brace) || State.NextToken->Parent->Type == TT_TemplateOpener) State.Stack[ParenLevel].Indent = State.Column + Spaces; - if (Current.getPreviousNoneComment()->is(tok::comma) && + if (Current.getPreviousNoneComment() != NULL && + Current.getPreviousNoneComment()->is(tok::comma) && Current.isNot(tok::comment)) State.Stack[ParenLevel].HasMultiParameterLine = true; @@ -1639,6 +1640,7 @@ public: // FIXME: Add a more explicit test. unsigned i = 0; while (i + 1 < Text.size() && Text[i] == '\\' && Text[i + 1] == '\n') { + // FIXME: ++FormatTok.NewlinesBefore is missing... FormatTok.WhiteSpaceLength += 2; FormatTok.TokenLength -= 2; i += 2; |