This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Fix PR22637 - IndirectFieldDecl's discard qualifiers during template instantiation.
ClosedPublic

Authored by EricWF on Apr 7 2018, 8:55 PM.

Details

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.

Diff Detail

Event Timeline

EricWF created this revision.Apr 7 2018, 8:55 PM
rjmccall accepted this revision.Apr 7 2018, 9:19 PM

Okay, LGTM.

This revision is now accepted and ready to land.Apr 7 2018, 9:19 PM
This revision was automatically updated to reflect the committed changes.