summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-01-05 00:19:03 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-01-05 00:19:03 +0000
commite6e9d8f6a7c686a58699a3b562db9c80ff864ef2 (patch)
treed536a737ba59dcd56f0069712db5b91c466e4073
parenta59dc2f8f0afedb980a301359e9e621f6e604853 (diff)
downloadbcm5719-llvm-e6e9d8f6a7c686a58699a3b562db9c80ff864ef2.tar.gz
bcm5719-llvm-e6e9d8f6a7c686a58699a3b562db9c80ff864ef2.zip
Sanity checks in SourceManager::getFileEntryForID() and SourceManager::getFileEntryForSLocEntry()
to make sure we do not crash. rdar://10594186 llvm-svn: 147576
-rw-r--r--clang/include/clang/Basic/SourceManager.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/include/clang/Basic/SourceManager.h b/clang/include/clang/Basic/SourceManager.h
index 375aea0ee90..d08d5368d15 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -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
OpenPOWER on IntegriCloud