summaryrefslogtreecommitdiffstats
path: root/clang/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
commitc2eb0116ccab71ac4ba3f65bffb547616bcf00e7 (patch)
treef49e054279230ea75dfa85bc25b90d163822bb2e /clang/tools/libclang/CIndexUSRs.cpp
parente3d864b85799e40d751f43fb5aec6c4872f6b94f (diff)
downloadbcm5719-llvm-c2eb0116ccab71ac4ba3f65bffb547616bcf00e7.tar.gz
bcm5719-llvm-c2eb0116ccab71ac4ba3f65bffb547616bcf00e7.zip
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>.
llvm-svn: 114392
Diffstat (limited to 'clang/tools/libclang/CIndexUSRs.cpp')
-rw-r--r--clang/tools/libclang/CIndexUSRs.cpp15
1 files changed, 11 insertions, 4 deletions
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<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);
OpenPOWER on IntegriCloud