ObjectiveC migrator. Do not infer NS_RETURNS_INNER_POINTER

annotation on methods which return typedef of pointer to 
an incomplete struct type.

llvm-svn: 190372
This commit is contained in:
Fariborz Jahanian 2013-09-09 23:56:14 +00:00
parent 9735f1a06b
commit 9d5fffb425
3 changed files with 34 additions and 0 deletions

View File

@ -694,6 +694,20 @@ static bool TypeIsInnerPointer(QualType T) {
if (T->isObjCObjectPointerType() || T->isObjCBuiltinType() ||
T->isBlockPointerType() || ento::coreFoundation::isCFObjectRef(T))
return false;
// Also, typedef-of-pointer-to-incomplete-struct is something that we assume
// is not an innter pointer type.
QualType OrigT = T;
while (const TypedefType *TD = dyn_cast<TypedefType>(T.getTypePtr()))
T = TD->getDecl()->getUnderlyingType();
if (OrigT == T || !T->isPointerType())
return true;
const PointerType* PT = T->getAs<PointerType>();
QualType UPointeeT = PT->getPointeeType().getUnqualifiedType();
if (UPointeeT->isRecordType()) {
const RecordType *RecordTy = UPointeeT->getAs<RecordType>();
if (!RecordTy->getDecl()->isCompleteDefinition())
return false;
}
return true;
}

View File

@ -75,6 +75,10 @@ typedef struct __CFDictionary * CFMutableDictionaryRef;
typedef struct CGImage *CGImageRef;
typedef struct OpaqueJSValue* JSObjectRef;
typedef JSObjectRef TTJSObjectRef;
CF_IMPLICIT_BRIDGING_DISABLED
@interface I
@ -94,3 +98,9 @@ CF_IMPLICIT_BRIDGING_DISABLED
@interface NSMutableData
- (void *)mutableBytes __attribute__((deprecated)) __attribute__((unavailable));
@end
@interface JS
- (JSObjectRef)JSObject;
- (TTJSObjectRef)JSObject1;
- (JSObjectRef*)JSObject2;
@end

View File

@ -75,6 +75,10 @@ typedef struct __CFDictionary * CFMutableDictionaryRef;
typedef struct CGImage *CGImageRef;
typedef struct OpaqueJSValue* JSObjectRef;
typedef JSObjectRef TTJSObjectRef;
CF_IMPLICIT_BRIDGING_DISABLED
@interface I
@ -94,3 +98,9 @@ CF_IMPLICIT_BRIDGING_DISABLED
@interface NSMutableData
- (void *)mutableBytes __attribute__((deprecated)) __attribute__((unavailable)) NS_RETURNS_INNER_POINTER;
@end
@interface JS
- (JSObjectRef)JSObject;
- (TTJSObjectRef)JSObject1;
- (JSObjectRef*)JSObject2 NS_RETURNS_INNER_POINTER;
@end