Skip to content

Commit

Permalink
Merge 97e3676 into 410de69
Browse files Browse the repository at this point in the history
  • Loading branch information
shameekganguly authored May 9, 2023
2 parents 410de69 + 97e3676 commit 0a4c170
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions core/src/utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ namespace gz
namespace plugin
{
/////////////////////////////////////////////////
std::string DemangleSymbol(const std::string &_name)
std::string DemangleSymbol(const std::string &_symbol)
{
#if defined(__GNUC__) || defined(__clang__)
int status;
char *demangled_cstr = abi::__cxa_demangle(
_name.c_str(), nullptr, nullptr, &status);
_symbol.c_str(), nullptr, nullptr, &status);

if (0 != status)
{
// LCOV_EXCL_START
std::cerr << "[Demangle] Failed to demangle the symbol name [" << _name
<< "]. Error code: " << status << "\n";
std::cerr << "[Demangle] Failed to demangle the symbol name ["
<< _symbol << "]. Error code: " << status << "\n";
assert(false);
return _name;
return _symbol;
// LCOV_EXCL_STOP
}

Expand All @@ -55,20 +55,20 @@ namespace gz
return demangled;
#elif _MSC_VER

assert(_name.substr(0, 6) == "class ");
assert(_symbol.substr(0, 6) == "class ");

// Visual Studio's typeid(~).name() does not mangle the name, except that
// it prefixes the normal name of the class with the character sequence
// "class ". So to get the "demangled" name, all we have to do is remove
// "class " from each place where it appears.
const std::regex classRegex("class ");
return std::regex_replace(_name, classRegex, "");
return std::regex_replace(_symbol, classRegex, "");
#else
// If we don't know the compiler, then we can't perform name demangling.
// The tests will probably fail in this situation, and the class names
// will probably look gross to users. Plugin name aliasing can be used
// to make plugins robust to this situation.
return _name;
return _symbol;
#endif
}
}
Expand Down

0 comments on commit 0a4c170

Please sign in to comment.