summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/SourceManager.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-03-16 20:01:30 +0000
committerDouglas Gregor <dgregor@apple.com>2010-03-16 20:01:30 +0000
commit4fb7fbef3b3ff9233d8163a40eefafd8b36e9fd1 (patch)
treebecb455ac4bd68fee869e1cf68500ecbffdba37f /clang/lib/Basic/SourceManager.cpp
parent26266da3c35d5a47770a9b165d5b5c74e714898b (diff)
downloadbcm5719-llvm-4fb7fbef3b3ff9233d8163a40eefafd8b36e9fd1.tar.gz
bcm5719-llvm-4fb7fbef3b3ff9233d8163a40eefafd8b36e9fd1.zip
Audit all getBuffer() callers (for both the FullSourceLoc and
SourceManager versions), updating those callers that need to recover gracefully from failure. llvm-svn: 98665
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r--clang/lib/Basic/SourceManager.cpp13
1 files changed, 6 insertions, 7 deletions
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();
}
OpenPOWER on IntegriCloud