Rewrite demangle memory handling.

The return of itaniumDemangle is allocated with malloc rather than new[]
and so using unique_ptr isn't called for here. As a note for the future
we should rewrite it to do this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306788 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Christopher
2017-06-30 05:38:56 +00:00
parent 76aac8f1ce
commit 7fd563d283

View File

@@ -672,12 +672,14 @@ static Optional<std::string> demangle(StringRef Name, bool StripUnderscore) {
return None;
int Status;
std::unique_ptr<char[]> Undecorated(
itaniumDemangle(Name.str().c_str(), nullptr, nullptr, &Status));
char *Undecorated =
itaniumDemangle(Name.str().c_str(), nullptr, nullptr, &Status);
if (Status != 0)
return None;
return std::string(Undecorated.get());
std::string S(Undecorated);
free(Undecorated);
return S;
}
static bool symbolIsDefined(const NMSymbol &Sym) {