diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp --- a/lldb/source/Core/Mangled.cpp +++ b/lldb/source/Core/Mangled.cpp @@ -108,7 +108,7 @@ // Local helpers for different demangling implementations. static char *GetMSVCDemangledStr(const char *M) { char *demangled_cstr = llvm::microsoftDemangle( - M, nullptr, nullptr, nullptr, nullptr, + M, nullptr, nullptr, llvm::MSDemangleFlags( llvm::MSDF_NoAccessSpecifier | llvm::MSDF_NoCallingConvention | llvm::MSDF_NoMemberType | llvm::MSDF_NoVariableType)); 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 @@ -46,15 +46,9 @@ /// success, or nullptr on error. /// If n_read is non-null and demangling was successful, it receives how many /// bytes of the input string were consumed. -/// buf can point to a *n_buf bytes large buffer where the demangled name is -/// stored. If the buffer is too small, it is grown with realloc(). If buf is -/// nullptr, then this malloc()s memory for the result. -/// *n_buf stores the size of buf on input if buf is non-nullptr, and it -/// receives the size of the demangled string on output if n_buf is not nullptr. /// status receives one of the demangle_ enum entries above if it's not nullptr. /// Flags controls various details of the demangled representation. -char *microsoftDemangle(const char *mangled_name, size_t *n_read, char *buf, - size_t *n_buf, int *status, +char *microsoftDemangle(const char *mangled_name, size_t *n_read, int *status, MSDemangleFlags Flags = MSDF_None); // Demangles a Rust v0 mangled symbol. diff --git a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp --- a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp +++ b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp @@ -687,7 +687,7 @@ // Only do MSVC C++ demangling on symbols starting with '?'. int status = 0; char *DemangledName = microsoftDemangle( - Name.c_str(), nullptr, nullptr, nullptr, &status, + Name.c_str(), nullptr, &status, MSDemangleFlags(MSDF_NoAccessSpecifier | MSDF_NoCallingConvention | MSDF_NoMemberType | MSDF_NoReturnType)); if (status != 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 @@ -36,8 +36,7 @@ if (S[0] == '_' && nonMicrosoftDemangle(S + 1, Result)) return Result; - if (char *Demangled = - microsoftDemangle(S, nullptr, nullptr, nullptr, nullptr)) { + if (char *Demangled = microsoftDemangle(S, nullptr, nullptr)) { Result = Demangled; std::free(Demangled); return Result; diff --git a/llvm/lib/Demangle/MicrosoftDemangle.cpp b/llvm/lib/Demangle/MicrosoftDemangle.cpp --- a/llvm/lib/Demangle/MicrosoftDemangle.cpp +++ b/llvm/lib/Demangle/MicrosoftDemangle.cpp @@ -2398,7 +2398,6 @@ } char *llvm::microsoftDemangle(const char *MangledName, size_t *NMangled, - char *Buf, size_t *N, int *Status, MSDemangleFlags Flags) { Demangler D; @@ -2423,14 +2422,13 @@ OF = OutputFlags(OF | OF_NoVariableType); int InternalStatus = demangle_success; + char *Buf; if (D.Error) InternalStatus = demangle_invalid_mangled_name; else { - OutputBuffer OB(Buf, N); + OutputBuffer OB; AST->output(OB, OF); OB += '\0'; - if (N != nullptr) - *N = OB.getCurrentPosition(); Buf = OB.getBuffer(); } diff --git a/llvm/tools/llvm-microsoft-demangle-fuzzer/llvm-microsoft-demangle-fuzzer.cpp b/llvm/tools/llvm-microsoft-demangle-fuzzer/llvm-microsoft-demangle-fuzzer.cpp --- a/llvm/tools/llvm-microsoft-demangle-fuzzer/llvm-microsoft-demangle-fuzzer.cpp +++ b/llvm/tools/llvm-microsoft-demangle-fuzzer/llvm-microsoft-demangle-fuzzer.cpp @@ -14,7 +14,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { std::string NullTerminatedString((const char *)Data, Size); - free(llvm::microsoftDemangle(NullTerminatedString.c_str(), nullptr, nullptr, - nullptr, nullptr)); + free(llvm::microsoftDemangle(NullTerminatedString.c_str(), nullptr, nullptr)); return 0; } diff --git a/llvm/tools/llvm-objdump/COFFDump.cpp b/llvm/tools/llvm-objdump/COFFDump.cpp --- a/llvm/tools/llvm-objdump/COFFDump.cpp +++ b/llvm/tools/llvm-objdump/COFFDump.cpp @@ -849,8 +849,7 @@ << Name; if (Demangle && Name.startswith("?")) { int Status = -1; - char *DemangledSymbol = - microsoftDemangle(Name.data(), nullptr, nullptr, nullptr, &Status); + char *DemangledSymbol = microsoftDemangle(Name.data(), nullptr, &Status); if (Status == 0 && DemangledSymbol) { outs() << " (" << StringRef(DemangledSymbol) << ")"; diff --git a/llvm/tools/llvm-undname/llvm-undname.cpp b/llvm/tools/llvm-undname/llvm-undname.cpp --- a/llvm/tools/llvm-undname/llvm-undname.cpp +++ b/llvm/tools/llvm-undname/llvm-undname.cpp @@ -75,8 +75,7 @@ Flags = MSDemangleFlags(Flags | MSDF_NoVariableType); size_t NRead; - char *ResultBuf = - microsoftDemangle(S.c_str(), &NRead, nullptr, nullptr, &Status, Flags); + char *ResultBuf = microsoftDemangle(S.c_str(), &NRead, &Status, Flags); if (Status == llvm::demangle_success) { outs() << ResultBuf << "\n"; outs().flush();