getOrCreateContentCache never returns null, so overrideFileContents

doesn't need its return value.

llvm-svn: 117393
This commit is contained in:
Dan Gohman 2010-10-26 20:47:28 +00:00
parent b7050233fb
commit 5d223dcb2f
2 changed files with 4 additions and 8 deletions

View File

@ -466,7 +466,7 @@ public:
unsigned PreallocatedID = 0,
unsigned Offset = 0) {
const SrcMgr::ContentCache *IR = getOrCreateContentCache(SourceFile);
if (IR == 0) return FileID(); // Error opening file?
assert(IR && "getOrCreateContentCache() cannot return NULL");
return createFileID(IR, IncludePos, FileCharacter, PreallocatedID, Offset);
}
@ -516,9 +516,7 @@ public:
///
/// \param DoNotFree If true, then the buffer will not be freed when the
/// source manager is destroyed.
///
/// \returns true if an error occurred, false otherwise.
bool overrideFileContents(const FileEntry *SourceFile,
void overrideFileContents(const FileEntry *SourceFile,
const llvm::MemoryBuffer *Buffer,
bool DoNotFree = false);

View File

@ -525,15 +525,13 @@ SourceManager::getMemoryBufferForFile(const FileEntry *File,
return IR->getBuffer(Diag, *this, SourceLocation(), Invalid);
}
bool SourceManager::overrideFileContents(const FileEntry *SourceFile,
void SourceManager::overrideFileContents(const FileEntry *SourceFile,
const llvm::MemoryBuffer *Buffer,
bool DoNotFree) {
const SrcMgr::ContentCache *IR = getOrCreateContentCache(SourceFile);
if (IR == 0)
return true;
assert(IR && "getOrCreateContentCache() cannot return NULL");
const_cast<SrcMgr::ContentCache *>(IR)->replaceBuffer(Buffer, DoNotFree);
return false;
}
llvm::StringRef SourceManager::getBufferData(FileID FID, bool *Invalid) const {