[llvm] r363350 - [llvm-objcopy] Changed command line parsing errors

Alex Brachet via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 13 19:04:03 PDT 2019


Author: abrachet
Date: Thu Jun 13 19:04:02 2019
New Revision: 363350

URL: http://llvm.org/viewvc/llvm-project?rev=363350&view=rev
Log:
[llvm-objcopy] Changed command line parsing errors

Summary: Tidied up errors during command line parsing to be more consistent with the rest of llvm-objcopy errors.

Reviewers: jhenderson, rupprecht, espindola, alexshap

Reviewed By: jhenderson, rupprecht

Subscribers: emaste, arichardson, MaskRay, llvm-commits, jakehehrlich

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D62973

Modified:
    llvm/trunk/test/tools/llvm-objcopy/ELF/bad-output-format.test
    llvm/trunk/test/tools/llvm-objcopy/ELF/binary-input-error.test
    llvm/trunk/test/tools/llvm-objcopy/ELF/compress-and-decompress-debug-sections-error.test
    llvm/trunk/test/tools/llvm-objcopy/ELF/compress-debug-sections-invalid-format.test
    llvm/trunk/test/tools/llvm-objcopy/ELF/help-message.test
    llvm/trunk/test/tools/llvm-objcopy/ELF/redefine-symbol.test
    llvm/trunk/test/tools/llvm-objcopy/ELF/rename-section-flag.test
    llvm/trunk/test/tools/llvm-objcopy/ELF/rename-section.test
    llvm/trunk/test/tools/llvm-objcopy/ELF/set-section-flags.test
    llvm/trunk/test/tools/llvm-objcopy/ELF/strip-multiple-files.test
    llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp
    llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp

Modified: llvm/trunk/test/tools/llvm-objcopy/ELF/bad-output-format.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/ELF/bad-output-format.test?rev=363350&r1=363349&r2=363350&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objcopy/ELF/bad-output-format.test (original)
+++ llvm/trunk/test/tools/llvm-objcopy/ELF/bad-output-format.test Thu Jun 13 19:04:02 2019
@@ -15,5 +15,5 @@ FileHeader:
   Type:            ET_EXEC
   Machine:         EM_386
 
-# BAD-OUTPUT-FORMAT: Invalid output format: 'xyz'
-# BAD-OUTPUT-FORMAT-BSD: Invalid output format: 'xyz-freebsd'
+# BAD-OUTPUT-FORMAT: invalid output format: 'xyz'
+# BAD-OUTPUT-FORMAT-BSD: invalid output format: 'xyz-freebsd'

Modified: llvm/trunk/test/tools/llvm-objcopy/ELF/binary-input-error.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/ELF/binary-input-error.test?rev=363350&r1=363349&r2=363350&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objcopy/ELF/binary-input-error.test (original)
+++ llvm/trunk/test/tools/llvm-objcopy/ELF/binary-input-error.test Thu Jun 13 19:04:02 2019
@@ -6,5 +6,5 @@
 # RUN: not llvm-objcopy -I binary -B xyz %t.txt %t.o 2>&1 \
 # RUN:   | FileCheck %s --check-prefix=BAD-BINARY-ARCH
 
-# MISSING-BINARY-ARCH: Specified binary input without specifiying an architecture
-# BAD-BINARY-ARCH: Invalid architecture: 'xyz'
+# MISSING-BINARY-ARCH: specified binary input without specifiying an architecture
+# BAD-BINARY-ARCH: invalid architecture: 'xyz'

Modified: llvm/trunk/test/tools/llvm-objcopy/ELF/compress-and-decompress-debug-sections-error.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/ELF/compress-and-decompress-debug-sections-error.test?rev=363350&r1=363349&r2=363350&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objcopy/ELF/compress-and-decompress-debug-sections-error.test (original)
+++ llvm/trunk/test/tools/llvm-objcopy/ELF/compress-and-decompress-debug-sections-error.test Thu Jun 13 19:04:02 2019
@@ -3,5 +3,5 @@
 # RUN: yaml2obj %p/Inputs/compress-debug-sections.yaml -o %t.o
 # RUN: not llvm-objcopy --compress-debug-sections=zlib --decompress-debug-sections %t.o 2>&1 | FileCheck %s
 
-# CHECK: Cannot specify --compress-debug-sections at the same time as --decompress-debug-sections at the same time
+# CHECK: cannot specify both --compress-debug-sections and --decompress-debug-sections
 

