From 4fb7fbef3b3ff9233d8163a40eefafd8b36e9fd1 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 16 Mar 2010 20:01:30 +0000 Subject: Audit all getBuffer() callers (for both the FullSourceLoc and SourceManager versions), updating those callers that need to recover gracefully from failure. llvm-svn: 98665 --- clang/lib/Basic/SourceManager.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'clang/lib/Basic/SourceManager.cpp') diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 4007ccf2a61..254aec02262 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -475,15 +475,14 @@ bool SourceManager::overrideFileContents(const FileEntry *SourceFile, } llvm::StringRef SourceManager::getBufferData(FileID FID, bool *Invalid) const { + bool MyInvalid = false; + const llvm::MemoryBuffer *Buf = getBuffer(FID, &MyInvalid); if (Invalid) - *Invalid = false; - - const llvm::MemoryBuffer *Buf = getBuffer(FID); - if (!Buf) { - if (*Invalid) - *Invalid = true; + *Invalid = MyInvalid; + + if (MyInvalid) return ""; - } + return Buf->getBuffer(); } -- cgit v1.2.3