diff --git a/llvm/include/llvm/Demangle/Demangle.h b/llvm/include/llvm/Demangle/Demangle.h --- a/llvm/include/llvm/Demangle/Demangle.h +++ b/llvm/include/llvm/Demangle/Demangle.h @@ -28,8 +28,7 @@ demangle_success = 0, }; -char *itaniumDemangle(const char *mangled_name, char *buf, size_t *n, - int *status); +char *itaniumDemangle(const char *mangled_name, int *status); enum MSDemangleFlags { MSDF_None = 0, diff --git a/llvm/lib/Demangle/Demangle.cpp b/llvm/lib/Demangle/Demangle.cpp --- a/llvm/lib/Demangle/Demangle.cpp +++ b/llvm/lib/Demangle/Demangle.cpp @@ -48,7 +48,7 @@ bool llvm::nonMicrosoftDemangle(const char *MangledName, std::string &Result) { char *Demangled = nullptr; if (isItaniumEncoding(MangledName)) - Demangled = itaniumDemangle(MangledName, nullptr, nullptr, nullptr); + Demangled = itaniumDemangle(MangledName, nullptr); else if (isRustEncoding(MangledName)) Demangled = rustDemangle(MangledName); else if (isDLangEncoding(MangledName)) diff --git a/llvm/lib/Demangle/ItaniumDemangle.cpp b/llvm/lib/Demangle/ItaniumDemangle.cpp --- a/llvm/lib/Demangle/ItaniumDemangle.cpp +++ b/llvm/lib/Demangle/ItaniumDemangle.cpp @@ -365,9 +365,8 @@ using Demangler = itanium_demangle::ManglingParser; -char *llvm::itaniumDemangle(const char *MangledName, char *Buf, - size_t *N, int *Status) { - if (MangledName == nullptr || (Buf != nullptr && N == nullptr)) { +char *llvm::itaniumDemangle(const char *MangledName, int *Status) { + if (MangledName == nullptr) { if (Status) *Status = demangle_invalid_args; return nullptr; @@ -377,15 +376,14 @@ Demangler Parser(MangledName, MangledName + std::strlen(MangledName)); Node *AST = Parser.parse(); + char *Buf; if (AST == nullptr) InternalStatus = demangle_invalid_mangled_name; else { - OutputBuffer OB(Buf, N); + OutputBuffer OB; assert(Parser.ForwardTemplateRefs.empty()); AST->print(OB); OB += '\0'; - if (N != nullptr) - *N = OB.getCurrentPosition(); Buf = OB.getBuffer(); } diff --git a/llvm/lib/ProfileData/GCOV.cpp b/llvm/lib/ProfileData/GCOV.cpp --- a/llvm/lib/ProfileData/GCOV.cpp +++ b/llvm/lib/ProfileData/GCOV.cpp @@ -339,7 +339,7 @@ if (Name.startswith("_Z")) { int status = 0; // Name is guaranteed to be NUL-terminated. - char *res = itaniumDemangle(Name.data(), nullptr, nullptr, &status); + char *res = itaniumDemangle(Name.data(), &status); if (status == 0) { demangled = res; free(res); diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc --- a/llvm/lib/Support/Unix/Signals.inc +++ b/llvm/lib/Support/Unix/Signals.inc @@ -653,7 +653,7 @@ if (dlinfo.dli_sname != nullptr) { OS << ' '; int res; - char *d = itaniumDemangle(dlinfo.dli_sname, nullptr, nullptr, &res); + char *d = itaniumDemangle(dlinfo.dli_sname, &res); if (!d) OS << dlinfo.dli_sname; else diff --git a/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp b/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp --- a/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp +++ b/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp @@ -84,11 +84,11 @@ char *Undecorated = nullptr; if (Types) - Undecorated = itaniumDemangle(DecoratedStr, nullptr, nullptr, nullptr); + Undecorated = itaniumDemangle(DecoratedStr, nullptr); if (!Undecorated && strncmp(DecoratedStr, "__imp_", 6) == 0) { Prefix = "import thunk for "; - Undecorated = itaniumDemangle(DecoratedStr + 6, nullptr, nullptr, nullptr); + Undecorated = itaniumDemangle(DecoratedStr + 6, nullptr); } Result = Undecorated ? Prefix + Undecorated : Mangled; diff --git a/llvm/tools/llvm-itanium-demangle-fuzzer/llvm-itanium-demangle-fuzzer.cpp b/llvm/tools/llvm-itanium-demangle-fuzzer/llvm-itanium-demangle-fuzzer.cpp --- a/llvm/tools/llvm-itanium-demangle-fuzzer/llvm-itanium-demangle-fuzzer.cpp +++ b/llvm/tools/llvm-itanium-demangle-fuzzer/llvm-itanium-demangle-fuzzer.cpp @@ -15,8 +15,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { std::string NullTerminatedString((const char *)Data, Size); int status = 0; - if (char *demangle = llvm::itaniumDemangle(NullTerminatedString.c_str(), nullptr, - nullptr, &status)) + if (char *demangle = + llvm::itaniumDemangle(NullTerminatedString.c_str(), &status)) free(demangle); return 0; diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp --- a/llvm/tools/llvm-objdump/MachODump.cpp +++ b/llvm/tools/llvm-objdump/MachODump.cpp @@ -7281,8 +7281,7 @@ if (info->demangled_name != nullptr) free(info->demangled_name); int status; - info->demangled_name = - itaniumDemangle(SymbolName + 1, nullptr, nullptr, &status); + info->demangled_name = itaniumDemangle(SymbolName + 1, &status); if (info->demangled_name != nullptr) { *ReferenceName = info->demangled_name; *ReferenceType = LLVMDisassembler_ReferenceType_DeMangled_Name; @@ -7381,8 +7380,7 @@ if (info->demangled_name != nullptr) free(info->demangled_name); int status; - info->demangled_name = - itaniumDemangle(SymbolName + 1, nullptr, nullptr, &status); + info->demangled_name = itaniumDemangle(SymbolName + 1, &status); if (info->demangled_name != nullptr) { *ReferenceName = info->demangled_name; *ReferenceType = LLVMDisassembler_ReferenceType_DeMangled_Name; diff --git a/llvm/tools/llvm-opt-report/OptReport.cpp b/llvm/tools/llvm-opt-report/OptReport.cpp --- a/llvm/tools/llvm-opt-report/OptReport.cpp +++ b/llvm/tools/llvm-opt-report/OptReport.cpp @@ -339,8 +339,7 @@ bool Printed = false; if (!NoDemangle) { int Status = 0; - char *Demangled = - itaniumDemangle(FuncName.c_str(), nullptr, nullptr, &Status); + char *Demangled = itaniumDemangle(FuncName.c_str(), &Status); if (Demangled && Status == 0) { OS << Demangled; Printed = true;