summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/PPLexerChange.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-04-20 20:35:58 +0000
committerChris Lattner <sabre@nondot.org>2010-04-20 20:35:58 +0000
commitfb24a3a4ec3d625981bb822e021dc89a0cf3fde1 (patch)
tree20d53042ca9baae6abb062b22670a5305f79fc27 /clang/lib/Lex/PPLexerChange.cpp
parent877aaa9706e8bed893cebfc292a2ca305ec30663 (diff)
downloadbcm5719-llvm-fb24a3a4ec3d625981bb822e021dc89a0cf3fde1.tar.gz
bcm5719-llvm-fb24a3a4ec3d625981bb822e021dc89a0cf3fde1.zip
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. llvm-svn: 101939
Diffstat (limited to 'clang/lib/Lex/PPLexerChange.cpp')
-rw-r--r--clang/lib/Lex/PPLexerChange.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/clang/lib/Lex/PPLexerChange.cpp b/clang/lib/Lex/PPLexerChange.cpp
index 335d3db627d..4a404059926 100644
--- a/clang/lib/Lex/PPLexerChange.cpp
+++ b/clang/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
OpenPOWER on IntegriCloud