Fix the return type of demangle function so that its compatible across ABIs (#1744)

[ROCm/hip commit: 080b0b9a68]
This commit is contained in:
saleelk
2019-12-23 05:41:40 -08:00
committed by Maneesh Gupta
parent 1f5ecc0f6a
commit bb7fa73dcc
2 changed files with 14 additions and 13 deletions
+9 -9
View File
@@ -143,7 +143,9 @@ struct _hiprtcProgram {
{
using namespace std;
name = hip_impl::demangle(name.c_str());
char* demangled = hip_impl::demangle(name.c_str());
name.assign(demangled == nullptr ? "" : demangled);
free(demangled);
if (name.empty()) return name;
@@ -392,18 +394,16 @@ namespace
namespace hip_impl
{
inline
std::string demangle(const char* x)
char* demangle(const char* x)
{
if (!x) return {};
if (!x) return nullptr;
int s{};
std::unique_ptr<char, decltype(std::free)*> tmp{
abi::__cxa_demangle(x, nullptr, nullptr, &s), std::free};
char* tmp = abi::__cxa_demangle(x, nullptr, nullptr, &s);
if (s != 0) return {};
if (s != 0) return nullptr;
return tmp.get();
return tmp;
}
} // Namespace hip_impl.
@@ -598,4 +598,4 @@ hiprtcResult hiprtcGetCodeSize(hiprtcProgram p, std::size_t* sz)
*sz = p->elf.size();
return HIPRTC_SUCCESS;
}
}