]> granicus.if.org Git - clang/commitdiff
ObjectiveC migrator. Do not infer NS_RETURNS_INNER_POINTER
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 9 Sep 2013 23:56:14 +0000 (23:56 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 9 Sep 2013 23:56:14 +0000 (23:56 +0000)
annotation on methods which return typedef of pointer to
an incomplete struct type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190372 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ARCMigrate/ObjCMT.cpp
test/ARCMT/objcmt-ns-returns-inner-pointer.m
test/ARCMT/objcmt-ns-returns-inner-pointer.m.result

index 702149e018eeed8c1f22f2e4ad7c2f8cf9af9c46..f91741abf894f957f9c696bed1671ef9bbd0a2ba 100644 (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;
 }
 
index f1a57bde962feecccaf2c06ec581137d6ced16f8..404928398fe59a12ce0711a8312cf37df08fc23a 100644 (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
index 40d4f66356fc92823ccc1c31340d4d0a10c9a5de..c3f151ab2231cd93f46a894df392de3d4615f5fe 100644 (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