mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-03 07:38:57 +00:00
acf4fd3039
A 'readonly' Objective-C property declared in the primary class can effectively be shadowed by a 'readwrite' property declared within an extension of that class, so long as the types and attributes of the two property declarations are compatible. Previously, this functionality was implemented by back-patching the original 'readonly' property to make it 'readwrite', destroying source information and causing some hideously redundant, incorrect code. Simplify the implementation to express how this should actually be modeled: as a separate property declaration in the extension that shadows (via the name lookup rules) the declaration in the primary class. While here, correct some broken Fix-Its, eliminate a pile of redundant code, clean up the ARC migrator's handling of properties declared in extensions, and fix debug info's naming of methods that come from categories. A wonderous side effect of doing this write is that it eliminates the "AddedObjCPropertyInClassExtension" method from the AST mutation listener, which in turn eliminates the last place where we rewrite entire declarations in a chained PCH file or a module file. This change (which fixes rdar://problem/18475765) will allow us to eliminate the rewritten-decls logic from the serialization library, and fixes a crash (rdar://problem/23247794) illustrated by the test/PCH/chain-categories.m example. llvm-svn: 251874
67 lines
1.4 KiB
Objective-C
67 lines
1.4 KiB
Objective-C
// Without PCH
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -include %s -include %s %s
|
|
|
|
// With PCH
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s -chain-include %s -chain-include %s
|
|
|
|
// expected-no-diagnostics
|
|
|
|
#ifndef HEADER1
|
|
#define HEADER1
|
|
//===----------------------------------------------------------------------===//
|
|
// Primary header
|
|
|
|
@interface NSObject
|
|
- (id)init;
|
|
- (void)finalize;
|
|
@end
|
|
|
|
@interface NSObject (Properties)
|
|
@property (readonly,nonatomic) int intProp;
|
|
@end
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
#elif !defined(HEADER2)
|
|
#define HEADER2
|
|
#if !defined(HEADER1)
|
|
#error Header inclusion order messed up
|
|
#endif
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// Dependent header
|
|
|
|
@interface MyClass : NSObject
|
|
+(void)meth;
|
|
@end
|
|
|
|
@interface NSObject(ObjExt)
|
|
-(void)extMeth;
|
|
@end
|
|
|
|
@interface NSObject ()
|
|
@property (readwrite,nonatomic) int intProp;
|
|
@end
|
|
|
|
@class NSObject;
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
#else
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
@implementation MyClass
|
|
+(void)meth {}
|
|
-(void)finalize {
|
|
[super finalize];
|
|
}
|
|
@end
|
|
|
|
void test(NSObject *o) {
|
|
[o extMeth];
|
|
|
|
// Make sure the property is treated as read-write.
|
|
o.intProp = 17;
|
|
}
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
#endif
|