#include "clang/Basic/Diagnostic.h"
#include "clang/Driver/Phases.h"
+#include "clang/Driver/Types.h"
#include "clang/Driver/Util.h"
#include "llvm/ADT/StringRef.h"
/// The file to log CC_LOG_DIAGNOSTICS output to, if enabled.
const char *CCLogDiagnosticsFilename;
+ /// A list of inputs and their types for the given arguments.
+ typedef SmallVector<std::pair<types::ID, const Arg*>, 16> InputList;
+
/// Whether the driver should follow g++ like behavior.
unsigned CCCIsCXX : 1;
/// ArgList.
InputArgList *ParseArgStrings(ArrayRef<const char *> Args);
+ /// BuildInputs - Construct the list of inputs and their types from
+ /// the given arguments.
+ ///
+ /// \param TC - The default host tool chain.
+ /// \param Args - The input arguments.
+ /// \param Inputs - The list to store the resulting compilation
+ /// inputs onto.
+ void BuildInputs(const ToolChain &TC, const DerivedArgList &Args,
+ InputList &Inputs) const;
+
/// BuildActions - Construct the list of actions to perform for the
/// given arguments, which are only done for a single architecture.
///
/// \param Args - The input arguments.
/// \param Actions - The list to store the resulting actions onto.
void BuildActions(const ToolChain &TC, const DerivedArgList &Args,
- ActionList &Actions) const;
+ const InputList &Inputs, ActionList &Actions) const;
/// BuildUniversalActions - Construct the list of actions to perform
/// for the given arguments, which may require a universal build.
/// \param Args - The input arguments.
/// \param Actions - The list to store the resulting actions onto.
void BuildUniversalActions(const ToolChain &TC, const DerivedArgList &Args,
+ const InputList &BAInputs,
ActionList &Actions) const;
/// BuildJobs - Bind actions to concrete tools and translate
#include "clang/Driver/Options.h"
#include "clang/Driver/Tool.h"
#include "clang/Driver/ToolChain.h"
-#include "clang/Driver/Types.h"
#include "clang/Basic/Version.h"
if (!HandleImmediateArgs(*C))
return C;
+ // Construct the list of inputs.
+ InputList Inputs;
+ BuildInputs(C->getDefaultToolChain(), C->getArgs(), Inputs);
+
// Construct the list of abstract actions to perform for this compilation.
if (Host->useDriverDriver())
BuildUniversalActions(C->getDefaultToolChain(), C->getArgs(),
- C->getActions());
+ Inputs, C->getActions());
else
- BuildActions(C->getDefaultToolChain(), C->getArgs(), C->getActions());
+ BuildActions(C->getDefaultToolChain(), C->getArgs(), Inputs,
+ C->getActions());
if (CCCPrintActions) {
PrintActions(*C);
// Clear stale state and suppress tool output.
C.initCompilationForDiagnostics();
+ Diags.Reset();
+
+ // Construct the list of inputs.
+ InputList Inputs;
+ BuildInputs(C.getDefaultToolChain(), C.getArgs(), Inputs);
// Construct the list of abstract actions to perform for this compilation.
- Diags.Reset();
if (Host->useDriverDriver())
BuildUniversalActions(C.getDefaultToolChain(), C.getArgs(),
- C.getActions());
+ Inputs, C.getActions());
else
- BuildActions(C.getDefaultToolChain(), C.getArgs(), C.getActions());
+ BuildActions(C.getDefaultToolChain(), C.getArgs(), Inputs,
+ C.getActions());
BuildJobs(C);
void Driver::BuildUniversalActions(const ToolChain &TC,
const DerivedArgList &Args,
+ const InputList &BAInputs,
ActionList &Actions) const {
llvm::PrettyStackTraceString CrashInfo("Building universal build actions");
// Collect the list of architectures. Duplicates are allowed, but should only
}
ActionList SingleActions;
- BuildActions(TC, Args, SingleActions);
+ BuildActions(TC, Args, BAInputs, SingleActions);
// Add in arch bindings for every top level action, as well as lipo and
// dsymutil steps if needed.
}
}
-void Driver::BuildActions(const ToolChain &TC, const DerivedArgList &Args,
- ActionList &Actions) const {
- llvm::PrettyStackTraceString CrashInfo("Building compilation actions");
- // Start by constructing the list of inputs and their types.
-
+// Construct a the list of inputs and their types.
+void Driver::BuildInputs(const ToolChain &TC, const DerivedArgList &Args,
+ InputList &Inputs) const {
// Track the current user specified (-x) input. We also explicitly track the
// argument used to set the type; we only want to claim the type when we
// actually use it, so we warn about unused -x arguments.
types::ID InputType = types::TY_Nothing;
Arg *InputTypeArg = 0;
- SmallVector<std::pair<types::ID, const Arg*>, 16> Inputs;
for (ArgList::const_iterator it = Args.begin(), ie = Args.end();
it != ie; ++it) {
Arg *A = *it;
}
}
}
-
if (CCCIsCPP && Inputs.empty()) {
// If called as standalone preprocessor, stdin is processed
// if no other input is present.
A->claim();
Inputs.push_back(std::make_pair(types::TY_C, A));
}
+}
+
+void Driver::BuildActions(const ToolChain &TC, const DerivedArgList &Args,
+ const InputList &Inputs, ActionList &Actions) const {
+ llvm::PrettyStackTraceString CrashInfo("Building compilation actions");
if (!SuppressMissingInputWarning && Inputs.empty()) {
Diag(clang::diag::err_drv_no_input_files);