[llvm] 94828af - [llvm-nm] Tidy up error messages

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 15 05:57:39 PST 2021


Author: James Henderson
Date: 2021-02-15T13:54:08Z
New Revision: 94828afd0a178d00abec87143b48fe0d7c063198

URL: https://github.com/llvm/llvm-project/commit/94828afd0a178d00abec87143b48fe0d7c063198
DIFF: https://github.com/llvm/llvm-project/commit/94828afd0a178d00abec87143b48fe0d7c063198.diff

LOG: [llvm-nm] Tidy up error messages

This adds colons to separate the file name from the message, removes a
duplicate space, and removes a trailing full stop from some messages.
These help bring the error messages into line with other tools, as well
as making all llvm-nm message more self-consistent.

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

Reviewed by: Higuoxing, rupprecht, MaskRay

Added: 
    

Modified: 
    llvm/test/Object/macho-invalid.test
    llvm/test/Object/nm-archive.test
    llvm/test/Object/nm-shared-object.test
    llvm/test/Object/nm-tapi-invalids.test
    llvm/test/tools/llvm-nm/dynamic.test
    llvm/test/tools/llvm-nm/invalid-input.test
    llvm/tools/llvm-nm/llvm-nm.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/test/Object/macho-invalid.test b/llvm/test/Object/macho-invalid.test
index f928b7edc686..f149ace70d42 100644
--- a/llvm/test/Object/macho-invalid.test
+++ b/llvm/test/Object/macho-invalid.test
@@ -108,7 +108,7 @@ RUN: not llvm-objdump --macho --private-headers %p/Inputs/macho-invalid-segment-
 INVALID-SEGMENT-FILEOFF: macho-invalid-segment-fileoff': truncated or malformed object (load command 0 fileoff field in LC_SEGMENT extends past the end of the file)
 
 RUN: not llvm-nm %p/Inputs/macho-invalid-segment-fileoff 2>&1 | FileCheck -check-prefix INVALID-SEGMENT-FILEOFF-NM %s
-INVALID-SEGMENT-FILEOFF-NM: macho-invalid-segment-fileoff truncated or malformed object (load command 0 fileoff field in LC_SEGMENT extends past the end of the file)
+INVALID-SEGMENT-FILEOFF-NM: macho-invalid-segment-fileoff: truncated or malformed object (load command 0 fileoff field in LC_SEGMENT extends past the end of the file)
 
 RUN: not llvm-size %p/Inputs/macho-invalid-segment-fileoff 2>&1 | FileCheck -DFILE=%p/Inputs/macho-invalid-segment-fileoff -check-prefix INVALID-SEGMENT-FILEOFF-SIZE %s
 INVALID-SEGMENT-FILEOFF-SIZE: error: '[[FILE]]': truncated or malformed object (load command 0 fileoff field in LC_SEGMENT extends past the end of the file)

diff  --git a/llvm/test/Object/nm-archive.test b/llvm/test/Object/nm-archive.test
index 89e88fe3ee14..0244949adeae 100644
--- a/llvm/test/Object/nm-archive.test
+++ b/llvm/test/Object/nm-archive.test
@@ -58,7 +58,7 @@ GNU AR is able to parse the unaligned member and warns about the member with
 the unknown format. We should probably simply warn on both. For now we just
 produce an error for the unknown format.
 RUN: not llvm-nm %p/Inputs/corrupt-archive.a 2>&1 | FileCheck %s -check-prefix CORRUPT
-CORRUPT: corrupt-archive.a(trivial-object-test2.elf-x86-64) Insufficient alignment
+CORRUPT: corrupt-archive.a(trivial-object-test2.elf-x86-64): Insufficient alignment
 
 
 RUN: llvm-nm %p/Inputs/thin.a | FileCheck %s -check-prefix THIN

diff  --git a/llvm/test/Object/nm-shared-object.test b/llvm/test/Object/nm-shared-object.test
index a9eb379985e4..8153715b4c5f 100644
--- a/llvm/test/Object/nm-shared-object.test
+++ b/llvm/test/Object/nm-shared-object.test
@@ -32,7 +32,7 @@
 # RUN: not llvm-nm -D %p/Inputs/trivial-object-test.coff-i386 2>&1 \
 # RUN:         | FileCheck %s -check-prefix ERROR
 
-# ERROR: File format has no dynamic symbol table.
+# ERROR: File format has no dynamic symbol table
 
 # RUN: yaml2obj %s -o %t.elf-i386
 # RUN: llvm-nm -D %t.elf-i386 2>&1 | FileCheck %s -check-prefix=NO-SYMBOLS

