llvm.org GIT mirror llvm / ac4b70f
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346606 91177308-0d34-0410-b5e6-96231b3b80d8 Nico Weber 10 months ago
3 changed file(s) with 12 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
174174 if (Buf == nullptr) {
175175 Buf = static_cast(std::malloc(InitSize));
176176 if (Buf == nullptr)
177 return true;
177 return false;
178178 BufferSize = InitSize;
179179 } else
180180 BufferSize = *N;
181181
182182 S.reset(Buf, BufferSize);
183 return false;
183 return true;
184184 }
185185
186186 #endif
339339
340340 if (AST == nullptr)
341341 InternalStatus = demangle_invalid_mangled_name;
342 else if (initializeOutputStream(Buf, N, S, 1024))
342 else if (!initializeOutputStream(Buf, N, S, 1024))
343343 InternalStatus = demangle_memory_alloc_failure;
344344 else {
345345 assert(Parser.ForwardTemplateRefs.empty());
395395
396396 static char *printNode(const Node *RootNode, char *Buf, size_t *N) {
397397 OutputStream S;
398 if (initializeOutputStream(Buf, N, S, 128))
398 if (!initializeOutputStream(Buf, N, S, 128))
399399 return nullptr;
400400 RootNode->print(S);
401401 S += '\0';
440440 const Node *Name = static_cast(RootNode)->getName();
441441
442442 OutputStream S;
443 if (initializeOutputStream(Buf, N, S, 128))
443 if (!initializeOutputStream(Buf, N, S, 128))
444444 return nullptr;
445445
446446 KeepGoingLocalFunction:
493493 NodeArray Params = static_cast(RootNode)->getParams();
494494
495495 OutputStream S;
496 if (initializeOutputStream(Buf, N, S, 128))
496 if (!initializeOutputStream(Buf, N, S, 128))
497497 return nullptr;
498498
499499 S += '(';
511511 return nullptr;
512512
513513 OutputStream S;
514 if (initializeOutputStream(Buf, N, S, 128))
514 if (!initializeOutputStream(Buf, N, S, 128))
515515 return nullptr;
516516
517517 if (const Node *Ret =
873873 // Render this class template name into a string buffer so that we can
874874 // memorize it for the purpose of back-referencing.
875875 OutputStream OS;
876 if (initializeOutputStream(nullptr, nullptr, OS, 1024))
876 if (!initializeOutputStream(nullptr, nullptr, OS, 1024))
877877 // FIXME: Propagate out-of-memory as an error?
878878 std::terminate();
879879 Identifier->output(OS, OF_Default);
12061206 if (MangledName.empty())
12071207 goto StringLiteralError;
12081208
1209 if (initializeOutputStream(nullptr, nullptr, OS, 1024))
1209 if (!initializeOutputStream(nullptr, nullptr, OS, 1024))
12101210 // FIXME: Propagate out-of-memory as an error?
12111211 std::terminate();
12121212 if (IsWcharT) {
13291329
13301330 // Render the parent symbol's name into a buffer.
13311331 OutputStream OS;
1332 if (initializeOutputStream(nullptr, nullptr, OS, 1024))
1332 if (!initializeOutputStream(nullptr, nullptr, OS, 1024))
13331333 // FIXME: Propagate out-of-memory as an error?
13341334 std::terminate();
13351335 OS << '`';
21552155
21562156 // Create an output stream so we can render each type.
21572157 OutputStream OS;
2158 if (initializeOutputStream(nullptr, nullptr, OS, 1024))
2158 if (!initializeOutputStream(nullptr, nullptr, OS, 1024))
21592159 std::terminate();
21602160 for (size_t I = 0; I < Backrefs.FunctionParamCount; ++I) {
21612161 OS.setCurrentPosition(0);
21932193
21942194 if (D.Error)
21952195 InternalStatus = demangle_invalid_mangled_name;
2196 else if (initializeOutputStream(Buf, N, S, 1024))
2196 else if (!initializeOutputStream(Buf, N, S, 1024))
21972197 InternalStatus = demangle_memory_alloc_failure;
21982198 else {
21992199 AST->output(S, OF_Default);