[cfe-commits] r114392 - /cfe/trunk/tools/libclang/CIndexUSRs.cpp

Ted Kremenek kremenek at apple.com
Mon Sep 20 21:45:46 PDT 2010


Author: kremenek
Date: Mon Sep 20 23:45:46 2010
New Revision: 114392

URL: http://llvm.org/viewvc/llvm-project?rev=114392&view=rev
Log:
Check for null ObjCInterfaceDecls returned from getClassInterface() when generating USRs.  While I have no test case for this (could not create one), this shows up in crash reports.  Tentatively fixes <rdar://problem/8452791>.

Modified:
    cfe/trunk/tools/libclang/CIndexUSRs.cpp

Modified: cfe/trunk/tools/libclang/CIndexUSRs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexUSRs.cpp?rev=114392&r1=114391&r2=114392&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndexUSRs.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexUSRs.cpp Mon Sep 20 23:45:46 2010
@@ -286,10 +286,17 @@
   do {
     if (ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(container))
       if (CD->IsClassExtension()) {
-        Visit(CD->getClassInterface());
-        break;
-      }    
-    Visit(cast<Decl>(D->getDeclContext()));
+        // ID can be null with invalid code.
+        if (ObjCInterfaceDecl *ID = CD->getClassInterface()) {
+          Visit(ID);
+	  break;
+        }
+        // Invalid code.  Can't generate USR.
+        IgnoreResults = true;
+        return;
+      }
+
+    Visit(container);
   }
   while (false);
   





More information about the cfe-commits mailing list