From 39d9841ed4c0568d4b44dfbc12ac04491f60a374 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 1 Dec 2009 22:52:33 +0000 Subject: pass the reason for failure up from MemoryBuffer and report it in diagnostics when we fail to open a file. This allows us to report things like: $ clang test.c -I. test.c:2:10: fatal error: error opening file './foo.h': Permission denied #include "foo.h" ^ git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90276 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Basic/SourceManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/Basic/SourceManager.cpp') diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp index a85bef0f29..394f493fa9 100644 --- a/lib/Basic/SourceManager.cpp +++ b/lib/Basic/SourceManager.cpp @@ -47,12 +47,12 @@ unsigned ContentCache::getSize() const { return Buffer ? Buffer->getBufferSize() : Entry->getSize(); } -const llvm::MemoryBuffer *ContentCache::getBuffer() const { +const llvm::MemoryBuffer *ContentCache::getBuffer(std::string *ErrorStr) const { // Lazily create the Buffer for ContentCaches that wrap files. if (!Buffer && Entry) { // FIXME: Should we support a way to not have to do this check over // and over if we cannot open the file? - Buffer = MemoryBuffer::getFile(Entry->getName(), 0, Entry->getSize()); + Buffer = MemoryBuffer::getFile(Entry->getName(), ErrorStr,Entry->getSize()); if (isTruncated()) const_cast(this)->truncateAt(TruncateAtLine, TruncateAtColumn); -- cgit v1.2.3-18-g5258