diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-02-04 23:42:48 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-02-04 23:42:48 +0000 |
commit | 0c8a172911f9e8029d77511dbe59c810fb46ea14 (patch) | |
tree | b17aa3af6c54ba0bc0025f6af261ba5a9616626f | |
parent | 27dfb1e1a4e6d3c36e0ade15792dbd1487c7a931 (diff) | |
download | bcm5719-llvm-0c8a172911f9e8029d77511dbe59c810fb46ea14.tar.gz bcm5719-llvm-0c8a172911f9e8029d77511dbe59c810fb46ea14.zip |
Fix a crash with ill-formed code within a method in an ill-formed
category implementation, which showed up during (attempted) typo
correction. Fixes <rdar://problem/7605289>.
llvm-svn: 95334
-rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 9 | ||||
-rw-r--r-- | clang/test/FixIt/typo-crash.m | 6 | ||||
-rw-r--r-- | clang/test/FixIt/typo.m | 2 |
3 files changed, 13 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index c4b261fad44..af1b8a276ef 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -2027,6 +2027,9 @@ static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, bool InBaseClass, VisibleDeclConsumer &Consumer, VisibleDeclsRecord &Visited) { + if (!Ctx) + return; + // Make sure we don't visit the same context twice. if (Visited.visitedContext(Ctx->getPrimaryContext())) return; @@ -2183,9 +2186,9 @@ static void LookupVisibleDecls(Scope *S, LookupResult &Result, // For instance methods, look for ivars in the method's interface. LookupResult IvarResult(Result.getSema(), Result.getLookupName(), Result.getNameLoc(), Sema::LookupMemberName); - ObjCInterfaceDecl *IFace = Method->getClassInterface(); - LookupVisibleDecls(IFace, IvarResult, /*QualifiedNameLookup=*/false, - /*InBaseClass=*/false, Consumer, Visited); + if (ObjCInterfaceDecl *IFace = Method->getClassInterface()) + LookupVisibleDecls(IFace, IvarResult, /*QualifiedNameLookup=*/false, + /*InBaseClass=*/false, Consumer, Visited); } // We've already performed all of the name lookup that we need diff --git a/clang/test/FixIt/typo-crash.m b/clang/test/FixIt/typo-crash.m new file mode 100644 index 00000000000..f10fe61ae78 --- /dev/null +++ b/clang/test/FixIt/typo-crash.m @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// <rdar://problem/7605289> +@implementation Unknown (Blarg) // expected-error{{cannot find interface declaration for 'Unknown'}} +- (int)method { return ivar; } // expected-error{{use of undeclared identifier 'ivar'}} +@end diff --git a/clang/test/FixIt/typo.m b/clang/test/FixIt/typo.m index c2069dd4169..86dd383c904 100644 --- a/clang/test/FixIt/typo.m +++ b/clang/test/FixIt/typo.m @@ -86,5 +86,5 @@ void test2(Collide *a) { - (int)send:(void*)buffer bytes:(int)bytes; @end -@interface IPv8 <Network_Socket> // expected-error{{cannot find protocol declaration for 'Network_Socket'; did you mean 'NetworkSocket'?}} +@interface IPv6 <Network_Socket> // expected-error{{cannot find protocol declaration for 'Network_Socket'; did you mean 'NetworkSocket'?}} @end |