[llvm] r243240 - [llvm-dwarfump] Don't rely on global state, part 3.

Rafael EspĂ­ndola rafael.espindola at gmail.com
Mon Aug 3 14:03:12 PDT 2015


Thanks!

On 26 July 2015 at 01:35, Davide Italiano <davide at freebsd.org> wrote:
> Author: davide
> Date: Sun Jul 26 00:35:59 2015
> New Revision: 243240
>
> URL: http://llvm.org/viewvc/llvm-project?rev=243240&view=rev
> Log:
> [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.
>
> Modified:
>     llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
>
> Modified: llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp?rev=243240&r1=243239&r2=243240&view=diff
> ==============================================================================
> --- llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp (original)
> +++ llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp Sun Jul 26 00:35:59 2015
> @@ -69,27 +69,22 @@ DumpType("debug-dump", cl::init(DIDT_All
>          clEnumValN(DIDT_StrOffsetsDwo, "str_offsets.dwo", ".debug_str_offsets.dwo"),
>          clEnumValEnd));
>
> -static int ReturnValue = EXIT_SUCCESS;
> -
> -static bool error(StringRef Filename, std::error_code EC) {
> +static void error(StringRef Filename, std::error_code EC) {
>    if (!EC)
> -    return false;
> +    return;
>    errs() << Filename << ": " << EC.message() << "\n";
> -  ReturnValue = EXIT_FAILURE;
> -  return true;
> +  exit(1);
>  }
>
>  static void DumpInput(StringRef Filename) {
>    ErrorOr<std::unique_ptr<MemoryBuffer>> BuffOrErr =
>        MemoryBuffer::getFileOrSTDIN(Filename);
> -  if (error(Filename, BuffOrErr.getError()))
> -    return;
> +  error(Filename, BuffOrErr.getError());
>    std::unique_ptr<MemoryBuffer> Buff = std::move(BuffOrErr.get());
>
>    ErrorOr<std::unique_ptr<ObjectFile>> ObjOrErr =
>        ObjectFile::createObjectFile(Buff->getMemBufferRef());
> -  if (error(Filename, ObjOrErr.getError()))
> -    return;
> +  error(Filename, ObjOrErr.getError());
>    ObjectFile &Obj = *ObjOrErr.get();
>
>    std::unique_ptr<DIContext> DICtx(new DWARFContextInMemory(Obj));
> @@ -114,5 +109,5 @@ int main(int argc, char **argv) {
>
>    std::for_each(InputFilenames.begin(), InputFilenames.end(), DumpInput);
>
> -  return ReturnValue;
> +  return EXIT_SUCCESS;
>  }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list