зеркало из https://github.com/microsoft/clang-1.git
Fix <rdar://problem/6877235> Classes typedef-ed to CF objects should get the same treatment as CF objects
This was accomplished by having 'isTypeRef' recursively walk the typedef stack. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71538 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
b64c19365d
Коммит
6738b731a6
|
@ -225,9 +225,17 @@ static bool hasSuffix(const char* s, const char* suffix) {
|
||||||
static bool isRefType(QualType RetTy, const char* prefix,
|
static bool isRefType(QualType RetTy, const char* prefix,
|
||||||
ASTContext* Ctx = 0, const char* name = 0) {
|
ASTContext* Ctx = 0, const char* name = 0) {
|
||||||
|
|
||||||
if (TypedefType* TD = dyn_cast<TypedefType>(RetTy.getTypePtr())) {
|
// Recursively walk the typedef stack, allowing typedefs of reference types.
|
||||||
const char* TDName = TD->getDecl()->getIdentifier()->getName();
|
while (1) {
|
||||||
return hasPrefix(TDName, prefix) && hasSuffix(TDName, "Ref");
|
if (TypedefType* TD = dyn_cast<TypedefType>(RetTy.getTypePtr())) {
|
||||||
|
const char* TDName = TD->getDecl()->getIdentifier()->getName();
|
||||||
|
if (hasPrefix(TDName, prefix) && hasSuffix(TDName, "Ref"))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
RetTy = TD->getDecl()->getUnderlyingType();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Ctx || !name)
|
if (!Ctx || !name)
|
||||||
|
|
|
@ -528,6 +528,27 @@ void rdar_6866843() {
|
||||||
[pool drain];
|
[pool drain];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
// <rdar://problem/6877235> Classes typedef-ed to CF objects should get the same treatment as CF objects
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
typedef CFTypeRef OtherRef;
|
||||||
|
|
||||||
|
@interface RDar6877235 : NSObject {}
|
||||||
|
- (CFTypeRef)_copyCFTypeRef;
|
||||||
|
- (OtherRef)_copyOtherRef;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation RDar6877235
|
||||||
|
- (CFTypeRef)_copyCFTypeRef {
|
||||||
|
return [[NSString alloc] init]; // no-warning
|
||||||
|
}
|
||||||
|
- (OtherRef)_copyOtherRef {
|
||||||
|
return [[NSString alloc] init]; // no-warning
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Tests of ownership attributes.
|
// Tests of ownership attributes.
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
Загрузка…
Ссылка в новой задаче