Modified: llvm/trunk/test/tools/llvm-objcopy/ELF/compress-debug-sections-invalid-format.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/ELF/compress-debug-sections-invalid-format.test?rev=363350&r1=363349&r2=363350&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objcopy/ELF/compress-debug-sections-invalid-format.test (original)
+++ llvm/trunk/test/tools/llvm-objcopy/ELF/compress-debug-sections-invalid-format.test Thu Jun 13 19:04:02 2019
@@ -1,5 +1,5 @@
 # RUN: yaml2obj %p/Inputs/compress-debug-sections.yaml -o %t.o
 # RUN: not llvm-objcopy --compress-debug-sections=zlib-fake %t.o 2>&1 | FileCheck %s
 
-# CHECK: Invalid or unsupported --compress-debug-sections format: zlib-fake
+# CHECK: invalid or unsupported --compress-debug-sections format: zlib-fake
 

Modified: llvm/trunk/test/tools/llvm-objcopy/ELF/help-message.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/ELF/help-message.test?rev=363350&r1=363349&r2=363350&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objcopy/ELF/help-message.test (original)
+++ llvm/trunk/test/tools/llvm-objcopy/ELF/help-message.test Thu Jun 13 19:04:02 2019
@@ -16,4 +16,4 @@
 # OBJCOPY-USAGE:  USAGE: llvm-objcopy
 # STRIP-USAGE:    USAGE: llvm-strip
 # UNKNOWN-ARG:    unknown argument '{{-+}}abcabc'
-# NO-INPUT-FILES: No input file specified
+# NO-INPUT-FILES: no input file specified

Modified: llvm/trunk/test/tools/llvm-objcopy/ELF/redefine-symbol.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/ELF/redefine-symbol.test?rev=363350&r1=363349&r2=363350&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objcopy/ELF/redefine-symbol.test (original)
+++ llvm/trunk/test/tools/llvm-objcopy/ELF/redefine-symbol.test Thu Jun 13 19:04:02 2019
@@ -88,8 +88,8 @@ Symbols:
 #CHECK-NEXT:    Section: .text
 #CHECK-NEXT:  }
 
-#BAD-FORMAT: Bad format for --redefine-sym
-#MULTIPLE-REDEFINITION: Multiple redefinition of symbol foo
+#BAD-FORMAT: bad format for --redefine-sym
+#MULTIPLE-REDEFINITION: multiple redefinition of symbol 'foo'
 #MISSING-SYM-NAME: error: {{.*}}.rename.txt:2: missing new symbol name
 #NO-FILE: error: '{{.*}}.rename-none.txt': {{[Nn]}}o such file or directory
 

Modified: llvm/trunk/test/tools/llvm-objcopy/ELF/rename-section-flag.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/ELF/rename-section-flag.test?rev=363350&r1=363349&r2=363350&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objcopy/ELF/rename-section-flag.test (original)
+++ llvm/trunk/test/tools/llvm-objcopy/ELF/rename-section-flag.test Thu Jun 13 19:04:02 2019
@@ -95,4 +95,4 @@ Sections:
 # WRITE-NEXT:      SHF_WRITE (0x1)
 # CHECK-NEXT:    ]
 
-# BAD-FLAG: Unrecognized section flag 'xyzzy'. Flags supported for GNU compatibility: alloc, load, noload, readonly, debug, code, data, rom, share, contents, merge, strings
+# BAD-FLAG: unrecognized section flag 'xyzzy'. Flags supported for GNU compatibility: alloc, load, noload, readonly, debug, code, data, rom, share, contents, merge, strings

Modified: llvm/trunk/test/tools/llvm-objcopy/ELF/rename-section.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/ELF/rename-section.test?rev=363350&r1=363349&r2=363350&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objcopy/ELF/rename-section.test (original)
+++ llvm/trunk/test/tools/llvm-objcopy/ELF/rename-section.test Thu Jun 13 19:04:02 2019
@@ -26,5 +26,5 @@ Sections:
 # CHECK: Name: .strtab
 # CHECK: Name: .shstrtab
 
-#BAD-FORMAT: Bad format for --rename-section: missing '='
-#MULTIPLE-RENAMES: Multiple renames of section .foo
+#BAD-FORMAT: bad format for --rename-section: missing '='
+#MULTIPLE-RENAMES: multiple renames of section '.foo'

Modified: llvm/trunk/test/tools/llvm-objcopy/ELF/set-section-flags.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/ELF/set-section-flags.test?rev=363350&r1=363349&r2=363350&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objcopy/ELF/set-section-flags.test (original)
+++ llvm/trunk/test/tools/llvm-objcopy/ELF/set-section-flags.test Thu Jun 13 19:04:02 2019
@@ -117,7 +117,7 @@ Sections:
 # WRITE-NEXT:      SHF_WRITE (0x1)
 # CHECK-NEXT:    ]
 
