New issue
Advanced search Search tips

Issue 640016 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Nov 2016
Cc:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug

Blocking:
issue 578344



Sign in to add a comment

rewrite_to_chrome_style: handle UnresolvedUsingValueDecl renaming

Project Member Reported by lukasza@chromium.org, Aug 22 2016

Issue description

In wtf/Vector.h, declaration of |m_size| in VectorBufferBase gets rewritten to |size_| (so far so good), but references to this field do not always get rewritten - for example:

    Vector(size_t size, const T& val)
        : Base(size)
    {
        ANNOTATE_NEW_BUFFER(begin(), Capacity(), size);
        m_size = size;
        TypeOperations::uninitializedFill(begin(), end(), val);
    }
 
I think I have a small repro:

    template <typename T>
    class BaseClass {
     public:
      unsigned long m_size;
    };

    template <typename T>
    class DerivedClass : protected BaseClass<T> {
     private:
      using Base = BaseClass<T>;
      using Base::m_size;
      void method() {
        m_size = 123;  // <- |m_size| should get rewritten to |size_|.
      }
    };

And it seems that the trouble comes from UnresolvedMemberExpr:

      `-CXXMethodDecl 0x5c7ced0 <line:138:3, line:140:3> line:138:8 method 'void (void)'
        `-CompoundStmt 0x5c7d028 <col:17, line:140:3>
          `-BinaryOperator 0x5c7d000 <line:139:5, col:14> '<dependent type>' '='
            |-UnresolvedMemberExpr 0x5c7cf78 <col:5> '<dependent type>' lvalue
            `-IntegerLiteral 0x5c7cfe0 <col:14> 'int' 123

It seems to me that the problem is that ...

      unresolvedMemberExpr(
          allOverloadsMatch(
              anyOf(method_decl_matcher, method_template_decl_matcher)))));

... only matches methods and in our case, |allOverloadsMatch| iterates only over one candidate: UnresolvedUsingValueDecl ... Base::m_size ...

I am trying to figure out which inner matcher I can use to match UnresolvedUsingValueDecl (+ bind the "decl" id to the right decl).

Cc: lukasza@chromium.org
 Issue 640338  has been merged into this issue.
Summary: rewrite_to_chrome_style: handle UnresolvedUsingValueDecl renaming (was: rewrite_to_chrome_style: m_size -> size_ rewrite doesn't happen everywhere)
Status: Fixed (was: Started)

Sign in to add a comment