This is an archive of the discontinued LLVM Phabricator instance.

Don't allow mangling substitutions to refer to unrelated entities from different <encoding>s.
Needs ReviewPublic

Authored by rsmith on Jul 12 2020, 2:11 PM.

Details

Reviewers
rjmccall
Summary

Per the ABI rules, substitutable components are symbolic constructs, not
the associated mangling character strings, so references to function
parameters or template parameters of distinct <encoding>s should not be
considered substitutable even if they're at the same depth / index.

See https://github.com/itanium-cxx-abi/cxx-abi/issues/106.

This change can be turned off by setting -fclang-abi-compat to 10 or
earlier.

Diff Detail

Event Timeline

rsmith created this revision.Jul 12 2020, 2:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 12 2020, 2:11 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
rsmith added a comment.EditedJul 12 2020, 4:00 PM

Hm, I think this is not quite right. For example, given:

template<typename T, typename U> struct X {};
template<typename T> auto f(T a, decltype(a)) {
  struct A {};
  struct B {};
  return X<A, B>();
}
void g(decltype(f(0, 0))) {}

... I think we won't use a substitution from the first parameter of f<int> in the second <local-name> back to the first parameter of f<int> in the first <local-name>.