[llvm] r346606 - Make initializeOutputStream() return false on error and true on success.
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 11 02:04:00 PST 2018
Author: nico
Date: Sun Nov 11 02:04:00 2018
New Revision: 346606
URL: http://llvm.org/viewvc/llvm-project?rev=346606&view=rev
Log:
Make initializeOutputStream() return false on error and true on success.
As discussed in https://reviews.llvm.org/D52104
Differential Revision: https://reviews.llvm.org/D52143
Modified:
llvm/trunk/include/llvm/Demangle/Utility.h
llvm/trunk/lib/Demangle/ItaniumDemangle.cpp
llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
Modified: llvm/trunk/include/llvm/Demangle/Utility.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Demangle/Utility.h?rev=346606&r1=346605&r2=346606&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Demangle/Utility.h (original)
+++ llvm/trunk/include/llvm/Demangle/Utility.h Sun Nov 11 02:04:00 2018
@@ -175,13 +175,13 @@ inline bool initializeOutputStream(char
if (Buf == nullptr) {
Buf = static_cast<char *>(std::malloc(InitSize));
if (Buf == nullptr)
- return true;
+ return false;
BufferSize = InitSize;
} else
BufferSize = *N;
S.reset(Buf, BufferSize);
- return false;
+ return true;
}
#endif
Modified: llvm/trunk/lib/Demangle/ItaniumDemangle.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Demangle/ItaniumDemangle.cpp?rev=346606&r1=346605&r2=346606&view=diff
==============================================================================
--- llvm/trunk/lib/Demangle/ItaniumDemangle.cpp (original)
+++ llvm/trunk/lib/Demangle/ItaniumDemangle.cpp Sun Nov 11 02:04:00 2018
@@ -340,7 +340,7 @@ char *llvm::itaniumDemangle(const char *
if (AST == nullptr)
InternalStatus = demangle_invalid_mangled_name;
- else if (initializeOutputStream(Buf, N, S, 1024))
+ else if (!initializeOutputStream(Buf, N, S, 1024))
InternalStatus = demangle_memory_alloc_failure;
else {
assert(Parser.ForwardTemplateRefs.empty());
@@ -396,7 +396,7 @@ bool ItaniumPartialDemangler::partialDem
static char *printNode(const Node *RootNode, char *Buf, size_t *N) {
OutputStream S;
- if (initializeOutputStream(Buf, N, S, 128))
+ if (!initializeOutputStream(Buf, N, S, 128))
return nullptr;
RootNode->print(S);
S += '\0';
@@ -441,7 +441,7 @@ char *ItaniumPartialDemangler::getFuncti
const Node *Name = static_cast<const FunctionEncoding *>(RootNode)->getName();
OutputStream S;
- if (initializeOutputStream(Buf, N, S, 128))
+ if (!initializeOutputStream(Buf, N, S, 128))
return nullptr;
KeepGoingLocalFunction:
@@ -494,7 +494,7 @@ char *ItaniumPartialDemangler::getFuncti
NodeArray Params = static_cast<FunctionEncoding *>(RootNode)->getParams();
OutputStream S;
- if (initializeOutputStream(Buf, N, S, 128))
+ if (!initializeOutputStream(Buf, N, S, 128))
return nullptr;
S += '(';
@@ -512,7 +512,7 @@ char *ItaniumPartialDemangler::getFuncti
return nullptr;
OutputStream S;
- if (initializeOutputStream(Buf, N, S, 128))
+ if (!initializeOutputStream(Buf, N, S, 128))
return nullptr;
if (const Node *Ret =
Modified: llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp?rev=346606&r1=346605&r2=346606&view=diff
==============================================================================
--- llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp (original)
+++ llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp Sun Nov 11 02:04:00 2018
@@ -874,7 +874,7 @@ void Demangler::memorizeIdentifier(Ident
// Render this class template name into a string buffer so that we can
// memorize it for the purpose of back-referencing.
OutputStream OS;
- if (initializeOutputStream(nullptr, nullptr, OS, 1024))
+ if (!initializeOutputStream(nullptr, nullptr, OS, 1024))
// FIXME: Propagate out-of-memory as an error?
std::terminate();
Identifier->output(OS, OF_Default);
@@ -1207,7 +1207,7 @@ Demangler::demangleStringLiteral(StringV
if (MangledName.empty())
goto StringLiteralError;
- if (initializeOutputStream(nullptr, nullptr, OS, 1024))
+ if (!initializeOutputStream(nullptr, nullptr, OS, 1024))
// FIXME: Propagate out-of-memory as an error?
std::terminate();
if (IsWcharT) {
@@ -1330,7 +1330,7 @@ Demangler::demangleLocallyScopedNamePiec
// Render the parent symbol's name into a buffer.
OutputStream OS;
- if (initializeOutputStream(nullptr, nullptr, OS, 1024))
+ if (!initializeOutputStream(nullptr, nullptr, OS, 1024))
// FIXME: Propagate out-of-memory as an error?
std::terminate();
OS << '`';
@@ -2156,7 +2156,7 @@ void Demangler::dumpBackReferences() {
// Create an output stream so we can render each type.
OutputStream OS;
- if (initializeOutputStream(nullptr, nullptr, OS, 1024))
+ if (!initializeOutputStream(nullptr, nullptr, OS, 1024))
std::terminate();
for (size_t I = 0; I < Backrefs.FunctionParamCount; ++I) {
OS.setCurrentPosition(0);
@@ -2194,7 +2194,7 @@ char *llvm::microsoftDemangle(const char
if (D.Error)
InternalStatus = demangle_invalid_mangled_name;
- else if (initializeOutputStream(Buf, N, S, 1024))
+ else if (!initializeOutputStream(Buf, N, S, 1024))
InternalStatus = demangle_memory_alloc_failure;
else {
AST->output(S, OF_Default);
More information about the llvm-commits
mailing list