[lld] r190117 - Return early to simplify.

Rui Ueyama ruiu at google.com
Thu Sep 5 18:48:19 PDT 2013


Author: ruiu
Date: Thu Sep  5 20:48:19 2013
New Revision: 190117

URL: http://llvm.org/viewvc/llvm-project?rev=190117&view=rev
Log:
Return early to simplify.

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=190117&r1=190116&r2=190117&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Thu Sep  5 20:48:19 2013
@@ -165,19 +165,17 @@ void processLibEnv(PECOFFLinkingContext
       context.appendInputSearchPath(context.allocateString(path));
 }
 
-// Sets a default entry point symbol name depending on context image type and
+// Returns a default entry point symbol name depending on context image type and
 // subsystem. These default names are MS CRT compliant.
-void setDefaultEntrySymbolName(PECOFFLinkingContext &context) {
-  if (context.getImageType() == PECOFFLinkingContext::ImageType::IMAGE_DLL) {
-    context.setEntrySymbolName("__DllMainCRTStartup");
-  } else {
-    llvm::COFF::WindowsSubsystem subsystem = context.getSubsystem();
-    if (subsystem == llvm::COFF::WindowsSubsystem::IMAGE_SUBSYSTEM_WINDOWS_GUI)
-      context.setEntrySymbolName("_WinMainCRTStartup");
-    else if (subsystem ==
-      llvm::COFF::WindowsSubsystem::IMAGE_SUBSYSTEM_WINDOWS_CUI)
-      context.setEntrySymbolName("_mainCRTStartup");
-  }
+StringRef getDefaultEntrySymbolName(PECOFFLinkingContext &context) {
+  if (context.getImageType() == PECOFFLinkingContext::ImageType::IMAGE_DLL)
+    return "__DllMainCRTStartup";
+  llvm::COFF::WindowsSubsystem subsystem = context.getSubsystem();
+  if (subsystem == llvm::COFF::WindowsSubsystem::IMAGE_SUBSYSTEM_WINDOWS_GUI)
+    return "_WinMainCRTStartup";
+  if (subsystem == llvm::COFF::WindowsSubsystem::IMAGE_SUBSYSTEM_WINDOWS_CUI)
+    return "_mainCRTStartup";
+  return "";
 }
 
 // Parses the given command line options and returns the result. Returns NULL if
@@ -434,7 +432,7 @@ bool WinLinkDriver::parse(int argc, cons
 
   // Use the default entry name if /entry option is not given.
   if (ctx.entrySymbolName().empty())
-    setDefaultEntrySymbolName(ctx);
+    ctx.setEntrySymbolName(getDefaultEntrySymbolName(ctx));
 
   // Specifying both /opt:ref and /opt:noref is an error.
   if (parsedArgs->getLastArg(OPT_ref) && parsedArgs->getLastArg(OPT_no_ref)) {





More information about the llvm-commits mailing list