-# BAD-FORMAT: Bad format for --set-section-flags: missing '='
-# MULTIPLE-SETS: --set-section-flags set multiple times for section .foo
+# BAD-FORMAT: bad format for --set-section-flags: missing '='
+# MULTIPLE-SETS: --set-section-flags set multiple times for section '.foo'
 
-# BAD-FLAG: Unrecognized section flag 'xyzzy'. Flags supported for GNU compatibility: alloc, load, noload, readonly, debug, code, data, rom, share, contents, merge, strings
+# BAD-FLAG: unrecognized section flag 'xyzzy'. Flags supported for GNU compatibility: alloc, load, noload, readonly, debug, code, data, rom, share, contents, merge, strings

Modified: llvm/trunk/test/tools/llvm-objcopy/ELF/strip-multiple-files.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/ELF/strip-multiple-files.test?rev=363350&r1=363349&r2=363350&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objcopy/ELF/strip-multiple-files.test (original)
+++ llvm/trunk/test/tools/llvm-objcopy/ELF/strip-multiple-files.test Thu Jun 13 19:04:02 2019
@@ -71,4 +71,4 @@ Symbols:
 # CHECK-NEXT:   }
 # CHECK-NEXT: ]
 
-# BAD-O-FLAG: Multiple input files cannot be used in combination with -o
+# BAD-O-FLAG: multiple input files cannot be used in combination with -o

Modified: llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp?rev=363350&r1=363349&r2=363350&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp (original)
+++ llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp Thu Jun 13 19:04:02 2019
@@ -118,7 +118,7 @@ parseSectionFlagSet(ArrayRef<StringRef>
     if (ParsedFlag == SectionFlag::SecNone)
       return createStringError(
           errc::invalid_argument,
-          "Unrecognized section flag '%s'. Flags supported for GNU "
+          "unrecognized section flag '%s'. Flags supported for GNU "
           "compatibility: alloc, load, noload, readonly, debug, code, data, "
           "rom, share, contents, merge, strings",
           Flag.str().c_str());
@@ -131,7 +131,7 @@ parseSectionFlagSet(ArrayRef<StringRef>
 static Expected<SectionRename> parseRenameSectionValue(StringRef FlagValue) {
   if (!FlagValue.contains('='))
     return createStringError(errc::invalid_argument,
-                             "Bad format for --rename-section: missing '='");
+                             "bad format for --rename-section: missing '='");
 
   // Initial split: ".foo" = ".bar,f1,f2,..."
   auto Old2New = FlagValue.split('=');
@@ -158,7 +158,7 @@ static Expected<SectionFlagsUpdate>
 parseSetSectionFlagValue(StringRef FlagValue) {
   if (!StringRef(FlagValue).contains('='))
     return createStringError(errc::invalid_argument,
-                             "Bad format for --set-section-flags: missing '='");
+                             "bad format for --set-section-flags: missing '='");
 
   // Initial split: ".foo" = "f1,f2,..."
   auto Section2Flags = StringRef(FlagValue).split('=');
@@ -272,7 +272,7 @@ static Expected<const MachineInfo &> get
   auto Iter = ArchMap.find(Arch);
   if (Iter == std::end(ArchMap))
     return createStringError(errc::invalid_argument,
-                             "Invalid architecture: '%s'", Arch.str().c_str());
+                             "invalid architecture: '%s'", Arch.str().c_str());
   return Iter->getValue();
 }
 
@@ -314,7 +314,7 @@ static Expected<MachineInfo> getOutputFo
   auto Iter = OutputFormatMap.find(Format);
   if (Iter == std::end(OutputFormatMap))
     return createStringError(errc::invalid_argument,
-                             "Invalid output format: '%s'",
+                             "invalid output format: '%s'",
                              OriginalFormat.str().c_str());
   MachineInfo MI = Iter->getValue();
   if (IsFreeBSD)
@@ -424,11 +424,11 @@ Expected<DriverConfig> parseObjcopyOptio
     Positional.push_back(Arg->getValue());
 
   if (Positional.empty())
-    return createStringError(errc::invalid_argument, "No input file specified");
+    return createStringError(errc::invalid_argument, "no input file specified");
 
   if (Positional.size() > 2)
     return createStringError(errc::invalid_argument,
-                             "Too many positional arguments");
+                             "too many positional arguments");
 
   CopyConfig Config;
   Config.InputFilename = Positional[0];
