[llvm-bugs] [Bug 44566] New: AST creates CXXDependentScopeMemberExpr when Expr isnt dependent

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jan 16 03:26:28 PST 2020


            Bug ID: 44566
           Summary: AST creates CXXDependentScopeMemberExpr when Expr isnt
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: N.James93 at hotmail.co.uk
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Take this class

>#include <utility>
>template <class T>
>class C {
>  int _A;
> public:
>  C& operator=(const C& Other){
>      this->_A = Other._A;
>      return *this;
>  }
>  C& operator==(C&& Other){
>      _A = std::move(Other._A);
>      return *this;
>  }

The AST for the copy assignment '=' line is 
BinaryOperator <line:8:7, col:24> '<dependent type>' '='
|-CXXDependentScopeMemberExpr <col:7, col:13> '<dependent type>' lvalue ->_A
| -CXXThisExpr <col:7> 'C<T> *' this
|-CXXDependentScopeMemberExpr <col:18, col:24> '<dependent type>' lvalue ._A
| -DeclRefExpr <col:18> 'const C<T>' lvalue ParmVar 0x555e4f6cc108 'Other'
'const C<T> &'

Likewise the move assignment '=' line is 
BinaryOperator <line:12:7, col:30> '<dependent type>' '='
|-MemberExpr <col:7> 'int' lvalue ->_A 0x555e4f6cc058
| -CXXThisExpr <col:7> 'C<T> *' implicit this
|-CallExpr <col:12, col:30> '<dependent type>'
| -UnresolvedLookupExpr <col:12, col:17> '<overloaded function type>' lvalue
(no ADL) = 'move' 0x555e4f65b538
|  -CXXDependentScopeMemberExpr <col:22, col:28> '<dependent type>' lvalue ._A
|   -DeclRefExpr <col:22> 'C<T>' lvalue ParmVar 0x555e4f6cc308 'Other' 'C<T>

The AST only prints out a MemberExpr for the implicit this (in the move
The explicit this (in the copy assignment) should never be a
Likewise in this example as the Other param is templated on the class, that
could be made into MemberExpr.

This shortfall makes creating source code analysis and refactoring tools harder
to implement as its harder to find where members are referenced.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200116/c6ea0472/attachment.html>

More information about the llvm-bugs mailing list