vsapsai added a comment.

Found a use case where `getCanonicalType()` causes problems:

  @interface NSObject
  @end
  
  @protocol SomeProtocol
  @end
  
  @interface NSString : NSObject
  @end
  @interface NSNumber : NSObject
  @end
  
  @interface Container<T : NSString *>
  @end
  
  @interface Container<T> (extension)
  T FunctionInExtension(void);
  @end
  
  void test(Container *c) {
    NSNumber *n = FunctionInExtension();
  }

In this case we don't warn about `NSNumber`/`NSString` mismatch but should. At 
line 8125 
<https://github.com/llvm/llvm-project/blob/f0c4e70e95d94f1d585058c5ad18098e5924d06d/clang/lib/Sema/SemaExpr.cpp#L8125>
 in `Sema::CheckAssignmentConstraints` we get a canonical type for the 
right-hand side and it turned out to be `id`, which is compatible with 
`NSNumber`.

I believe it's a separate issue and the currently proposed change is correct 
but insufficient. Prior to using `ObjCTypeParamType` for generic parameters, we 
were using `TypedefType` and I think we need to make `ObjCTypeParamType` like 
`TypedefType` in more places.


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

https://reviews.llvm.org/D66696



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to