aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/libclang/CIndexUSRs.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/tools/libclang/CIndexUSRs.cpp b/tools/libclang/CIndexUSRs.cpp
index 554165754a..4f23e59ec2 100644
--- a/tools/libclang/CIndexUSRs.cpp
+++ b/tools/libclang/CIndexUSRs.cpp
@@ -286,10 +286,17 @@ void USRGenerator::VisitObjCMethodDecl(ObjCMethodDecl *D) {
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);