Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[abi] mangled name issues for requires-clauses. #90046

Open
hokein opened this issue Apr 25, 2024 · 5 comments
Open

[abi] mangled name issues for requires-clauses. #90046

hokein opened this issue Apr 25, 2024 · 5 comments
Labels
ABI Application Binary Interface clang:frontend Language frontend issues, e.g. anything involving "Sema" tools:llvm-cxxfilt

Comments

@hokein
Copy link
Collaborator

hokein commented Apr 25, 2024

Example 1:

template <typename T>
concept C = true;

template <typename T>
struct Foo {
  template <typename F>
  explicit Foo(F f)
    requires requires {
      requires C<F>;
    }
  {}
};

void k() {
 // mangled name for the Foo<double>::Foo constructor: _ZN3FooIdEC2IiEET_QrqQ1CITL0__EE
 Foo<double> f(1);
}

The mangled name _ZN3FooIdEC2IiEET_QrqQ1CITL0__EE is demangled incorrectly (note that TL0):

$ ./bin/llvm-cxxfilt _ZN3FooIdEC2IiEET_QrqQ1CITL0__EE
Foo<double>::Foo<int>(int) requires requires { requires C<TL0_>; }

Example 2:

template <typename T>
concept C = true;
template <typename T, typename U>
concept C2 = true;

template <typename T>
struct Foo {
  template <typename F>
  explicit Foo(F f)
    requires requires {
      requires C<Foo>;
      requires C<T>;
      requires C2<F, F>;
    }
  {}
};

void k() {
   // mangled name is _ZN3FooIdEC2IiEET_QrqQ1CIS_IS2_EEQ1CIS2_EQ2C2ITL0__S5_EE
   Foo<double> f(1);
}

The mangled name can not be demangled by llvm-cxxfilt.

@hokein hokein added clang:frontend Language frontend issues, e.g. anything involving "Sema" tools:llvm-cxxfilt ABI Application Binary Interface labels Apr 25, 2024
@llvmbot
Copy link
Member

llvmbot commented Apr 25, 2024

@llvm/issue-subscribers-tools-llvm-cxxfilt

Author: Haojian Wu (hokein)

Example 1:
template &lt;typename T&gt;
concept C = true;

template &lt;typename T&gt;
struct Foo {
  template &lt;typename F&gt;
  explicit Foo(F f)
    requires requires {
      requires C&lt;F&gt;;
    }
  {}
};

void k() {
 // mangled name for the Foo&lt;double&gt;::Foo constructor: _ZN3FooIdEC2IiEET_QrqQ1CITL0__EE
 Foo&lt;double&gt; f(1);
}

The mangled name _ZN3FooIdEC2IiEET_QrqQ1CITL0__EE is demangled incorrectly (note that TL0):

$ ./bin/llvm-cxxfilt _ZN3FooIdEC2IiEET_QrqQ1CITL0__EE
Foo&lt;double&gt;::Foo&lt;int&gt;(int) requires requires { requires C&lt;TL0_&gt;; }

Example 2:

template &lt;typename T&gt;
concept C = true;
template &lt;typename T, typename U&gt;
concept C2 = true;

template &lt;typename T&gt;
struct Foo {
  template &lt;typename F&gt;
  explicit Foo(F f)
    requires requires {
      requires C&lt;Foo&gt;;
      requires C&lt;T&gt;;
      requires C2&lt;F, F&gt;;
    }
  {}
};

void k() {
   // mangled name is _ZN3FooIdEC2IiEET_QrqQ1CIS_IS2_EEQ1CIS2_EQ2C2ITL0__S5_EE
   Foo&lt;double&gt; f(1);
}

The mangled name can not be demangled by llvm-cxxfilt.

@llvmbot
Copy link
Member

llvmbot commented Apr 25, 2024

@llvm/issue-subscribers-clang-frontend

Author: Haojian Wu (hokein)

Example 1:
template &lt;typename T&gt;
concept C = true;

template &lt;typename T&gt;
struct Foo {
  template &lt;typename F&gt;
  explicit Foo(F f)
    requires requires {
      requires C&lt;F&gt;;
    }
  {}
};

void k() {
 // mangled name for the Foo&lt;double&gt;::Foo constructor: _ZN3FooIdEC2IiEET_QrqQ1CITL0__EE
 Foo&lt;double&gt; f(1);
}

The mangled name _ZN3FooIdEC2IiEET_QrqQ1CITL0__EE is demangled incorrectly (note that TL0):

$ ./bin/llvm-cxxfilt _ZN3FooIdEC2IiEET_QrqQ1CITL0__EE
Foo&lt;double&gt;::Foo&lt;int&gt;(int) requires requires { requires C&lt;TL0_&gt;; }

Example 2:

template &lt;typename T&gt;
concept C = true;
template &lt;typename T, typename U&gt;
concept C2 = true;

template &lt;typename T&gt;
struct Foo {
  template &lt;typename F&gt;
  explicit Foo(F f)
    requires requires {
      requires C&lt;Foo&gt;;
      requires C&lt;T&gt;;
      requires C2&lt;F, F&gt;;
    }
  {}
};

void k() {
   // mangled name is _ZN3FooIdEC2IiEET_QrqQ1CIS_IS2_EEQ1CIS2_EQ2C2ITL0__S5_EE
   Foo&lt;double&gt; f(1);
}

The mangled name can not be demangled by llvm-cxxfilt.

@hokein
Copy link
Collaborator Author

hokein commented Apr 25, 2024

The mangled name _ZN3FooIdEC2IiEET_QrqQ1CITL0__EE is demangled incorrectly (note that TL0):

This is not fully supported by the demangler yet, there is a TODO at https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/Demangle/ItaniumDemangle.h#L5675-L5681

@hokein
Copy link
Collaborator Author

hokein commented Apr 25, 2024

In example 2, _ZN3FooIdEC2IiEET_QrqQ1CIS_IS2_EEQ1CIS2_EQ2C2ITL0__S5_EE, the demangler fails when parsing the substitution S5 because it attempts to access Subs[5+1], which is out of bounds. The Subs array only has 6 elements:
[Foo, Foo<double>, Foo<double>::Foo<double>, int, Foo<int>, TL0_].

@shafik
Copy link
Collaborator

shafik commented Apr 26, 2024

CC @rjmccall @zygoloid

hokein added a commit that referenced this issue Apr 29, 2024
)

Having them dump is useful for ad-hoc debugging (context:
#90046)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ABI Application Binary Interface clang:frontend Language frontend issues, e.g. anything involving "Sema" tools:llvm-cxxfilt
Projects
None yet
Development

No branches or pull requests

3 participants