aboutsummaryrefslogtreecommitdiff
path: root/lib/Driver/Tools.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-09-10 01:21:05 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-09-10 01:21:05 +0000
commit88a3d6cf5ebab81614f89ba48a8d89023270637a (patch)
tree7e9ba4ee4d33a86d2fb32e1414762a461e44877e /lib/Driver/Tools.cpp
parent659862902cdf115c6ae2bd064e2bf9fea2525b7e (diff)
Factor out CheckPreprocessing options to share between Clang/CC1 tools.
Also, fix forwarding of -C/-CC to cc1. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81420 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Tools.cpp')
-rw-r--r--lib/Driver/Tools.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 9c7b3cd695..60fecc6a14 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -39,6 +39,15 @@ static const char *MakeFormattedString(const ArgList &Args,
return Args.MakeArgString(Str.str());
}
+/// CheckPreprocessingOptions - Perform some validation of preprocessing
+/// arguments that is shared with gcc.
+static void CheckPreprocessingOptions(const Driver &D, const ArgList &Args) {
+ if (Arg *A = Args.getLastArg(options::OPT_C, options::OPT_CC))
+ if (!Args.hasArg(options::OPT_E))
+ D.Diag(clang::diag::err_drv_argument_only_allowed_with)
+ << A->getAsString(Args) << "-E";
+}
+
void Clang::AddPreprocessingOptions(const Driver &D,
const ArgList &Args,
ArgStringList &CmdArgs,
@@ -46,13 +55,10 @@ void Clang::AddPreprocessingOptions(const Driver &D,
const InputInfoList &Inputs) const {
Arg *A;
- if ((A = Args.getLastArg(options::OPT_C)) ||
- (A = Args.getLastArg(options::OPT_CC))) {
- if (!Args.hasArg(options::OPT_E))
- D.Diag(clang::diag::err_drv_argument_only_allowed_with)
- << A->getAsString(Args) << "-E";
- A->render(Args, CmdArgs);
- }
+ CheckPreprocessingOptions(D, Args);
+
+ Args.AddLastArg(CmdArgs, options::OPT_C);
+ Args.AddLastArg(CmdArgs, options::OPT_CC);
// Handle dependency file generation.
if ((A = Args.getLastArg(options::OPT_M)) ||
@@ -1042,14 +1048,12 @@ void darwin::CC1::AddCPPUniqueOptionsArgs(const ArgList &Args,
const InputInfoList &Inputs) const {
const Driver &D = getToolChain().getHost().getDriver();
+ CheckPreprocessingOptions(D, Args);
+
// Derived from cpp_unique_options.
- Arg *A;
- if ((A = Args.getLastArg(options::OPT_C)) ||
- (A = Args.getLastArg(options::OPT_CC))) {
- if (!Args.hasArg(options::OPT_E))
- D.Diag(clang::diag::err_drv_argument_only_allowed_with)
- << A->getAsString(Args) << "-E";
- }
+ // -{C,CC} only with -E is checked in CheckPreprocessingOptions().
+ Args.AddLastArg(CmdArgs, options::OPT_C);
+ Args.AddLastArg(CmdArgs, options::OPT_CC);
if (!Args.hasArg(options::OPT_Q))
CmdArgs.push_back("-quiet");
Args.AddAllArgs(CmdArgs, options::OPT_nostdinc);