@@ -453,7 +453,7 @@ Expected<DriverConfig> parseObjcopyOptio
     if (BinaryArch.empty())
       return createStringError(
           errc::invalid_argument,
-          "Specified binary input without specifiying an architecture");
+          "specified binary input without specifiying an architecture");
     Expected<const MachineInfo &> MI = getMachineInfo(BinaryArch);
     if (!MI)
       return MI.takeError();
@@ -481,7 +481,7 @@ Expected<DriverConfig> parseObjcopyOptio
       if (Config.CompressionType == DebugCompressionType::None)
         return createStringError(
             errc::invalid_argument,
-            "Invalid or unsupported --compress-debug-sections format: %s",
+            "invalid or unsupported --compress-debug-sections format: %s",
             InputArgs.getLastArgValue(OBJCOPY_compress_debug_sections_eq)
                 .str()
                 .c_str());
@@ -526,11 +526,11 @@ Expected<DriverConfig> parseObjcopyOptio
   for (auto Arg : InputArgs.filtered(OBJCOPY_redefine_symbol)) {
     if (!StringRef(Arg->getValue()).contains('='))
       return createStringError(errc::invalid_argument,
-                               "Bad format for --redefine-sym");
+                               "bad format for --redefine-sym");
     auto Old2New = StringRef(Arg->getValue()).split('=');
     if (!Config.SymbolsToRename.insert(Old2New).second)
       return createStringError(errc::invalid_argument,
-                               "Multiple redefinition of symbol %s",
+                               "multiple redefinition of symbol '%s'",
                                Old2New.first.str().c_str());
   }
 
@@ -546,7 +546,7 @@ Expected<DriverConfig> parseObjcopyOptio
       return SR.takeError();
     if (!Config.SectionsToRename.try_emplace(SR->OriginalName, *SR).second)
       return createStringError(errc::invalid_argument,
-                               "Multiple renames of section %s",
+                               "multiple renames of section '%s'",
                                SR->OriginalName.str().c_str());
   }
   for (auto Arg : InputArgs.filtered(OBJCOPY_set_section_flags)) {
@@ -557,7 +557,7 @@ Expected<DriverConfig> parseObjcopyOptio
     if (!Config.SetSectionFlags.try_emplace(SFU->Name, *SFU).second)
       return createStringError(
           errc::invalid_argument,
-          "--set-section-flags set multiple times for section %s",
+          "--set-section-flags set multiple times for section '%s'",
           SFU->Name.str().c_str());
   }
   // Prohibit combinations of --set-section-flags when the section name is used
@@ -693,8 +693,8 @@ Expected<DriverConfig> parseObjcopyOptio
       Config.CompressionType != DebugCompressionType::None) {
     return createStringError(
         errc::invalid_argument,
-        "Cannot specify --compress-debug-sections at the same time as "
-        "--decompress-debug-sections at the same time");
+        "cannot specify both --compress-debug-sections and "
+        "--decompress-debug-sections");
   }
 
   if (Config.DecompressDebugSections && !zlib::isAvailable())
@@ -744,12 +744,12 @@ Expected<DriverConfig> parseStripOptions
     Positional.push_back(Arg->getValue());
 
   if (Positional.empty())
-    return createStringError(errc::invalid_argument, "No input file specified");
+    return createStringError(errc::invalid_argument, "no input file specified");
 
   if (Positional.size() > 1 && InputArgs.hasArg(STRIP_output))
     return createStringError(
         errc::invalid_argument,
-        "Multiple input files cannot be used in combination with -o");
+        "multiple input files cannot be used in combination with -o");
 
   CopyConfig Config;
   bool UseRegexp = InputArgs.hasArg(STRIP_regex);

Modified: llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp?rev=363350&r1=363349&r2=363350&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp (original)
+++ llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp Thu Jun 13 19:04:02 2019
@@ -53,7 +53,7 @@ namespace objcopy {
 StringRef ToolName;
 
 LLVM_ATTRIBUTE_NORETURN void error(Twine Message) {
-  WithColor::error(errs(), ToolName) << Message << ".\n";
+  WithColor::error(errs(), ToolName) << Message << "\n";
   errs().flush();
   exit(1);
 }
@@ -154,7 +154,7 @@ static Error executeObjcopyOnBinary(cons
     return macho::executeObjcopyOnBinary(Config, *MachOBinary, Out);
   else
     return createStringError(object_error::invalid_file_type,
-                             "Unsupported object file format");
+                             "unsupported object file format");
 }
 
 static Error executeObjcopyOnArchive(const CopyConfig &Config,




More information about the llvm-commits mailing list