-O gen-C++ fix for dealing with use of more than one module qualifier

This commit is contained in:
Vern Paxson 2024-08-13 14:41:51 -07:00
parent 77c34787f3
commit a93a69ba62

View file

@ -111,10 +111,30 @@ string CPPCompile::LocalName(const ID* l) const {
auto n = l->Name(); auto n = l->Name();
auto without_module = strstr(n, "::"); auto without_module = strstr(n, "::");
if ( without_module ) while ( without_module ) {
return Canonicalize(without_module + 2); n = without_module + 2;
else without_module = strstr(n, "::");
return Canonicalize(n); }
return Canonicalize(n);
}
string CPPCompile::CaptureName(const ID* l) const {
// We want to strip both the module and any inlining appendage.
auto n = l->Name();
auto without_module = strstr(n, "::");
while ( without_module ) {
n = without_module + 2;
without_module = strstr(n, "::");
}
auto appendage = strchr(n, '.');
if ( appendage )
return string(n, appendage - n) + "_";
return string(n) + "_";
} }
string CPPCompile::Canonicalize(const char* name) const { string CPPCompile::Canonicalize(const char* name) const {
@ -127,7 +147,7 @@ string CPPCompile::Canonicalize(const char* name) const {
if ( c == '<' || c == '>' ) if ( c == '<' || c == '>' )
continue; continue;
if ( c == ':' || c == '-' ) if ( c == ':' || c == '-' || c == '.' )
c = '_'; c = '_';
cname += c; cname += c;