Skip to content

Commit

Permalink
[llvm-nm] Tidy up error messages
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jh7370 committed Feb 15, 2021
1 parent eefd620 commit 94828af
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion llvm/test/Object/macho-invalid.test
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Object/nm-archive.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Object/nm-shared-object.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/Object/nm-tapi-invalids.test
Original file line number Diff line number Diff line change
Expand Up @@ -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'
2 changes: 1 addition & 1 deletion llvm/test/tools/llvm-nm/dynamic.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion llvm/test/tools/llvm-nm/invalid-input.test
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions llvm/tools/llvm-nm/llvm-nm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit 94828af

Please sign in to comment.