summaryrefslogtreecommitdiffstats
path: root/lib/Lex/PPLexerChange.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Lex/PPLexerChange.cpp')
-rw-r--r--lib/Lex/PPLexerChange.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/Lex/PPLexerChange.cpp b/lib/Lex/PPLexerChange.cpp
index 41ed991..8a61d7b 100644
--- a/lib/Lex/PPLexerChange.cpp
+++ b/lib/Lex/PPLexerChange.cpp
@@ -63,9 +63,8 @@ PreprocessorLexer *Preprocessor::getCurrentFileLexer() const {
//===----------------------------------------------------------------------===//
/// EnterSourceFile - Add a source file to the top of the include stack and
-/// start lexing tokens from it instead of the current buffer. Return true
-/// on failure.
-void Preprocessor::EnterSourceFile(FileID FID, const DirectoryLookup *CurDir) {
+/// start lexing tokens from it instead of the current buffer.
+bool Preprocessor::EnterSourceFile(FileID FID, const DirectoryLookup *CurDir) {
assert(CurTokenLexer == 0 && "Cannot #include a file inside a macro!");
++NumEnteredSourceFiles;
@@ -73,10 +72,19 @@ void Preprocessor::EnterSourceFile(FileID FID, const DirectoryLookup *CurDir) {
MaxIncludeStackDepth = IncludeMacroStack.size();
if (PTH) {
- if (PTHLexer *PL = PTH->CreateLexer(FID))
- return EnterSourceFileWithPTH(PL, CurDir);
+ if (PTHLexer *PL = PTH->CreateLexer(FID)) {
+ EnterSourceFileWithPTH(PL, CurDir);
+ return false;
+ }
}
- EnterSourceFileWithLexer(new Lexer(FID, *this), CurDir);
+
+ // Get the MemoryBuffer for this FID, if it fails, we fail.
+ const llvm::MemoryBuffer *InputFile = getSourceManager().getBuffer(FID);
+ if (InputFile == 0)
+ return true;
+
+ EnterSourceFileWithLexer(new Lexer(FID, InputFile, *this), CurDir);
+ return false;
}
/// EnterSourceFileWithLexer - Add a source file to the top of the include stack
OpenPOWER on IntegriCloud