diff options
Diffstat (limited to 'include/clang/Basic')
-rw-r--r-- | include/clang/Basic/DiagnosticLexKinds.td | 2 | ||||
-rw-r--r-- | include/clang/Basic/SourceManager.h | 14 |
2 files changed, 10 insertions, 6 deletions
diff --git a/include/clang/Basic/DiagnosticLexKinds.td b/include/clang/Basic/DiagnosticLexKinds.td index 39123d9b37..cc06ab3a86 100644 --- a/include/clang/Basic/DiagnosticLexKinds.td +++ b/include/clang/Basic/DiagnosticLexKinds.td @@ -171,7 +171,7 @@ def err_pp_invalid_directive : Error<"invalid preprocessing directive">; def err_pp_hash_error : Error<"#error%0">; def err_pp_file_not_found : Error<"'%0' file not found">, DefaultFatal; def err_pp_error_opening_file : Error< - "error opening file '%0'">, DefaultFatal; + "error opening file '%0': %1">, DefaultFatal; def err_pp_empty_filename : Error<"empty filename">; def err_pp_include_too_deep : Error<"#include nested too deeply">; def err_pp_expects_filename : Error<"expected \"FILENAME\" or <FILENAME>">; 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. |