[lld] r186612 - [PECOFF] Use replace_extension() instead of doing it myself.
Rui Ueyama
ruiu at google.com
Thu Jul 18 14:38:44 PDT 2013
Author: ruiu
Date: Thu Jul 18 16:38:44 2013
New Revision: 186612
URL: http://llvm.org/viewvc/llvm-project?rev=186612&view=rev
Log:
[PECOFF] Use replace_extension() instead of doing it myself.
Modified:
lld/trunk/lib/Driver/WinLinkDriver.cpp
Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=186612&r1=186611&r2=186612&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Thu Jul 18 16:38:44 2013
@@ -15,6 +15,7 @@
#include <cstdlib>
+#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Option/Arg.h"
#include "llvm/Option/Option.h"
@@ -175,11 +176,10 @@ StringRef canonicalizeInputFileName(PECO
// Replace a file extension with ".exe". If the given file has no
// extension, just add ".exe".
-StringRef getDefaultOutputFileName(PECOFFTargetInfo &info, std::string path) {
- StringRef ext = llvm::sys::path::extension(path);
- if (!ext.empty())
- path.erase(path.size() - ext.size());
- return info.allocateString(path.append(".exe"));
+StringRef getDefaultOutputFileName(PECOFFTargetInfo &info, StringRef path) {
+ SmallString<128> smallStr = path;
+ llvm::sys::path::replace_extension(smallStr, ".exe");
+ return info.allocateString(smallStr.str());
}
} // namespace
More information about the llvm-commits
mailing list