From a9c28d33d40099881540f9b4e6cdac3adad32a65 Mon Sep 17 00:00:00 2001 From: James Henderson Date: Fri, 12 Feb 2021 14:18:21 +0000 Subject: [PATCH] [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 --- test/Object/macho-invalid.test | 2 +- test/Object/nm-archive.test | 2 +- test/Object/nm-shared-object.test | 2 +- test/Object/nm-tapi-invalids.test | 6 +++--- test/tools/llvm-nm/dynamic.test | 2 +- test/tools/llvm-nm/invalid-input.test | 2 +- tools/llvm-nm/llvm-nm.cpp | 10 +++++----- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/test/Object/macho-invalid.test b/test/Object/macho-invalid.test index f928b7edc68..f149ace70d4 100644 --- a/test/Object/macho-invalid.test +++ b/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/test/Object/nm-archive.test b/test/Object/nm-archive.test index 89e88fe3ee1..0244949adea 100644 --- a/test/Object/nm-archive.test +++ b/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/test/Object/nm-shared-object.test b/test/Object/nm-shared-object.test index a9eb379985e..8153715b4c5 100644 --- a/test/Object/nm-shared-object.test +++ b/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/test/Object/nm-tapi-invalids.test b/test/Object/nm-tapi-invalids.test index 11ded10c6c6..da23c833c0f 100644 --- a/test/Object/nm-tapi-invalids.test +++ b/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/test/tools/llvm-nm/dynamic.test b/test/tools/llvm-nm/dynamic.test index 732da61afe2..18b2a58ad6b 100644 --- a/test/tools/llvm-nm/dynamic.test +++ b/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/test/tools/llvm-nm/invalid-input.test b/test/tools/llvm-nm/invalid-input.test index 773306b267d..ad9195613d4 100644 --- a/test/tools/llvm-nm/invalid-input.test +++ b/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/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp index 2487d3b2bd5..bf5a43107a2 100644 --- a/tools/llvm-nm/llvm-nm.cpp +++ b/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 {