[PATCH] D69458: lld/COFF: Simplify getOutputPath() using sys::path functions.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 27 19:19:25 PDT 2019
ruiu accepted this revision.
ruiu added a comment.
This revision is now accepted and ready to land.
LGTM
================
Comment at: lld/COFF/Driver.cpp:107-108
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();
+ SmallString<128> outputPath = sys::path::filename(path);
+ sys::path::replace_extension(outputPath, config->dll ? ".dll" : ".exe");
+ return outputPath.str();
----------------
It seems that you can simplify this further to `sys::path::stem(path) + (config->dll ? ".dll" : ".exe")`, but I'm fine with this too.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69458/new/
https://reviews.llvm.org/D69458
More information about the llvm-commits
mailing list