diff options
author | Chris Lattner <sabre@nondot.org> | 2009-12-01 22:52:33 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-12-01 22:52:33 +0000 |
commit | 39d9841ed4c0568d4b44dfbc12ac04491f60a374 (patch) | |
tree | 8e85395573cf9e3854b100995521f7195fe2d0f2 /include/clang/Basic/SourceManager.h | |
parent | 2b56b9cf7429919e1df011d8d6bee2e04f5bc22c (diff) |
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
Diffstat (limited to 'include/clang/Basic/SourceManager.h')
-rw-r--r-- | include/clang/Basic/SourceManager.h | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h index 7e9ac53101..67b3d50064 100644 --- a/include/clang/Basic/SourceManager.h +++ b/include/clang/Basic/SourceManager.h @@ -77,8 +77,10 @@ namespace SrcMgr { /// ContentCache. mutable FileID FirstFID; - /// getBuffer - Returns the memory buffer for the associated content. - const llvm::MemoryBuffer *getBuffer() const; + /// getBuffer - Returns the memory buffer for the associated content. If + /// there is an error opening this buffer the first time, this returns null + /// and fills in the ErrorStr with a reason. + const llvm::MemoryBuffer *getBuffer(std::string *ErrorStr = 0) const; /// getSize - Returns the size of the content encapsulated by this /// ContentCache. This can be the size of the source file or the size of an @@ -432,10 +434,12 @@ public: // FileID manipulation methods. //===--------------------------------------------------------------------===// - /// getBuffer - Return the buffer for the specified FileID. + /// getBuffer - Return the buffer for the specified FileID. If there is an + /// error opening this buffer the first time, this returns null and fills in + /// the ErrorStr with a reason. /// - const llvm::MemoryBuffer *getBuffer(FileID FID) const { - return getSLocEntry(FID).getFile().getContentCache()->getBuffer(); + const llvm::MemoryBuffer *getBuffer(FileID FID, std::string *Error = 0) const{ + return getSLocEntry(FID).getFile().getContentCache()->getBuffer(Error); } /// getFileEntryForID - Returns the FileEntry record for the provided FileID. |