From c2eb0116ccab71ac4ba3f65bffb547616bcf00e7 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Tue, 21 Sep 2010 04:45:46 +0000 Subject: 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 . llvm-svn: 114392 --- clang/tools/libclang/CIndexUSRs.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'clang/tools/libclang/CIndexUSRs.cpp') diff --git a/clang/tools/libclang/CIndexUSRs.cpp b/clang/tools/libclang/CIndexUSRs.cpp index 554165754ac..4f23e59ec20 100644 --- a/clang/tools/libclang/CIndexUSRs.cpp +++ b/clang/tools/libclang/CIndexUSRs.cpp @@ -286,10 +286,17 @@ void USRGenerator::VisitObjCMethodDecl(ObjCMethodDecl *D) { do { if (ObjCCategoryDecl *CD = dyn_cast(container)) if (CD->IsClassExtension()) { - Visit(CD->getClassInterface()); - break; - } - Visit(cast(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); -- cgit v1.2.3