fixed "-O gen-C++" naming of "when" captures to avoid ambiguities due to inlining

Previously there was logic for doing this, but it was ineffectual
	due to the order in which canonicalization was done. This problem
	manifested non-deterministically depending on order-of-generation
	of "when" lambdas, which is why previous testing didn't catch it.
This commit is contained in:
Vern Paxson 2024-10-11 08:16:59 -07:00
parent e18ab5be95
commit 1f1200e5e8

View file

@ -133,15 +133,13 @@ string CPPCompile::LocalName(const ID* l) const { return Canonicalize(trim_name(
string CPPCompile::CaptureName(const ID* c) const {
// We want to strip both the module and any inlining appendage.
auto n = Canonicalize(trim_name(c).c_str());
auto tn = trim_name(c);
auto appendage = n.find(".");
if ( appendage != string::npos ) {
n.erase(n.begin() + appendage, n.end());
n.push_back('_');
}
auto appendage = tn.find(".");
if ( appendage != string::npos )
tn.erase(tn.begin() + appendage, tn.end());
return n;
return Canonicalize(tn.c_str());
}
string CPPCompile::Canonicalize(const char* name) const {