Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
/ druntime Public archive
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 15 additions & 22 deletions src/rt/minfo.d
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,9 @@ struct ModuleGroup
return true;
}

// `cycle` is set to `true` if deprecated cycle error otherwise set `result`.
void doSort(size_t relevantFlags, ref bool cycle, ref immutable(ModuleInfo)*[] result)
// returns `false` if deprecated cycle error otherwise set `result`.
bool doSort(size_t relevantFlags, ref immutable(ModuleInfo)*[] result)
{
if (cycle)
return;

clearFlags(relevant);
clearFlags(ctorstart);
clearFlags(ctordone);
Expand Down Expand Up @@ -495,33 +492,29 @@ struct ModuleGroup
if (!bt(ctordone, idx))
{
if (!processMod(idx))
{
cycle = true;
return;
}
return false;
}
}

if (ctoridx == 0)
{
// no ctors in the list.
.free(ctors);
result = null;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, this wasn't needed, as the ctor list is null by default.

return;
}

ctors = cast(immutable(ModuleInfo)**).realloc(ctors, ctoridx * (void*).sizeof);
if (ctors is null)
assert(0);
result = ctors[0 .. ctoridx];
return;
else
{
ctors = cast(immutable(ModuleInfo)**).realloc(ctors, ctoridx * (void*).sizeof);
if (ctors is null)
assert(0);
result = ctors[0 .. ctoridx];
}
return true;
}

// finally, do the sorting for both shared and tls ctors.
bool cycle = false;
doSort(MIctor | MIdtor, cycle, _ctors);
doSort(MItlsctor | MItlsdtor, cycle, _tlsctors);
if (cycle)
// finally, do the sorting for both shared and tls ctors. If either returns false,
// print the deprecation warning.
if (!doSort(MIctor | MIdtor, _ctors) ||
!doSort(MItlsctor | MItlsdtor, _tlsctors))
{
// print a warning
import core.stdc.stdio : fprintf, stderr;
Expand Down