[PATCH] D69458: lld/COFF: Simplify getOutputPath() using sys::path functions.
Nico Weber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 28 07:38:45 PDT 2019
This revision was automatically updated to reflect the committed changes.
thakis marked an inline comment as done.
Closed by commit rGb911d2db5dd8: lld/COFF: Simplify getOutputPath() using sys::path functions. (authored by thakis).
Changed prior to commit:
https://reviews.llvm.org/D69458?vs=226528&id=226663#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69458/new/
https://reviews.llvm.org/D69458
Files:
lld/COFF/Driver.cpp
llvm/include/llvm/Support/Path.h
Index: llvm/include/llvm/Support/Path.h
===================================================================
--- llvm/include/llvm/Support/Path.h
+++ llvm/include/llvm/Support/Path.h
@@ -121,6 +121,8 @@
/// Remove the last component from \a path unless it is the root dir.
///
+/// Similar to the POSIX "dirname" utility.
+///
/// @code
/// directory/filename.cpp => directory/
/// directory/ => directory
@@ -295,7 +297,7 @@
///
/// @param path Input path.
/// @result The filename part of \a path. This is defined as the last component
-/// of \a path.
+/// of \a path. Similar to the POSIX "basename" utility.
StringRef filename(StringRef path, Style style = Style::native);
/// Get stem.
Index: lld/COFF/Driver.cpp
===================================================================
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -104,10 +104,7 @@
// Drop directory components and replace extension with ".exe" or ".dll".
static std::string getOutputPath(StringRef path) {
- auto p = path.find_last_of("\\/");
- StringRef s = (p == StringRef::npos) ? path : path.substr(p + 1);
- const char* e = config->dll ? ".dll" : ".exe";
- return (s.substr(0, s.rfind('.')) + e).str();
+ return (sys::path::stem(path) + (config->dll ? ".dll" : ".exe")).str();
}
// Returns true if S matches /crtend.?\.o$/.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69458.226663.patch
Type: text/x-patch
Size: 1362 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191028/a2013693/attachment.bin>
More information about the llvm-commits
mailing list