diff options
author | Kirill Stoimenov <kstoimenov@google.com> | 2022-04-26 20:24:06 +0000 |
---|---|---|
committer | Kirill Stoimenov <kstoimenov@google.com> | 2022-04-26 20:24:06 +0000 |
commit | aabeb5eb7f0aaa2c80147d904959c882cdeba1e5 (patch) | |
tree | c2cbd63fa7047f616693b1613147c35fbb38f1a3 /llvm/lib/Demangle/MicrosoftDemangle.cpp | |
parent | ce8f42d4af2cf56c96f5a8cc4c4a02bf6b790ccc (diff) | |
download | llvm-aabeb5eb7f0aaa2c80147d904959c882cdeba1e5.zip llvm-aabeb5eb7f0aaa2c80147d904959c882cdeba1e5.tar.gz llvm-aabeb5eb7f0aaa2c80147d904959c882cdeba1e5.tar.bz2 |
Revert "[demangler] Simplify OutputBuffer initialization"
Reverting due to a bot failure:
https://lab.llvm.org/buildbot/#/builders/5/builds/22738
This reverts commit 5b3ca24a35e91bf9c19af856e7f92c69b17f989e.
Diffstat (limited to 'llvm/lib/Demangle/MicrosoftDemangle.cpp')
-rw-r--r-- | llvm/lib/Demangle/MicrosoftDemangle.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/llvm/lib/Demangle/MicrosoftDemangle.cpp b/llvm/lib/Demangle/MicrosoftDemangle.cpp index 26087a5..aca8cf7 100644 --- a/llvm/lib/Demangle/MicrosoftDemangle.cpp +++ b/llvm/lib/Demangle/MicrosoftDemangle.cpp @@ -966,6 +966,9 @@ void Demangler::memorizeIdentifier(IdentifierNode *Identifier) { // Render this class template name into a string buffer so that we can // memorize it for the purpose of back-referencing. OutputBuffer OB; + if (!initializeOutputBuffer(nullptr, nullptr, OB, 1024)) + // FIXME: Propagate out-of-memory as an error? + std::terminate(); Identifier->output(OB, OF_Default); StringView Owned = copyString(OB); memorizeString(Owned); @@ -1276,6 +1279,11 @@ Demangler::demangleStringLiteral(StringView &MangledName) { EncodedStringLiteralNode *Result = Arena.alloc<EncodedStringLiteralNode>(); + // Must happen before the first `goto StringLiteralError`. + if (!initializeOutputBuffer(nullptr, nullptr, OB, 1024)) + // FIXME: Propagate out-of-memory as an error? + std::terminate(); + // Prefix indicating the beginning of a string literal if (!MangledName.consumeFront("@_")) goto StringLiteralError; @@ -1434,6 +1442,9 @@ Demangler::demangleLocallyScopedNamePiece(StringView &MangledName) { // Render the parent symbol's name into a buffer. OutputBuffer OB; + if (!initializeOutputBuffer(nullptr, nullptr, OB, 1024)) + // FIXME: Propagate out-of-memory as an error? + std::terminate(); OB << '`'; Scope->output(OB, OF_Default); OB << '\''; @@ -2296,6 +2307,8 @@ void Demangler::dumpBackReferences() { // Create an output stream so we can render each type. OutputBuffer OB; + if (!initializeOutputBuffer(nullptr, nullptr, OB, 1024)) + std::terminate(); for (size_t I = 0; I < Backrefs.FunctionParamCount; ++I) { OB.setCurrentPosition(0); @@ -2322,6 +2335,7 @@ char *llvm::microsoftDemangle(const char *MangledName, size_t *NMangled, char *Buf, size_t *N, int *Status, MSDemangleFlags Flags) { Demangler D; + OutputBuffer OB; StringView Name{MangledName}; SymbolNode *AST = D.parse(Name); @@ -2346,8 +2360,9 @@ char *llvm::microsoftDemangle(const char *MangledName, size_t *NMangled, int InternalStatus = demangle_success; if (D.Error) InternalStatus = demangle_invalid_mangled_name; + else if (!initializeOutputBuffer(Buf, N, OB, 1024)) + InternalStatus = demangle_memory_alloc_failure; else { - OutputBuffer OB(Buf, N); AST->output(OB, OF); OB += '\0'; if (N != nullptr) |