[llvm] r374780 - Revert r374771 "[llvm-size] Tidy up error messages (PR42970)"
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 14 07:44:26 PDT 2019
Author: nico
Date: Mon Oct 14 07:44:26 2019
New Revision: 374780
URL: http://llvm.org/viewvc/llvm-project?rev=374780&view=rev
Log:
Revert r374771 "[llvm-size] Tidy up error messages (PR42970)"
This reverts commit 83e52f5e1150018329b8907bb014c77ac382d611.
Makes Object/macho-invalid.test fail everywhere, e.g. here:
http://lab.llvm.org:8011/builders/llvm-hexagon-elf/builds/23669/steps/test-llvm/logs/FAIL%3A%20LLVM%3A%3Amacho-invalid.test
Modified:
llvm/trunk/test/tools/llvm-size/invalid-input.test
llvm/trunk/test/tools/llvm-size/no-input.test
llvm/trunk/tools/llvm-size/llvm-size.cpp
Modified: llvm/trunk/test/tools/llvm-size/invalid-input.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-size/invalid-input.test?rev=374780&r1=374779&r2=374780&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-size/invalid-input.test (original)
+++ llvm/trunk/test/tools/llvm-size/invalid-input.test Mon Oct 14 07:44:26 2019
@@ -1,15 +1,19 @@
## Show that llvm-size reports an error when passed an input file in an
## unknown format.
+## FIXME: The error messages tested here are not consistently formatted, and the
+## second one doesn't even return with a non-zero exit code.
+## See https://bugs.llvm.org/show_bug.cgi?id=42970.
+
# RUN: not llvm-size %s 2>&1 | FileCheck %s -DFILE=%s --check-prefix=UNRECOGNIZED
-# UNRECOGNIZED: {{.*}}llvm-size{{(.*)}}: error: '[[FILE]]': The file was not recognized as a valid object file
+# UNRECOGNIZED: {{.*}}llvm-size{{(.*)}}: [[FILE]] The file was not recognized as a valid object file
## Show that llvm-size reports an error when passed an input file in an
## unsupported format.
# RUN: yaml2obj %s -o %t
-# RUN: not llvm-size %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=NOTSUPPORTED
-# NOTSUPPORTED: {{.*}}llvm-size{{(.*)}}: error: '[[FILE]]': unsupported file type
+# RUN: llvm-size %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=NOTSUPPORTED
+# NOTSUPPORTED: {{.*}}llvm-size{{(.*)}}: [[FILE]]: Unrecognized file type.
--- !minidump
Streams:
Modified: llvm/trunk/test/tools/llvm-size/no-input.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-size/no-input.test?rev=374780&r1=374779&r2=374780&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-size/no-input.test (original)
+++ llvm/trunk/test/tools/llvm-size/no-input.test Mon Oct 14 07:44:26 2019
@@ -1,7 +1,7 @@
## Show that llvm-size emits an error if passed in a non-existent file.
# RUN: not llvm-size %t.blah 2>&1 | FileCheck %s -DFILE=%t.blah --check-prefix=ENOENT
-# ENOENT: {{.*}}llvm-size{{.*}}: error: '[[FILE]]': {{[Nn]}}o such file or directory
+# ENOENT: {{.*}}llvm-size{{.*}}: [[FILE]] {{[Nn]}}o such file or directory
## Show that llvm-size reads a.out if not passed any file.
Modified: llvm/trunk/tools/llvm-size/llvm-size.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-size/llvm-size.cpp?rev=374780&r1=374779&r2=374780&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-size/llvm-size.cpp (original)
+++ llvm/trunk/tools/llvm-size/llvm-size.cpp Mon Oct 14 07:44:26 2019
@@ -24,7 +24,6 @@
#include "llvm/Support/Format.h"
#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/WithColor.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <string>
@@ -107,9 +106,11 @@ static bool HadError = false;
static std::string ToolName;
-static void error(const Twine &Message, StringRef File) {
+static bool error(Twine Message) {
HadError = true;
- WithColor::error(errs(), ToolName) << "'" << File << "': " << Message << "\n";
+ errs() << ToolName << ": " << Message << ".\n";
+ errs().flush();
+ return true;
}
// This version of error() prints the archive name and member name, for example:
@@ -118,7 +119,7 @@ static void error(const Twine &Message,
static void error(llvm::Error E, StringRef FileName, const Archive::Child &C,
StringRef ArchitectureName = StringRef()) {
HadError = true;
- WithColor::error(errs(), ToolName) << "'" << FileName << "'";
+ errs() << ToolName << ": " << FileName;
Expected<StringRef> NameOrErr = C.getName();
// TODO: if we have a error getting the name then it would be nice to print
@@ -137,7 +138,7 @@ static void error(llvm::Error E, StringR
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 // is from, for example: "foo.o (for architecture i386)" after the ToolName
@@ -146,7 +147,7 @@ static void error(llvm::Error E, StringR
static void error(llvm::Error E, StringRef FileName,
StringRef ArchitectureName = StringRef()) {
HadError = true;
- WithColor::error(errs(), ToolName) << "'" << FileName << "'";
+ errs() << ToolName << ": " << FileName;
if (!ArchitectureName.empty())
errs() << " (for architecture " << ArchitectureName << ") ";
@@ -155,7 +156,7 @@ static void error(llvm::Error E, StringR
raw_string_ostream OS(Buf);
logAllUnhandledErrors(std::move(E), OS);
OS.flush();
- errs() << ": " << Buf << "\n";
+ errs() << " " << Buf << "\n";
}
/// Get the length of the string that represents @p num in Radix including the
@@ -528,7 +529,7 @@ static bool checkMachOAndArchFlags(Objec
if (none_of(ArchFlags, [&](const std::string &Name) {
return Name == T.getArchName();
})) {
- error("no architecture specified", Filename);
+ error(Filename + ": No architecture specified");
return false;
}
return true;
@@ -657,15 +658,15 @@ static void printFileSectionSizes(String
error(std::move(Err), UA->getFileName());
} else {
consumeError(AOrErr.takeError());
- error("mach-o universal file for architecture " +
- StringRef(I->getArchFlagName()) +
- " is not a mach-o file or an archive file",
- file);
+ error("Mach-O universal file: " + file + " for architecture " +
+ StringRef(I->getArchFlagName()) +
+ " is not a Mach-O file or an archive file");
}
}
}
if (!ArchFound) {
- error("file does not contain architecture " + ArchFlags[i], file);
+ errs() << ToolName << ": file: " << file
+ << " does not contain architecture" << ArchFlags[i] << ".\n";
return;
}
}
@@ -739,10 +740,9 @@ static void printFileSectionSizes(String
error(std::move(Err), UA->getFileName());
} else {
consumeError(AOrErr.takeError());
- error("mach-o universal file for architecture " +
- StringRef(I->getArchFlagName()) +
- " is not a mach-o file or an archive file",
- file);
+ error("Mach-O universal file: " + file + " for architecture " +
+ StringRef(I->getArchFlagName()) +
+ " is not a Mach-O file or an archive file");
}
return;
}
@@ -816,10 +816,9 @@ static void printFileSectionSizes(String
error(std::move(Err), UA->getFileName());
} else {
consumeError(AOrErr.takeError());
- error("mach-o universal file for architecture " +
- StringRef(I->getArchFlagName()) +
- " is not a mach-o file or an archive file",
- file);
+ error("Mach-O universal file: " + file + " for architecture " +
+ StringRef(I->getArchFlagName()) +
+ " is not a Mach-O file or an archive file");
}
}
} else if (ObjectFile *o = dyn_cast<ObjectFile>(&Bin)) {
@@ -837,7 +836,8 @@ static void printFileSectionSizes(String
outs() << "\n";
}
} else {
- error("unsupported file type", file);
+ errs() << ToolName << ": " << file << ": "
+ << "Unrecognized file type.\n";
}
// System V adds an extra newline at the end of each file.
if (OutputFormat == sysv)
More information about the llvm-commits
mailing list