]> granicus.if.org Git - clang/commitdiff
Objective-C. Recover from missing interface decl.
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 21 Aug 2014 17:06:57 +0000 (17:06 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 21 Aug 2014 17:06:57 +0000 (17:06 +0000)
and checking on availability of method declaration
instead of crashing. // rdar://18059669

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216191 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/SemaObjC/attr-availability.m

index b3e92d765fd38ba6bfcb85306c84996f7e4283ca..c8c381518b19a7faa56c8f1981577ff5674e3b7f 100644 (file)
@@ -13634,5 +13634,6 @@ AvailabilityResult Sema::getCurContextAvailability() const {
             dyn_cast<ObjCImplementationDecl>(D)) {
     D = ID->getClassInterface();
   }
-  return D->getAvailability();
+  // Recover from user error.
+  return D ? D->getAvailability() : AR_Available;
 }
index 7990b1202e8ffac705111e991fe8b6363e2df274..c455bc7acce62e619cb9076e0cc6c8c2188aa515 100644 (file)
@@ -60,3 +60,30 @@ void f(A *a, B *b) {
 }
 @end
 
+// rdar://18059669
+@class NSMutableArray;
+
+@interface NSDictionary
++ (instancetype)dictionaryWithObjectsAndKeys:(id)firstObject, ... __attribute__((sentinel(0,1)));
+@end
+
+@class NSString;
+
+extern NSString *NSNibTopLevelObjects __attribute__((availability(macosx,introduced=10.0 ,deprecated=10.8,message="" )));
+id NSNibOwner, topNibObjects;
+
+@interface AppDelegate (SIEImport) // expected-error {{cannot find interface declaration for 'AppDelegate'}}
+
+-(void)__attribute__((ibaction))importFromSIE:(id)sender;
+
+@end
+
+@implementation AppDelegate (SIEImport) // expected-error {{cannot find interface declaration for 'AppDelegate'}}
+
+-(void)__attribute__((ibaction))importFromSIE:(id)sender {
+
+ NSMutableArray *topNibObjects;
+ NSDictionary *nibLoadDict = [NSDictionary dictionaryWithObjectsAndKeys:self, NSNibOwner, topNibObjects, NSNibTopLevelObjects, ((void *)0)];
+}
+
+@end