diff options
author | Chris Lattner <sabre@nondot.org> | 2010-04-20 20:35:58 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-04-20 20:35:58 +0000 |
commit | e127a0d80155b45dafe77f2b4380e5fa111a3345 (patch) | |
tree | b6b2e97ea34265d06945d0365c76eead56356910 /lib/Lex/PPLexerChange.cpp | |
parent | b00ab27f64abd18a68fc41699b86d0bc36189e21 (diff) |
push some source location information down through the compiler,
into ContentCache::getBuffer. This allows it to produce
diagnostics on the broken #include line instead of without a
location.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101939 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PPLexerChange.cpp')
-rw-r--r-- | lib/Lex/PPLexerChange.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/Lex/PPLexerChange.cpp b/lib/Lex/PPLexerChange.cpp index 335d3db627..4a40405992 100644 --- a/lib/Lex/PPLexerChange.cpp +++ b/lib/Lex/PPLexerChange.cpp @@ -64,8 +64,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. -bool Preprocessor::EnterSourceFile(FileID FID, const DirectoryLookup *CurDir, - std::string &ErrorStr) { +void Preprocessor::EnterSourceFile(FileID FID, const DirectoryLookup *CurDir, + SourceLocation Loc) { assert(CurTokenLexer == 0 && "Cannot #include a file inside a macro!"); ++NumEnteredSourceFiles; @@ -75,19 +75,23 @@ bool Preprocessor::EnterSourceFile(FileID FID, const DirectoryLookup *CurDir, if (PTH) { if (PTHLexer *PL = PTH->CreateLexer(FID)) { EnterSourceFileWithPTH(PL, CurDir); - return false; + return; } } // Get the MemoryBuffer for this FID, if it fails, we fail. bool Invalid = false; - const llvm::MemoryBuffer *InputFile = getSourceManager().getBuffer(FID, - &Invalid); - if (Invalid) - return true; + const llvm::MemoryBuffer *InputFile = + getSourceManager().getBuffer(FID, Loc, &Invalid); + if (Invalid) { + SourceLocation FileStart = SourceMgr.getLocForStartOfFile(FID); + Diag(Loc, diag::err_pp_error_opening_file) + << std::string(SourceMgr.getBufferName(FileStart)) << ""; + return; + } EnterSourceFileWithLexer(new Lexer(FID, InputFile, *this), CurDir); - return false; + return; } /// EnterSourceFileWithLexer - Add a source file to the top of the include stack |