diff --git a/llvm/test/tools/llvm-objdump/long-option-style.test b/llvm/test/tools/llvm-objdump/long-option-style.test new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-objdump/long-option-style.test @@ -0,0 +1,18 @@ +## Don't make symlinks on Windows. +# UNSUPPORTED: system-windows + +# RUN: rm -rf %t +# RUN: mkdir %t +# RUN: ln -s llvm-objdump %t/otool + +# RUN: llvm-objdump --help | FileCheck --check-prefix=LLVM-OBJDUMP %s +# RUN: not llvm-objdump -help 2>&1 | FileCheck --check-prefix=UNKNOWN %s + +# LLVM-OBJDUMP: USAGE: llvm-objdump + +# UNKNOWN: llvm-objdump: Unknown command line argument '-help'. + +# RUN: %t/otool -help | FileCheck --check-prefix=OTOOL %s +# RUN: %t/otool --help | FileCheck --check-prefix=OTOOL %s + +# OTOOL: USAGE: otool diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -2339,9 +2339,11 @@ // Register the target printer for --version. cl::AddExtraVersionPrinter(TargetRegistry::printRegisteredTargetsForVersion); + // In otool mode, support + bool LongOptionsUseDoubleDash = + StringRef(argv[0]).find("otool") == std::string::npos; cl::ParseCommandLineOptions(argc, argv, "llvm object file dumper\n", nullptr, - /*EnvVar=*/nullptr, - /*LongOptionsUseDoubleDash=*/true); + /*EnvVar=*/nullptr, LongOptionsUseDoubleDash); if (StartAddress >= StopAddress) reportCmdLineError("start address should be less than stop address");