Open tycho opened 11 months ago
@llvm/issue-subscribers-debuginfo
Author: Steven Noonan (tycho)
@llvm/issue-subscribers-clang-codegen
Author: Steven Noonan (tycho)
Much reduced: https://gcc.godbolt.org/z/7PhK1vvhh
#include <map>
template <int T>
struct StrongResourceIDBase {
typedef int value_type;
};
template <int T>
struct GLResourceName {
typedef StrongResourceIDBase<T> base_type;
};
template <int T>
class GLResourceRef {
typedef GLResourceName<T>::base_type::value_type name_value_type;
private:
static std::map<unsigned int, name_value_type> s_resourceNames;
};
GLResourceRef<0> m_vao;
Looks like a regression starting in clang-16.
CC @dwblaikie
Reduced down a bit further:
template <typename T>
struct t1 {
typedef int m1;
};
template <typename T>
struct t2 {
typedef t1<T> m2;
};
template <typename T>
struct t3 {
static t2<T>::m2::m1 m3;
};
t3<int> g1;
The missing typename
in static typename t2<T>::m2::m1 m3;
seems to make a difference between success and crashing. So I'm guessing maybe some difference in the AST was made that caused this problem.
Yeah, so in the missing typename
case, the CGDebugInfo.cpp
sees the static member as having a dependent type:
DependentNameType 0x555569273d20 'typename t2<int>::m2::m1' dependent
Whereas in the case that has the typename
:
ElaboratedType 0x555569274200 'typename t2<int>::m2::m1' sugar
`-TypedefType 0x5555692741d0 't1<int>::m1' sugar
|-Typedef 0x555569274160 'm1'
`-BuiltinType 0x555569204fc0 'int'
That doesn't seem consistent with Clang's "recover as-if the fixit was written in the source".
So I think this should be a generic clang fix, not related to debug info.
Originally found on Windows with clang-cl 17.0.6, but I suspect this is still related to my original issue. Here's a repro on Godbolt: https://gcc.godbolt.org/z/n1KGbnEGs
It only happens at -g2 or higher:
Here's the repro, though I don't have creduce/cvise up and running right now so it's a little too verbose: