diff options
| author | Alexander Kornienko <alexfh@google.com> | 2013-04-02 13:04:06 +0000 |
|---|---|---|
| committer | Alexander Kornienko <alexfh@google.com> | 2013-04-02 13:04:06 +0000 |
| commit | b5dad75e38d449a1421d5f14ccf55857fe5599fe (patch) | |
| tree | bd05e5c5589641ebebe5cf4df6d93b88f6bba9c4 /clang/lib | |
| parent | a922c7e90e95791838f30148d33af0deeab42137 (diff) | |
| download | bcm5719-llvm-b5dad75e38d449a1421d5f14ccf55857fe5599fe.tar.gz bcm5719-llvm-b5dad75e38d449a1421d5f14ccf55857fe5599fe.zip | |
Alternative handling of comments adjacent to preprocessor directives.
Summary: Store comments in ScopedLineState
Reviewers: klimek, djasper
Reviewed By: klimek
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D609
llvm-svn: 178537
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index b24d5141e0a..d218f88e551 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -100,6 +100,7 @@ public: Parser.Line.reset(new UnwrappedLine()); Parser.Line->Level = PreBlockLine->Level; Parser.Line->InPPDirective = PreBlockLine->InPPDirective; + Parser.CommentsBeforeNextToken.swap(CommentsBeforeNextToken); } ~ScopedLineState() { @@ -111,6 +112,7 @@ public: Parser.MustBreakBeforeNextToken = true; if (SwitchToPreprocessorLines) Parser.CurrentLines = &Parser.Lines; + Parser.CommentsBeforeNextToken.swap(CommentsBeforeNextToken); } private: @@ -118,6 +120,7 @@ private: const bool SwitchToPreprocessorLines; UnwrappedLine *PreBlockLine; + SmallVector<FormatToken, 1> CommentsBeforeNextToken; }; UnwrappedLineParser::UnwrappedLineParser( @@ -822,7 +825,6 @@ void UnwrappedLineParser::readToken() { while (!Line->InPPDirective && FormatTok.Tok.is(tok::hash) && ((FormatTok.NewlinesBefore > 0 && FormatTok.HasUnescapedNewline) || FormatTok.IsFirst)) { - flushComments(FormatTok.NewlinesBefore > 0); // If there is an unfinished unwrapped line, we flush the preprocessor // directives only after that unwrapped line was finished later. bool SwitchToPreprocessorLines = |

