[PATCH] D51133: win: Omit ".exe" from lld warning and error messages.
Nico Weber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 22 16:11:47 PDT 2018
thakis updated this revision to Diff 162093.
thakis added a comment.
Thanks, that's a good suggestion. I put the new function in Common/Args.h; I'm not sure if that's the best place.
https://reviews.llvm.org/D51133
Files:
lld/COFF/Driver.cpp
lld/Common/Args.cpp
lld/ELF/Driver.cpp
lld/include/lld/Common/Args.h
lld/lib/Driver/DarwinLdDriver.cpp
lld/test/ELF/lto-plugin-ignore.s
lld/wasm/Driver.cpp
Index: lld/wasm/Driver.cpp
===================================================================
--- lld/wasm/Driver.cpp
+++ lld/wasm/Driver.cpp
@@ -78,7 +78,7 @@
bool lld::wasm::link(ArrayRef<const char *> Args, bool CanExitEarly,
raw_ostream &Error) {
- errorHandler().LogName = sys::path::filename(Args[0]);
+ errorHandler().LogName = args::FilenameWithoutExe(Args[0]);
errorHandler().ErrorOS = &Error;
errorHandler().ColorDiagnostics = Error.has_colors();
errorHandler().ErrorLimitExceededMsg =
Index: lld/test/ELF/lto-plugin-ignore.s
===================================================================
--- lld/test/ELF/lto-plugin-ignore.s
+++ lld/test/ELF/lto-plugin-ignore.s
@@ -6,5 +6,5 @@
# RUN: -plugin-opt=-data-sections -plugin-opt=thinlto -o /dev/null
# RUN: not ld.lld %t -plugin-opt=-abc -plugin-opt=-xyz 2>&1 | FileCheck %s
-# CHECK: error: --plugin-opt: ld.lld{{.*}}: Unknown command line argument '-abc'
-# CHECK: error: --plugin-opt: ld.lld{{.*}}: Unknown command line argument '-xyz'
+# CHECK: error: --plugin-opt: ld.lld: Unknown command line argument '-abc'
+# CHECK: error: --plugin-opt: ld.lld: Unknown command line argument '-xyz'
Index: lld/lib/Driver/DarwinLdDriver.cpp
===================================================================
--- lld/lib/Driver/DarwinLdDriver.cpp
+++ lld/lib/Driver/DarwinLdDriver.cpp
@@ -1143,7 +1143,7 @@
/// This is where the link is actually performed.
bool link(llvm::ArrayRef<const char *> args, bool CanExitEarly,
raw_ostream &Error) {
- errorHandler().LogName = llvm::sys::path::filename(args[0]);
+ errorHandler().LogName = args::FilenameWithoutExe(args[0]);
errorHandler().ErrorLimitExceededMsg =
"too many errors emitted, stopping now (use "
"'-error-limit 0' to see all errors)";
Index: lld/include/lld/Common/Args.h
===================================================================
--- lld/include/lld/Common/Args.h
+++ lld/include/lld/Common/Args.h
@@ -29,6 +29,9 @@
uint64_t Default);
std::vector<StringRef> getLines(MemoryBufferRef MB);
+
+StringRef FilenameWithoutExe(StringRef path);
+
} // namespace args
} // namespace lld
Index: lld/ELF/Driver.cpp
===================================================================
--- lld/ELF/Driver.cpp
+++ lld/ELF/Driver.cpp
@@ -74,7 +74,7 @@
bool elf::link(ArrayRef<const char *> Args, bool CanExitEarly,
raw_ostream &Error) {
- errorHandler().LogName = sys::path::filename(Args[0]);
+ errorHandler().LogName = args::FilenameWithoutExe(Args[0]);
errorHandler().ErrorLimitExceededMsg =
"too many errors emitted, stopping now (use "
"-error-limit=0 to see all errors)";
Index: lld/Common/Args.cpp
===================================================================
--- lld/Common/Args.cpp
+++ lld/Common/Args.cpp
@@ -13,6 +13,7 @@
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Option/ArgList.h"
+#include "llvm/Support/Path.h"
using namespace llvm;
using namespace lld;
@@ -64,3 +65,9 @@
}
return Ret;
}
+
+StringRef lld::args::FilenameWithoutExe(StringRef path) {
+ if (sys::path::extension(path).equals_lower(".exe"))
+ return sys::path::stem(path);
+ return sys::path::filename(path);
+}
Index: lld/COFF/Driver.cpp
===================================================================
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -56,7 +56,7 @@
LinkerDriver *Driver;
bool link(ArrayRef<const char *> Args, bool CanExitEarly, raw_ostream &Diag) {
- errorHandler().LogName = sys::path::filename(Args[0]);
+ errorHandler().LogName = args::FilenameWithoutExe(Args[0]);
errorHandler().ErrorOS = &Diag;
errorHandler().ColorDiagnostics = Diag.has_colors();
errorHandler().ErrorLimitExceededMsg =
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51133.162093.patch
Type: text/x-patch
Size: 3823 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180822/6ed7100c/attachment.bin>
More information about the llvm-commits
mailing list