[PATCH] D146178: [Clang][Sema] Fix comparison of constraint expressions

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 10 10:07:03 PDT 2023


erichkeane added inline comments.


================
Comment at: clang/lib/Sema/SemaConcept.cpp:773
+  // ConstrExpr for the inner template will properly adjust the depths.
+  if (isa<CXXRecordDecl>(ND) && isa<CXXRecordDecl>(OtherND))
+    ForConstraintInstantiation = true;
----------------
alexander-shaposhnikov wrote:
> erichkeane wrote:
> > Hmm... this seems really strange to have to do. `ForConstraintInstantiation` shouldn't be used here, the point of that is to make sure we 'keep looking upward' once we hit a spot we normally stop with.  What exactly is the issue that you end up running into here?  Perhaps I can spend some time debugging what we should really be doign.
> yeah, I agree. I haven't found a proper solution or at least a better workaround (but would be happy to).
> This kicks in for the case 
> 
> ```
> template <class T0>
> concept Constraint = true;
> 
> 
> template<Constraint T1>
> struct Iterator {
>     template <Constraint T2>
>     friend class Iterator;
>     void operator*();
> };
> 
> Iterator<char*> I2;
> ```
> yeah, I agree. I haven't found a proper solution or at least a better workaround (but would be happy to).
> This kicks in for the case 
> 
> ```
> template <class T0>
> concept Constraint = true;
> 
> 
> template<Constraint T1>
> struct Iterator {
>     template <Constraint T2>
>     friend class Iterator;
>     void operator*();
> };
> 
> Iterator<char*> I2;
> ```

Alright, well, I should have time later in the week to poke at this, perhaps I can come up with something better?  I DO remember self-friend is a little wacky, and I spent a bunch of time on it last time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146178



More information about the cfe-commits mailing list