HomePhabricator

Pass the correct object argument when a member call to an 'unrelated' class is…

Description

Pass the correct object argument when a member call to an 'unrelated' class is made.

Prior to this patch, clang would do the wrong thing here (see inline comments for pre-patch behavior):

struct A {
  void bar(int) { }
  static void bar(double) { }
  
  void g(int*);
  static void g(char *);
};


struct B {
  void f() {
    A::bar(3);  // selects (double) ??!!
    A::g((int*)0); // Instead of no object argument, states conversion error?!!
  }
};

The fix is as follows: When we detect that what appears to be an implicit member function call (A::bar) is actually a call to a member of a class (A) unrelated to the type (B) that contains the member function (B::f) from which the call is being made, don't treat it (A::bar) as an Implicit Member Call Expression.

P.S. I wonder if there is an existing bug report related to this? (Surprisingly, a cursory search did not find one).

Details

Committed
faisalvAug 26 2017, 7:21 PM
Parents
rL311838: [NewGVN] Use `auto` when the type is obvious NFCI.
Branches
Unknown
Tags
Unknown