Skip to content

Commit 745ab81

Browse files
committed
Check that the method ObjCMessageExpr references isn't null before
passing it to diagnoseDeclFeatureAvailability rdar://146139827
1 parent e5e6004 commit 745ab81

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

clang/lib/Sema/SemaFeatureAvailability.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ class DiagnoseUnguardedFeatureAvailability
7878
}
7979

8080
bool VisitObjCMessageExpr(ObjCMessageExpr *OME) {
81-
diagnoseDeclFeatureAvailability(OME->getMethodDecl(), OME->getBeginLoc());
81+
if (auto *MD = OME->getMethodDecl())
82+
diagnoseDeclFeatureAvailability(MD, OME->getBeginLoc());
8283
return true;
8384
}
8485

clang/test/SemaObjC/feature-availability.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ @interface Derived3 : Base7<Base0 *> // expected-error {{use of 'Base0' requires
6262
@end
6363

6464
__attribute__((availability(domain:feature1, AVAIL))) // expected-note {{is incompatible with __attribute__((availability(domain:feature1, 0)))}} expected-note 2 {{feature attribute __attribute__((availability(domain:feature1, 0)))}}
65-
@interface Derived0 : Base0 {
65+
@interface Derived0 : Base0 { // expected-note {{receiver is instance of class declared here}}
6666
struct S1 *ivar4;
6767
}
6868
@property struct S1 *p0;
@@ -81,6 +81,7 @@ -(void)m0 {
8181
}
8282
-(void)m1 {
8383
self.p1 = 1;
84+
[self nonexistentMethod]; // expected-warning {{instance method '-nonexistentMethod' not found (return type defaults to 'id')}}
8485
}
8586
@end
8687

0 commit comments

Comments
 (0)