r190372 - ObjectiveC migrator. Do not infer NS_RETURNS_INNER_POINTER
Fariborz Jahanian
fjahanian at apple.com
Mon Sep 9 16:56:14 PDT 2013
Author: fjahanian
Date: Mon Sep 9 18:56:14 2013
New Revision: 190372
URL: http://llvm.org/viewvc/llvm-project?rev=190372&view=rev
Log:
ObjectiveC migrator. Do not infer NS_RETURNS_INNER_POINTER
annotation on methods which return typedef of pointer to
an incomplete struct type.
Modified:
cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
cfe/trunk/test/ARCMT/objcmt-ns-returns-inner-pointer.m
cfe/trunk/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result
Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=190372&r1=190371&r2=190372&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Mon Sep 9 18:56:14 2013
@@ -694,6 +694,20 @@ static bool TypeIsInnerPointer(QualType
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;
}
Modified: cfe/trunk/test/ARCMT/objcmt-ns-returns-inner-pointer.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-ns-returns-inner-pointer.m?rev=190372&r1=190371&r2=190372&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-ns-returns-inner-pointer.m (original)
+++ cfe/trunk/test/ARCMT/objcmt-ns-returns-inner-pointer.m Mon Sep 9 18:56:14 2013
@@ -75,6 +75,10 @@ typedef struct __CFDictionary * CFMutabl
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
+
+ at interface JS
+- (JSObjectRef)JSObject;
+- (TTJSObjectRef)JSObject1;
+- (JSObjectRef*)JSObject2;
+ at end
Modified: cfe/trunk/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result?rev=190372&r1=190371&r2=190372&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result (original)
+++ cfe/trunk/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result Mon Sep 9 18:56:14 2013
@@ -75,6 +75,10 @@ typedef struct __CFDictionary * CFMutabl
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
+
+ at interface JS
+- (JSObjectRef)JSObject;
+- (TTJSObjectRef)JSObject1;
+- (JSObjectRef*)JSObject2 NS_RETURNS_INNER_POINTER;
+ at end
More information about the cfe-commits
mailing list