diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-03-16 20:01:30 +0000 | 
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-03-16 20:01:30 +0000 | 
| commit | 4fb7fbef3b3ff9233d8163a40eefafd8b36e9fd1 (patch) | |
| tree | becb455ac4bd68fee869e1cf68500ecbffdba37f /clang/lib/Basic | |
| parent | 26266da3c35d5a47770a9b165d5b5c74e714898b (diff) | |
| download | bcm5719-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')
| -rw-r--r-- | clang/lib/Basic/SourceLocation.cpp | 8 | ||||
| -rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 13 | 
2 files changed, 10 insertions, 11 deletions
diff --git a/clang/lib/Basic/SourceLocation.cpp b/clang/lib/Basic/SourceLocation.cpp index 126d640364d..85e5595dc2e 100644 --- a/clang/lib/Basic/SourceLocation.cpp +++ b/clang/lib/Basic/SourceLocation.cpp @@ -110,13 +110,13 @@ const char *FullSourceLoc::getCharacterData() const {    return SrcMgr->getCharacterData(*this);  } -const llvm::MemoryBuffer* FullSourceLoc::getBuffer() const { +const llvm::MemoryBuffer* FullSourceLoc::getBuffer(bool *Invalid) const {    assert(isValid()); -  return SrcMgr->getBuffer(SrcMgr->getFileID(*this)); +  return SrcMgr->getBuffer(SrcMgr->getFileID(*this), Invalid);  } -llvm::StringRef FullSourceLoc::getBufferData() const { -  return getBuffer()->getBuffer(); +llvm::StringRef FullSourceLoc::getBufferData(bool *Invalid) const { +  return getBuffer(Invalid)->getBuffer();  }  std::pair<FileID, unsigned> FullSourceLoc::getDecomposedLoc() const { 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();  }  | 

