[lld] r191271 - [PECOFF] Use macro for the repeating pattern of the Driver code.
Rui Ueyama
ruiu at google.com
Mon Sep 23 20:37:56 PDT 2013
Author: ruiu
Date: Mon Sep 23 22:37:56 2013
New Revision: 191271
URL: http://llvm.org/viewvc/llvm-project?rev=191271&view=rev
Log:
[PECOFF] Use macro for the repeating pattern of the Driver code.
Modified:
lld/trunk/lib/Driver/WinLinkDriver.cpp
lld/trunk/lib/Driver/WinLinkOptions.td
Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=191271&r1=191270&r2=191271&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Mon Sep 23 22:37:56 2013
@@ -423,34 +423,6 @@ bool WinLinkDriver::parse(int argc, cons
ctx.setAllowRemainingUndefines(true);
break;
- case OPT_no_ref:
- ctx.setDeadStripping(false);
- break;
-
- case OPT_nxcompat_no:
- ctx.setNxCompat(false);
- break;
-
- case OPT_largeaddressaware:
- ctx.setLargeAddressAware(true);
- break;
-
- case OPT_allowbind:
- ctx.setAllowBind(true);
- break;
-
- case OPT_allowbind_no:
- ctx.setAllowBind(false);
- break;
-
- case OPT_allowisolation:
- ctx.setAllowIsolation(true);
- break;
-
- case OPT_allowisolation_no:
- ctx.setAllowIsolation(false);
- break;
-
case OPT_fixed:
// /fixed is not compatible with /dynamicbase. Check for it.
if (parsedArgs->getLastArg(OPT_dynamicbase)) {
@@ -461,18 +433,6 @@ bool WinLinkDriver::parse(int argc, cons
ctx.setDynamicBaseEnabled(false);
break;
- case OPT_dynamicbase_no:
- ctx.setDynamicBaseEnabled(false);
- break;
-
- case OPT_tsaware:
- ctx.setTerminalServerAware(true);
- break;
-
- case OPT_tsaware_no:
- ctx.setTerminalServerAware(false);
- break;
-
case OPT_incl:
ctx.addInitialUndefinedSymbol(ctx.allocateString(inputArg->getValue()));
break;
@@ -491,6 +451,24 @@ bool WinLinkDriver::parse(int argc, cons
new PECOFFFileNode(ctx, inputArg->getValue())));
break;
+#define DEFINE_BOOLEAN_FLAG(name, setter) \
+ case OPT_##name: \
+ ctx.setter(true); \
+ break; \
+ case OPT_##name##_no: \
+ ctx.setter(false); \
+ break
+
+ DEFINE_BOOLEAN_FLAG(ref, setDeadStripping);
+ DEFINE_BOOLEAN_FLAG(nxcompat, setNxCompat);
+ DEFINE_BOOLEAN_FLAG(largeaddressaware, setLargeAddressAware);
+ DEFINE_BOOLEAN_FLAG(allowbind, setAllowBind);
+ DEFINE_BOOLEAN_FLAG(allowisolation, setAllowIsolation);
+ DEFINE_BOOLEAN_FLAG(dynamicbase, setDynamicBaseEnabled);
+ DEFINE_BOOLEAN_FLAG(tsaware, setTerminalServerAware);
+
+#undef DEFINE_BOOLEAN_FLAG
+
default:
break;
}
@@ -501,7 +479,7 @@ bool WinLinkDriver::parse(int argc, cons
ctx.setEntrySymbolName(getDefaultEntrySymbolName(ctx));
// Specifying both /opt:ref and /opt:noref is an error.
- if (parsedArgs->getLastArg(OPT_ref) && parsedArgs->getLastArg(OPT_no_ref)) {
+ if (parsedArgs->getLastArg(OPT_ref) && parsedArgs->getLastArg(OPT_ref_no)) {
diagnostics << "/opt:ref must not be specified with /opt:noref\n";
return true;
}
Modified: lld/trunk/lib/Driver/WinLinkOptions.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkOptions.td?rev=191271&r1=191270&r2=191271&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkOptions.td (original)
+++ lld/trunk/lib/Driver/WinLinkOptions.td Mon Sep 23 22:37:56 2013
@@ -47,7 +47,7 @@ def force : F<"force">,
def force_unresolved : F<"force:unresolved">;
def ref : F<"opt:ref">;
-def no_ref : F<"opt:noref">,
+def ref_no : F<"opt:noref">,
HelpText<"Keep unreferenced symbols to be included to the output">;
defm nxcompat : B<"nxcompat", "Disable data execution provention">;
More information about the llvm-commits
mailing list