[PATCH] D23080: ObjC: Use a new type for ObjC type parameter (patch 3 out of 3)

Doug Gregor via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 19 16:39:14 PDT 2016


doug.gregor requested changes to this revision.
doug.gregor added a comment.
This revision now requires changes to proceed.

I think most of the complexity here will fold away when ObjCTypeParamType becomes sugar for the underlying ObjCObjectPointerType.


================
Comment at: lib/AST/Type.cpp:1095
@@ +1094,3 @@
+            return ctx.getQualifiedType(argType, splitType.Quals);
+          // Apply protocol lists if exists. Should we combine protocol list?
+          if (const auto *objcPtr = dyn_cast<ObjCObjectPointerType>(argType)) {
----------------
I think we should combine the protocol lists.

================
Comment at: lib/AST/Type.cpp:1290
@@ +1289,3 @@
+/// in @implementation. @implementation does not take type parameters.
+QualType QualType::handleObjCTypeParamType(ASTContext &ctx) const {
+  return simpleTransform(ctx, *this,
----------------
I think you won't need this if you take the approach I suggested on the previous patch of making ObjCTypeParamType type sugar for, effectively, the type you're computing here.

================
Comment at: lib/Sema/SemaExprObjC.cpp:388
@@ +387,3 @@
+  if (auto *TPT = T->getAs<ObjCTypeParamType>())
+    T = TPT->getDecl()->getUnderlyingType();
+
----------------
Dropping protocol qualifiers here? Again, I think this would be solved by treating ObjCTypeParamType as sugar.

================
Comment at: lib/Sema/SemaExprObjC.cpp:824
@@ -820,1 +823,3 @@
+        (!isa<ObjCTypeParamType>(PtrT->getPointeeType()) &&
+         !Context.hasSameUnqualifiedType(PtrT->getPointeeType(), IdT))) {
       Diag(SR.getBegin(), diag::err_objc_literal_method_sig)
----------------
Also unnecessary w/ the desugaring approach?

================
Comment at: lib/Sema/SemaType.cpp:901
@@ -900,2 +900,3 @@
     // Objective-C object pointer types must be substitutable for the bounds.
-    if (const auto *typeArgObjC = typeArg->getAs<ObjCObjectPointerType>()) {
+    if (typeArg->getAs<ObjCObjectPointerType>() ||
+        isa<ObjCTypeParamType>(typeArg)) {
----------------
... same comment about desugaring.

================
Comment at: lib/Sema/SemaType.cpp:917
@@ +916,3 @@
+      const ObjCObjectPointerType *typeArgObjC = nullptr;
+      if (isa<ObjCTypeParamType>(typeArg)) {
+        typeArgObjC = typeArg->getAs<ObjCTypeParamType>()->getDecl()->
----------------
Here too :)

================
Comment at: lib/Sema/SemaType.cpp:3397
@@ -3365,2 +3396,3 @@
     // Look at Objective-C object pointers.
-    if (auto objcObjectPtr = type->getAs<ObjCObjectPointerType>()) {
+    if (type->getAs<ObjCObjectPointerType>() ||
+        isa<ObjCTypeParamType>(type)) {
----------------
... same comment about desugaring.

================
Comment at: lib/StaticAnalyzer/Core/CallEvent.cpp:63
@@ -62,2 +62,3 @@
 
-  if (T->isAnyPointerType() || T->isReferenceType())
+  if ((T->isAnyPointerType() && !isa<ObjCTypeParamType>(T)) ||
+      T->isReferenceType())
----------------
... same comment about desugaring.

================
Comment at: lib/StaticAnalyzer/Core/CallEvent.cpp:133
@@ -131,1 +132,3 @@
 static bool isPointerToConst(QualType Ty) {
+  if (isa<ObjCTypeParamType>(Ty))
+    return false;
----------------
... same comment about desugaring.


https://reviews.llvm.org/D23080





More information about the cfe-commits mailing list