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 | f52d52790708132cc1a3b5c3aef1bed17eb6ff13 (patch) | |
tree | ff27a4a827f6f6c7dbee5b3f9620712dfcb1ddfb /lib/Format | |
parent | 3d11708c491a96198ebfee49079ae458ed90eaf8 (diff) |
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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178537 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format')
-rw-r--r-- | lib/Format/UnwrappedLineParser.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index b24d5141e0..d218f88e55 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/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 = |