[PATCH] D57075: [ObjC] For type substitution in generics use a regular recursive type visitor.

Volodymyr Sapsai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 24 16:48:39 PST 2019


vsapsai planned changes to this revision.
vsapsai added inline comments.


================
Comment at: clang/lib/AST/Type.cpp:1295
+
+  QualType VisitObjCObjectType(const ObjCObjectType *objType) {
+    if (!objType->isKindOfType())
----------------
erik.pilkington wrote:
> Does this works with type sugar? i.e. previously calling `Ty->getAs<ObjCObjectType>()` would have stripped through `TypedefType`, but its not obvious to me that this traversal is doing the right thing for that case.
You are right, great catch. And I have a test case to confirm that.

I've started this refactoring to avoid copy-pasting

```lang=c++
    QualType modifiedType = recurse(T->getModifiedType());
    if (modifiedType.isNull())
      return {};

    QualType equivalentType = recurse(T->getEquivalentType());
    if (equivalentType.isNull())
      return {};

    if (modifiedType.getAsOpaquePtr()
          == T->getModifiedType().getAsOpaquePtr() &&
        equivalentType.getAsOpaquePtr()
          == T->getEquivalentType().getAsOpaquePtr())
      return QualType(T, 0);
```

and use `BaseType::VisitAttributedType(attrType)` instead. I think it is possible to achieve the previous behaviour with the traditional recursive visitor. But ideas that I have are pretty complicated and I don't think that's the right trade-off.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57075/new/

https://reviews.llvm.org/D57075





More information about the cfe-commits mailing list