summaryrefslogtreecommitdiffstats
path: root/clang/lib/Rewrite
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2013-12-13 17:04:55 +0000
committerAlp Toker <alp@nuanti.com>2013-12-13 17:04:55 +0000
commit08c2500f9c0e7d6c22021f7ad70955c367c59e93 (patch)
tree06987c1425a1a47d3ba31fbfa7ba1eee1d928d9e /clang/lib/Rewrite
parent3158ec400262469fc79856c339e5b12d05c85719 (diff)
downloadbcm5719-llvm-08c2500f9c0e7d6c22021f7ad70955c367c59e93.tar.gz
bcm5719-llvm-08c2500f9c0e7d6c22021f7ad70955c367c59e93.zip
Fix raw lex crash and -frewrite-includes noeol-at-eof failure
Raw lexers don't have a preprocessor so we need to null check. llvm-svn: 197245
Diffstat (limited to 'clang/lib/Rewrite')
-rw-r--r--clang/lib/Rewrite/Frontend/InclusionRewriter.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/clang/lib/Rewrite/Frontend/InclusionRewriter.cpp b/clang/lib/Rewrite/Frontend/InclusionRewriter.cpp
index a2e0db69619..0e3e53498b5 100644
--- a/clang/lib/Rewrite/Frontend/InclusionRewriter.cpp
+++ b/clang/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));
OpenPOWER on IntegriCloud