[PATCH] D107275: [Sema] a[x] has type T when a has type T* or T[], even when T is dependent
    Sam McCall via Phabricator via cfe-commits 
    cfe-commits at lists.llvm.org
       
    Mon Aug  2 07:04:42 PDT 2021
    
    
  
sammccall added a comment.
@rsmith: we have two open questions here...
---
1: Expressions whose types are no longer dependent.
In the rare case where RHS is type-dependent and LHS is a known pointer, e.g.
  template <typename Idx>
  int access(int *arr, Idx i) {
    return arr[i];
  }
we're now changing the ArraySubscriptExpr's type from DependentTy to int, while keeping the expr type-dependent.
Is this OK, or should we avoid it by artificially requiring LHS specifically to be type-dependent to do the refinement?
---
2: LHS vs RHS symmetry.
We only bother to check if **LHS** is a pointer, so `type_dependent_pointer[integer]` gets a specific dependent type, while the obscure `integer[type_dependent_pointer]` remains DependentTy.
Is this OK, or must we handle the rare case in the same way?
---
Functionally, doing the "safe" thing in both cases seems fine. But I don't want to spray unnecessary defensive code around, for maintenance reasons.
Repository:
  rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107275/new/
https://reviews.llvm.org/D107275
    
    
More information about the cfe-commits
mailing list