summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2013-10-22 19:01:47 +0000
committerRui Ueyama <ruiu@google.com>2013-10-22 19:01:47 +0000
commit7c5bc2fc2bd1d57f870009bb71548ee7a0756056 (patch)
tree1214a2103c6a2bf85d85cc7d2c175eb98ee5f1bf
parent08a8660260a10b93e49e718be6aedacb5560a250 (diff)
downloadbcm5719-llvm-7c5bc2fc2bd1d57f870009bb71548ee7a0756056.tar.gz
bcm5719-llvm-7c5bc2fc2bd1d57f870009bb71548ee7a0756056.zip
Factor out into a separate function. No functionality change.
llvm-svn: 193186
-rw-r--r--lld/lib/Driver/WinLinkDriver.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/lld/lib/Driver/WinLinkDriver.cpp b/lld/lib/Driver/WinLinkDriver.cpp
index 637e6f40eea..d4fb892b6e4 100644
--- a/lld/lib/Driver/WinLinkDriver.cpp
+++ b/lld/lib/Driver/WinLinkDriver.cpp
@@ -197,6 +197,13 @@ bool parseManifestUac(StringRef option, llvm::Optional<std::string> &level,
}
}
+StringRef replaceExtension(PECOFFLinkingContext &ctx,
+ StringRef path, StringRef extension) {
+ SmallString<128> val = path;
+ llvm::sys::path::replace_extension(val, extension);
+ return ctx.allocateString(val.str());
+}
+
// Handle /failifmismatch option.
bool handleFailIfMismatchOption(StringRef option,
std::map<StringRef, StringRef> &mustMatch,
@@ -628,10 +635,8 @@ WinLinkDriver::parse(int argc, const char *argv[], PECOFFLinkingContext &ctx,
// constructed by replacing an extension of the first input file
// with ".exe".
if (ctx.outputPath().empty()) {
- SmallString<128> firstInputFilePath =
- *dyn_cast<FileNode>(&*inputElements[0])->getPath(ctx);
- llvm::sys::path::replace_extension(firstInputFilePath, ".exe");
- ctx.setOutputPath(ctx.allocateString(firstInputFilePath.str()));
+ StringRef path = *dyn_cast<FileNode>(&*inputElements[0])->getPath(ctx);
+ ctx.setOutputPath(replaceExtension(ctx, path, ".exe"));
}
// If the core linker already started, we need to explicitly call parse() for
OpenPOWER on IntegriCloud