erichkeane added a comment.

In D151365#4369650 <https://reviews.llvm.org/D151365#4369650>, @HerrCai0907 
wrote:

> In D151365#4369605 <https://reviews.llvm.org/D151365#4369605>, @erichkeane 
> wrote:
>
>> As Richard says, we should just be taking the first parameter type and using 
>> that instead (obviously de-qualified and removing reference if necessary).
>
> But we still can find the correct RecordDecl by `redecls`.

That ends up being an absurdly larger amount of work, and in the case of a 
'friend' declaration can result in the wrong answer, correct?  Consider 
something like:

  struct Foo;
  
  struct Bar {
      friend bool operator==(const Foo&, const Foo&);
  };
  
  struct Foo {
      friend bool operator==(const Foo&, const Foo&);
  };
  
  bool operator==(const Foo&, const Foo&) = default;

or even:

  struct Foo {
      bool operator==(const Foo&) const;
  };
  
  struct Bar {
      friend bool Foo::operator==(const Foo&) const;
  };
  
  
  bool operator==(Foo, Foo) = default;

In the 1st one, the lexical context could be 'Bar'.  Searching 'redecls' will 
end up with the 'first one first', so at least the 2nd example isn't as 
problematic, but I'm sure someone more clever than I could come up with a case 
where that could be declared in a different order.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151365

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

Reply via email to