summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/ARCMigrate/ObjCMT.cpp14
-rw-r--r--clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m10
-rw-r--r--clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result10
3 files changed, 34 insertions, 0 deletions
diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp
index 702149e018e..f91741abf89 100644
--- a/clang/lib/ARCMigrate/ObjCMT.cpp
+++ b/clang/lib/ARCMigrate/ObjCMT.cpp
@@ -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;
}
diff --git a/clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m b/clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m
index f1a57bde962..404928398fe 100644
--- a/clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m
+++ b/clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m
@@ -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
diff --git a/clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result b/clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result
index 40d4f66356f..c3f151ab223 100644
--- a/clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result
+++ b/clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result
@@ -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
OpenPOWER on IntegriCloud