[cfe-commits] r81421 - /cfe/trunk/lib/Driver/Tools.cpp
Daniel Dunbar
daniel at zuster.org
Wed Sep 9 18:21:12 PDT 2009
Author: ddunbar
Date: Wed Sep 9 20:21:12 2009
New Revision: 81421
URL: http://llvm.org/viewvc/llvm-project?rev=81421&view=rev
Log:
Add a check that -static is not used with -dynamic or -mdynamic-no-pic.
Modified:
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=81421&r1=81420&r2=81421&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Sep 9 20:21:12 2009
@@ -48,6 +48,17 @@
<< A->getAsString(Args) << "-E";
}
+/// CheckCodeGenerationOptions - Perform some validation of code generation
+/// arguments that is shared with gcc.
+static void CheckCodeGenerationOptions(const Driver &D, const ArgList &Args) {
+ // In gcc, only ARM checks this, but it seems reasonable to check universally.
+ if (Args.hasArg(options::OPT_static))
+ if (const Arg *A = Args.getLastArg(options::OPT_dynamic,
+ options::OPT_mdynamic_no_pic))
+ D.Diag(clang::diag::err_drv_argument_not_allowed_with)
+ << A->getAsString(Args) << "-static";
+}
+
void Clang::AddPreprocessingOptions(const Driver &D,
const ArgList &Args,
ArgStringList &CmdArgs,
@@ -321,6 +332,8 @@
Args.AddAllArgValues(CmdArgs, options::OPT_Xanalyzer);
}
+ CheckCodeGenerationOptions(D, Args);
+
// Perform argument translation for LLVM backend. This
// takes some care in reconciling with llvm-gcc. The
// issue is that llvm-gcc translates these options based on
@@ -897,6 +910,10 @@
void darwin::CC1::AddCC1Args(const ArgList &Args,
ArgStringList &CmdArgs) const {
+ const Driver &D = getToolChain().getHost().getDriver();
+
+ CheckCodeGenerationOptions(D, Args);
+
// Derived from cc1 spec.
if (!Args.hasArg(options::OPT_mkernel) && !Args.hasArg(options::OPT_static) &&
!Args.hasArg(options::OPT_mdynamic_no_pic))
More information about the cfe-commits
mailing list