Sanity checks in SourceManager::getFileEntryForID() and SourceManager::getFileEntryForSLocEntry()

to make sure we do not crash. rdar://10594186

llvm-svn: 147576
This commit is contained in:
Argyrios Kyrtzidis 2012-01-05 00:19:03 +00:00
parent a59dc2f8f0
commit e6e9d8f6a7
1 changed files with 8 additions and 2 deletions

View File

@ -750,13 +750,19 @@ public:
if (MyInvalid || !Entry.isFile())
return 0;
return Entry.getFile().getContentCache()->OrigEntry;
const SrcMgr::ContentCache *Content = Entry.getFile().getContentCache();
if (!Content)
return 0;
return Content->OrigEntry;
}
/// Returns the FileEntry record for the provided SLocEntry.
const FileEntry *getFileEntryForSLocEntry(const SrcMgr::SLocEntry &sloc) const
{
return sloc.getFile().getContentCache()->OrigEntry;
const SrcMgr::ContentCache *Content = sloc.getFile().getContentCache();
if (!Content)
return 0;
return Content->OrigEntry;
}
/// getBufferData - Return a StringRef to the source buffer data for the