code when we are printing the name of an Objective-C method
whose class has not been declared. Fixes <rdar://problem/
7495713>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98874
91177308-0d34-0410-b5e6-
96231b3b80d8
llvm::raw_svector_ostream Out(Name);
Out << (MD->isInstanceMethod() ? '-' : '+');
Out << '[';
- Out << MD->getClassInterface()->getNameAsString();
+
+ // For incorrect code, there might not be an ObjCInterfaceDecl. Do
+ // a null check to avoid a crash.
+ if (const ObjCInterfaceDecl *ID = MD->getClassInterface())
+ Out << ID->getNameAsString();
+
if (const ObjCCategoryImplDecl *CID =
dyn_cast<ObjCCategoryImplDecl>(MD->getDeclContext())) {
Out << '(';
void *p = @1; // expected-error {{unexpected '@' in program}}
}
+// <rdar://problem/7495713>
+// This previously triggered a crash because the class has not been defined.
+@implementation RDar7495713 (rdar_7495713_cat) // expected-error{{cannot find interface declaration for 'RDar7495713'}}
+- (id) rdar_7495713 {
+ __PRETTY_FUNCTION__; // expected-warning{{expression result unused}}
+}
+@end