DebugInfo: Don't simplify names referencing local enums

Due to the way type units work, this would lead to a declaration in a
type unit of a local type in a CU - which is ambiguous. Rather than
trying to resolve that relative to the CU that references the type unit,
let's just not try to simplify these names.

Longer term this should be fixed by not putting the template
instantiation in a type unit to begin with - since it references an
internal linkage type, it can't legitimately be duplicated/in more than
one translation unit, so skip the type unit overhead. (but the right fix
for that is to move type unit management into a DICompositeType flag
(dropping the "identifier" field is not a perfect solution since it
breaks LLVM IR linking decl/def merging during IR linking))
This commit is contained in:
David Blaikie 2022-02-10 15:48:48 -08:00
parent 01b56b8bdd
commit 389f67b35b
3 changed files with 26 additions and 0 deletions

View File

@ -5040,6 +5040,10 @@ struct ReconstitutableType : public RecursiveASTVisitor<ReconstitutableType> {
Reconstitutable = false;
return false;
}
if (!ED->isExternallyVisible()) {
Reconstitutable = false;
return false;
}
}
return true;
}

View File

@ -16,6 +16,17 @@ struct t2 {
};
template <template <typename...> class T>
void f3() {}
namespace {
enum LocalEnum { LocalEnum1 };
}
template<typename T, T ... ts>
struct t3 { };
struct t4 {
t3<LocalEnum, LocalEnum1> m1;
};
t4 v1;
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "t3<(anonymous namespace)::LocalEnum, (anonymous namespace)::LocalEnum1>"
void f() {
// Basic examples of simplifiable/rebuildable names
f1<>();

View File

@ -53,6 +53,7 @@ template<unsigned N>
struct t4 { };
namespace {
struct t5 { };
enum LocalEnum { LocalEnum1 };
}
template<typename ...T1, typename T2 = int>
void f5() { }
@ -167,6 +168,14 @@ template<typename T>
void operator_not_really() {
}
template<typename T, T ...A>
struct t11 {
};
struct t12 {
t11<LocalEnum, LocalEnum1> v1;
};
int main() {
struct { } A;
auto L = []{};
@ -198,6 +207,7 @@ int main() {
f3<ns::EnumerationClass, ns::EnumerationClass::Enumerator3, (ns::EnumerationClass)2>();
f3<ns::EnumerationSmall, ns::kNeg>();
f3<decltype(ns::AnonEnum1), ns::AnonEnum3, (decltype(ns::AnonEnum1))2>();
f3<LocalEnum, LocalEnum1>();
f3<int*, &i>();
f3<int*, nullptr>();
t4<3> v2;
@ -305,6 +315,7 @@ int main() {
f1<void(t8, decltype(A))>();
f1<void(t8)>();
operator_not_really<int>();
t12 v4;
}
void t8::mem() {
struct t7 { };