Summary:
Currently Clang fails to propagate qualifiers from the `CXXThisExpr` to the rebuilt `FieldDecl` for IndirectFieldDecls. For example:
```
template <class T> struct Foo {
struct { int x; };
int y;
void foo() const {
static_assert(__is_same(int const&, decltype((y))));
static_assert(__is_same(int const&, decltype((x)))); // assertion fails
}
};
template struct Foo<int>;
```
The fix is to delegate rebuilding of the MemberExpr to `BuildFieldReferenceExpr` which correctly propagates the qualifiers.
Reviewers: rsmith, lebedev.ri, aaron.ballman, bkramer, rjmccall
Reviewed By: rjmccall
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D45412
llvm-svn: 329517