[lld] r193186 - Factor out into a separate function. No functionality change.

Rui Ueyama ruiu at google.com
Tue Oct 22 12:01:47 PDT 2013


Author: ruiu
Date: Tue Oct 22 14:01:47 2013
New Revision: 193186

URL: http://llvm.org/viewvc/llvm-project?rev=193186&view=rev
Log:
Factor out into a separate function. No functionality change.

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=193186&r1=193185&r2=193186&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Tue Oct 22 14:01:47 2013
@@ -197,6 +197,13 @@ bool parseManifestUac(StringRef option,
   }
 }
 
+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 cha
   // 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





More information about the llvm-commits mailing list