diff  --git a/llvm/test/Object/nm-tapi-invalids.test b/llvm/test/Object/nm-tapi-invalids.test
index 11ded10c6c67..da23c833c0f6 100644
--- a/llvm/test/Object/nm-tapi-invalids.test
+++ b/llvm/test/Object/nm-tapi-invalids.test
@@ -8,13 +8,13 @@ RUN: not llvm-nm %p/Inputs/tapi-invalid-v3.tbd 2>&1\
 RUN:          | FileCheck %s -check-prefix V3
 
 # Typo Check
-V1: tapi-invalid-v1.tbd malformed file
+V1: tapi-invalid-v1.tbd: malformed file
 V1-NEXT: tapi-invalid-v1.tbd:11:1: error: unknown key 'expors'
 
 # Missing required key
-V2: tapi-invalid-v2.tbd malformed file
+V2: tapi-invalid-v2.tbd: malformed file
 V2-NEXT: tapi-invalid-v2.tbd:2:1: error: missing required key 'archs'
 
 # v2 key in v3 specified file
-V3: tapi-invalid-v3.tbd malformed file
+V3: tapi-invalid-v3.tbd: malformed file
 V3-NEXT: tapi-invalid-v3.tbd:19:1: error: unknown key 'swift-version'

diff  --git a/llvm/test/tools/llvm-nm/dynamic.test b/llvm/test/tools/llvm-nm/dynamic.test
index 732da61afe2a..18b2a58ad6b4 100644
--- a/llvm/test/tools/llvm-nm/dynamic.test
+++ b/llvm/test/tools/llvm-nm/dynamic.test
@@ -190,4 +190,4 @@ DynamicSymbols:
 # RUN:   FileCheck %s -DFILE=%t4-broken-dynsym.o --check-prefix=VERSION-ERR4
 
 # VERSION-ERR4: warning: unable to read symbol versions: unable to read flags for symbol with index 1: section [index 4] has invalid sh_entsize: expected 24, but got 255
-# VERSION-ERR4: error: [[FILE]] section [index 4] has invalid sh_entsize: expected 24, but got 255
+# VERSION-ERR4: error: [[FILE]]: section [index 4] has invalid sh_entsize: expected 24, but got 255

diff  --git a/llvm/test/tools/llvm-nm/invalid-input.test b/llvm/test/tools/llvm-nm/invalid-input.test
index 773306b267d6..ad9195613d40 100644
--- a/llvm/test/tools/llvm-nm/invalid-input.test
+++ b/llvm/test/tools/llvm-nm/invalid-input.test
@@ -1,2 +1,2 @@
 RUN: not llvm-nm %s 2>&1 | FileCheck %s -check-prefix=UNKNOWN_FILE_TYPE
-UNKNOWN_FILE_TYPE: {{.*}}invalid-input.test The file was not recognized as a valid object file
+UNKNOWN_FILE_TYPE: {{.*}}invalid-input.test: The file was not recognized as a valid object file

diff  --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp
index 2487d3b2bd5b..bf5a43107a25 100644
--- a/llvm/tools/llvm-nm/llvm-nm.cpp
+++ b/llvm/tools/llvm-nm/llvm-nm.cpp
@@ -232,7 +232,7 @@ std::string ToolName;
 
 static void error(Twine Message, Twine Path = Twine()) {
   HadError = true;
-  WithColor::error(errs(), ToolName) << Path << ": " << Message << ".\n";
+  WithColor::error(errs(), ToolName) << Path << ": " << Message << "\n";
 }
 
 static bool error(std::error_code EC, Twine Path = Twine()) {
@@ -262,13 +262,13 @@ static void error(llvm::Error E, StringRef FileName, const Archive::Child &C,
     errs() << "(" << NameOrErr.get() << ")";
 
   if (!ArchitectureName.empty())
-    errs() << " (for architecture " << ArchitectureName << ") ";
+    errs() << " (for architecture " << ArchitectureName << ")";
 
   std::string Buf;
   raw_string_ostream OS(Buf);
   logAllUnhandledErrors(std::move(E), OS);
   OS.flush();
-  errs() << " " << Buf << "\n";
+  errs() << ": " << Buf << "\n";
 }
 
 // This version of error() prints the file name and which architecture slice it
@@ -281,13 +281,13 @@ static void error(llvm::Error E, StringRef FileName,
   WithColor::error(errs(), ToolName) << FileName;
 
   if (!ArchitectureName.empty())
-    errs() << " (for architecture " << ArchitectureName << ") ";
+    errs() << " (for architecture " << ArchitectureName << ")";
 
   std::string Buf;
   raw_string_ostream OS(Buf);
   logAllUnhandledErrors(std::move(E), OS);
   OS.flush();
-  errs() << " " << Buf << "\n";
+  errs() << ": " << Buf << "\n";
 }
 
 namespace {


        


More information about the llvm-commits mailing list