[cfe-commits] r147576 - /cfe/trunk/include/clang/Basic/SourceManager.h

Argyrios Kyrtzidis akyrtzi at gmail.com
Wed Jan 4 16:19:03 PST 2012


Author: akirtzidis
Date: Wed Jan  4 18:19:03 2012
New Revision: 147576

URL: http://llvm.org/viewvc/llvm-project?rev=147576&view=rev
Log:
Sanity checks in SourceManager::getFileEntryForID() and SourceManager::getFileEntryForSLocEntry()
to make sure we do not crash. rdar://10594186

Modified:
    cfe/trunk/include/clang/Basic/SourceManager.h

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=147576&r1=147575&r2=147576&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Wed Jan  4 18:19:03 2012
@@ -750,13 +750,19 @@
     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





More information about the cfe-commits mailing list