aboutsummaryrefslogtreecommitdiff
path: root/tools/libclang/CIndexUSRs.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-09-21 04:45:46 +0000
committerTed Kremenek <kremenek@apple.com>2010-09-21 04:45:46 +0000
commitc52d069277c58009a6c91a66d2f0754299f1acde (patch)
tree1a0fd9bd1c73a5de1c8a97658885c79ac10a5cf3 /tools/libclang/CIndexUSRs.cpp
parent2e81caa14337cfa8973a1a073ef4dbbb8273238c (diff)
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>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114392 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/libclang/CIndexUSRs.cpp')
-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);