llvm.org GIT mirror llvm / 5e7aab0
[llvm-dwarfump] Don't rely on global state, part 3. Some tools used to rely on a global static variable to keep track of the return value for main(). I changed llvm-cxxdump to use exit(1) and Rafael shortly after did the same with llvm-readobj. This is (yet) another step towards the goal. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243240 91177308-0d34-0410-b5e6-96231b3b80d8 Davide Italiano 4 years ago
1 changed file(s) with 6 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
6868 clEnumValN(DIDT_StrOffsetsDwo, "str_offsets.dwo", ".debug_str_offsets.dwo"),
6969 clEnumValEnd));
7070
71 static int ReturnValue = EXIT_SUCCESS;
72
73 static bool error(StringRef Filename, std::error_code EC) {
71 static void error(StringRef Filename, std::error_code EC) {
7472 if (!EC)
75 return false;
73 return;
7674 errs() << Filename << ": " << EC.message() << "\n";
77 ReturnValue = EXIT_FAILURE;
78 return true;
75 exit(1);
7976 }
8077
8178 static void DumpInput(StringRef Filename) {
8279 ErrorOr> BuffOrErr =
8380 MemoryBuffer::getFileOrSTDIN(Filename);
84 if (error(Filename, BuffOrErr.getError()))
85 return;
81 error(Filename, BuffOrErr.getError());
8682 std::unique_ptr Buff = std::move(BuffOrErr.get());
8783
8884 ErrorOr> ObjOrErr =
8985 ObjectFile::createObjectFile(Buff->getMemBufferRef());
90 if (error(Filename, ObjOrErr.getError()))
91 return;
86 error(Filename, ObjOrErr.getError());
9287 ObjectFile &Obj = *ObjOrErr.get();
9388
9489 std::unique_ptr DICtx(new DWARFContextInMemory(Obj));
113108
114109 std::for_each(InputFilenames.begin(), InputFilenames.end(), DumpInput);
115110
116 return ReturnValue;
111 return EXIT_SUCCESS;
117112 }