Index: include/llvm/Demangle/Utility.h =================================================================== --- include/llvm/Demangle/Utility.h +++ include/llvm/Demangle/Utility.h @@ -175,13 +175,13 @@ if (Buf == nullptr) { Buf = static_cast(std::malloc(InitSize)); if (Buf == nullptr) - return true; + return false; BufferSize = InitSize; } else BufferSize = *N; S.reset(Buf, BufferSize); - return false; + return true; } #endif Index: lib/Demangle/ItaniumDemangle.cpp =================================================================== --- lib/Demangle/ItaniumDemangle.cpp +++ lib/Demangle/ItaniumDemangle.cpp @@ -334,7 +334,7 @@ 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()); @@ -390,7 +390,7 @@ 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'; @@ -435,7 +435,7 @@ const Node *Name = static_cast(RootNode)->getName(); OutputStream S; - if (initializeOutputStream(Buf, N, S, 128)) + if (!initializeOutputStream(Buf, N, S, 128)) return nullptr; KeepGoingLocalFunction: @@ -488,7 +488,7 @@ NodeArray Params = static_cast(RootNode)->getParams(); OutputStream S; - if (initializeOutputStream(Buf, N, S, 128)) + if (!initializeOutputStream(Buf, N, S, 128)) return nullptr; S += '('; @@ -506,7 +506,7 @@ return nullptr; OutputStream S; - if (initializeOutputStream(Buf, N, S, 128)) + if (!initializeOutputStream(Buf, N, S, 128)) return nullptr; if (const Node *Ret = Index: lib/Demangle/MicrosoftDemangle.cpp =================================================================== --- lib/Demangle/MicrosoftDemangle.cpp +++ lib/Demangle/MicrosoftDemangle.cpp @@ -1017,7 +1017,7 @@ // 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); @@ -1349,7 +1349,7 @@ 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) { @@ -1472,7 +1472,7 @@ // 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 << '`'; @@ -2298,7 +2298,7 @@ // 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); @@ -2336,7 +2336,7 @@ 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);