diff options
author | Alp Toker <alp@nuanti.com> | 2013-12-13 17:04:55 +0000 |
---|---|---|
committer | Alp Toker <alp@nuanti.com> | 2013-12-13 17:04:55 +0000 |
commit | e3739cdb5fe9e51b464c8defce598d290466a712 (patch) | |
tree | 6dcbbeedc0a381f445168bf630f6849179abee4c /lib/Rewrite | |
parent | 1366f26a78a293be5054f32001ce73a4db4a82f8 (diff) |
Fix raw lex crash and -frewrite-includes noeol-at-eof failure
Raw lexers don't have a preprocessor so we need to null check.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197245 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Rewrite')
-rw-r--r-- | lib/Rewrite/Frontend/InclusionRewriter.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/Rewrite/Frontend/InclusionRewriter.cpp b/lib/Rewrite/Frontend/InclusionRewriter.cpp index a2e0db6961..0e3e53498b 100644 --- a/lib/Rewrite/Frontend/InclusionRewriter.cpp +++ b/lib/Rewrite/Frontend/InclusionRewriter.cpp @@ -77,7 +77,7 @@ private: void OutputContentUpTo(const MemoryBuffer &FromFile, unsigned &WriteFrom, unsigned WriteTo, StringRef EOL, int &lines, - bool EnsureNewline = false); + bool EnsureNewline); void CommentOutDirective(Lexer &DirectivesLex, const Token &StartToken, const MemoryBuffer &FromFile, StringRef EOL, unsigned &NextToWrite, int &Lines); @@ -250,7 +250,7 @@ void InclusionRewriter::CommentOutDirective(Lexer &DirectiveLex, StringRef EOL, unsigned &NextToWrite, int &Line) { OutputContentUpTo(FromFile, NextToWrite, - SM.getFileOffset(StartToken.getLocation()), EOL, Line); + SM.getFileOffset(StartToken.getLocation()), EOL, Line, false); Token DirectiveToken; do { DirectiveLex.LexFromRawLexer(DirectiveToken); @@ -258,7 +258,7 @@ void InclusionRewriter::CommentOutDirective(Lexer &DirectiveLex, OS << "#if 0 /* expanded by -frewrite-includes */" << EOL; OutputContentUpTo(FromFile, NextToWrite, SM.getFileOffset(DirectiveToken.getLocation()) + DirectiveToken.getLength(), - EOL, Line); + EOL, Line, true); OS << "#endif /* expanded by -frewrite-includes */" << EOL; } @@ -462,12 +462,12 @@ bool InclusionRewriter::Process(FileID FileId, // Replace the macro with (0) or (1), followed by the commented // out macro for reference. OutputContentUpTo(FromFile, NextToWrite, SM.getFileOffset(Loc), - EOL, Line); + EOL, Line, false); OS << '(' << (int) HasFile << ")/*"; OutputContentUpTo(FromFile, NextToWrite, SM.getFileOffset(RawToken.getLocation()) + RawToken.getLength(), - EOL, Line); + EOL, Line, false); OS << "*/"; } } while (RawToken.isNot(tok::eod)); |