Fix issue #2937 (DI scope for types in static foreach in mixin templates) (#2939)

This commit is contained in:
Martin Kinkelin 2018-12-16 13:41:18 +01:00 committed by GitHub
parent c7d7894045
commit d4858cfbcb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 6 deletions

View file

@ -135,6 +135,8 @@ DIScope DIBuilder::GetSymbolScope(Dsymbol *s) {
return EmitSubProgram(fd); return EmitSubProgram(fd);
} else if (auto ns = parent->isNspace()) { } else if (auto ns = parent->isNspace()) {
return EmitNamespace(ns, ns->toChars()); return EmitNamespace(ns, ns->toChars());
} else if (auto fwd = parent->isForwardingScopeDsymbol()) {
return GetSymbolScope(fwd);
} }
llvm_unreachable("Unhandled parent"); llvm_unreachable("Unhandled parent");

View file

@ -52,13 +52,22 @@ void templatedFoo(int N)()
mixin template Mixin(T) mixin template Mixin(T)
{ {
T mixedInField; // test https://github.com/ldc-developers/ldc/issues/2937 while at it
void mixedInFoo() static foreach (i; 0 .. 1)
{ {
// CDB: bp `scopes_cdb.d:58` static struct MixedInStruct { T field; }
MixedInStruct mixedInField;
void mixedInFoo()
{
MixedInStruct local;
// CDB: bp `scopes_cdb.d:63`
// CDB: g // CDB: g
// CHECK-G: !scopes_cdb.S.mixedInFoo+ // CHECK-G: !scopes_cdb.S.mixedInFoo+
// CHECK-GC: !scopes_cdb::S::mixedInFoo+ // CHECK-GC: !scopes_cdb::S::mixedInFoo+
// CDB: dv /t
// CHECK-G: struct scopes_cdb.S.MixedInStruct local =
// CHECK-GC: struct scopes_cdb::S::MixedInStruct local =
}
} }
} }
@ -83,7 +92,7 @@ void test()
T[N] field; T[N] field;
void foo() void foo()
{ {
// CDB: bp `scopes_cdb.d:86` // CDB: bp `scopes_cdb.d:95`
// CDB: g // CDB: g
// CHECK-G: !scopes_cdb.test.TemplatedNestedStruct!(S, 3).foo+ // CHECK-G: !scopes_cdb.test.TemplatedNestedStruct!(S, 3).foo+
// CHECK-GC: !scopes_cdb::test::TemplatedNestedStruct<S, 3>::foo+ // CHECK-GC: !scopes_cdb::test::TemplatedNestedStruct<S, 3>::foo+
@ -98,7 +107,7 @@ void test()
int field; int field;
void foo() void foo()
{ {
// CDB: bp `scopes_cdb.d:101` // CDB: bp `scopes_cdb.d:110`
// CDB: g // CDB: g
// CHECK-G: !scopes_cdb.test.NestedStruct.foo+ // CHECK-G: !scopes_cdb.test.NestedStruct.foo+
// CHECK-GC: !scopes_cdb::test::NestedStruct::foo+ // CHECK-GC: !scopes_cdb::test::NestedStruct::foo+
@ -108,7 +117,7 @@ void test()
NestedStruct ns; NestedStruct ns;
ns.foo(); ns.foo();
// CDB: bp `scopes_cdb.d:111` // CDB: bp `scopes_cdb.d:120`
// CDB: g // CDB: g
// CDB: dv /t // CDB: dv /t
// CHECK-G: struct scopes_cdb.S s = // CHECK-G: struct scopes_cdb.S s =