/// check for the presence of Arg instances for a particular Option
/// and to iterate over groups of arguments.
class ArgList {
+ private:
+ ArgList(const ArgList &); // DO NOT IMPLEMENT
+ void operator=(const ArgList &); // DO NOT IMPLEMENT
+
public:
typedef llvm::SmallVector<Arg*, 16> arglist_type;
typedef arglist_type::iterator iterator;
};
class InputArgList : public ArgList {
- InputArgList(const ArgList &); // DO NOT IMPLEMENT
- void operator=(const ArgList &); // DO NOT IMPLEMENT
-
private:
/// List of argument strings used by the contained Args.
///
/// DerivedArgList - An ordered collection of driver arguments,
/// whose storage may be in another argument list.
class DerivedArgList : public ArgList {
- InputArgList &BaseArgs;
+ const InputArgList &BaseArgs;
/// The list of arguments we synthesized.
mutable arglist_type SynthesizedArgs;
public:
/// Construct a new derived arg list from \arg BaseArgs.
- ///
- /// \param OnlyProxy - If true, this is only a proxy for the base
- /// list (to adapt the type), and it's Args list is unused.
- DerivedArgList(InputArgList &BaseArgs, bool OnlyProxy);
+ DerivedArgList(const InputArgList &BaseArgs);
~DerivedArgList();
virtual const char *getArgString(unsigned Index) const {
return BaseArgs.getNumInputArgStrings();
}
+ const InputArgList &getBaseArgs() const {
+ return BaseArgs;
+ }
+
/// @name Arg Synthesis
/// @{
/// The original (untranslated) input argument list.
InputArgList *Args;
+ /// The driver translated arguments. Note that toolchains may perform their
+ /// own argument translation.
+ DerivedArgList *TranslatedArgs;
+
/// The list of actions.
ActionList Actions;
public:
Compilation(const Driver &D, const ToolChain &DefaultToolChain,
- InputArgList *Args);
+ InputArgList *Args, DerivedArgList *TranslatedArgs);
~Compilation();
const Driver &getDriver() const { return TheDriver; }
const InputArgList &getArgs() const { return *Args; }
+ const DerivedArgList &getTranslatedArgs() const { return *TranslatedArgs; }
+
ActionList &getActions() { return Actions; }
const ActionList &getActions() const { return Actions; }
class Action;
class ArgList;
class Compilation;
+ class DerivedArgList;
class HostInfo;
class InputArgList;
class InputInfo;
std::list<std::string> TempFiles;
std::list<std::string> ResultFiles;
+private:
+ /// TranslateInputArgs - Create a new derived argument list from the input
+ /// arguments, after applying the standard argument translations.
+ DerivedArgList *TranslateInputArgs(const InputArgList &Args) const;
+
public:
Driver(llvm::StringRef _Name, llvm::StringRef _Dir,
llvm::StringRef _DefaultHostTriple,
// Tool access.
/// TranslateArgs - Create a new derived argument list for any argument
- /// translations this ToolChain may wish to perform.
+ /// translations this ToolChain may wish to perform, or 0 if no tool chain
+ /// specific translations are needed.
///
/// \param BoundArch - The bound architecture name, or 0.
- virtual DerivedArgList *TranslateArgs(InputArgList &Args,
- const char *BoundArch) const = 0;
+ virtual DerivedArgList *TranslateArgs(const DerivedArgList &Args,
+ const char *BoundArch) const {
+ return 0;
+ }
/// SelectTool - Choose a tool to use to handle the action \arg JA.
virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const = 0;
//
-DerivedArgList::DerivedArgList(InputArgList &_BaseArgs, bool OnlyProxy)
+DerivedArgList::DerivedArgList(const InputArgList &_BaseArgs)
: BaseArgs(_BaseArgs) {
- if (OnlyProxy)
- getArgs() = _BaseArgs.getArgs();
}
DerivedArgList::~DerivedArgList() {
#include <errno.h>
using namespace clang::driver;
-Compilation::Compilation(const Driver &D,
- const ToolChain &_DefaultToolChain,
- InputArgList *_Args)
- : TheDriver(D), DefaultToolChain(_DefaultToolChain), Args(_Args) {
+Compilation::Compilation(const Driver &D, const ToolChain &_DefaultToolChain,
+ InputArgList *_Args, DerivedArgList *_TranslatedArgs)
+ : TheDriver(D), DefaultToolChain(_DefaultToolChain), Args(_Args),
+ TranslatedArgs(_TranslatedArgs) {
}
Compilation::~Compilation() {
+ delete TranslatedArgs;
delete Args;
// Free any derived arg lists.
for (llvm::DenseMap<std::pair<const ToolChain*, const char*>,
DerivedArgList*>::iterator it = TCArgs.begin(),
ie = TCArgs.end(); it != ie; ++it)
- delete it->second;
+ if (it->second != TranslatedArgs)
+ delete it->second;
// Free the actions, if built.
for (ActionList::iterator it = Actions.begin(), ie = Actions.end();
TC = &DefaultToolChain;
DerivedArgList *&Entry = TCArgs[std::make_pair(TC, BoundArch)];
- if (!Entry)
- Entry = TC->TranslateArgs(*Args, BoundArch);
+ if (!Entry) {
+ Entry = TC->TranslateArgs(*TranslatedArgs, BoundArch);
+ if (!Entry)
+ Entry = TranslatedArgs;
+ }
return *Entry;
}
return Args;
}
+DerivedArgList *Driver::TranslateInputArgs(const InputArgList &Args) const {
+ DerivedArgList *DAL = new DerivedArgList(Args);
+
+ for (ArgList::const_iterator it = Args.begin(),
+ ie = Args.end(); it != ie; ++it)
+ DAL->append(*it);
+
+ return DAL;
+}
+
Compilation *Driver::BuildCompilation(int argc, const char **argv) {
llvm::PrettyStackTraceString CrashInfo("Compilation construction");
Host = GetHostInfo(HostTriple);
+ // Perform the default argument translations.
+ DerivedArgList *TranslatedArgs = TranslateInputArgs(*Args);
+
// The compilation takes ownership of Args.
- Compilation *C = new Compilation(*this, *Host->CreateToolChain(*Args), Args);
+ Compilation *C = new Compilation(*this, *Host->CreateToolChain(*Args), Args,
+ TranslatedArgs);
// FIXME: This behavior shouldn't be here.
if (CCCPrintOptions) {
}
}
-DerivedArgList *Darwin::TranslateArgs(InputArgList &Args,
+DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args,
const char *BoundArch) const {
- DerivedArgList *DAL = new DerivedArgList(Args, false);
+ DerivedArgList *DAL = new DerivedArgList(Args.getBaseArgs());
const OptTable &Opts = getDriver().getOpts();
// FIXME: We really want to get out of the tool chain level argument
}
setTarget(iPhoneVersion, Major, Minor, Micro);
- for (ArgList::iterator it = Args.begin(), ie = Args.end(); it != ie; ++it) {
+ for (ArgList::const_iterator it = Args.begin(),
+ ie = Args.end(); it != ie; ++it) {
Arg *A = *it;
if (A->getOption().matches(options::OPT_Xarch__)) {
return 0;
}
-DerivedArgList *Generic_GCC::TranslateArgs(InputArgList &Args,
- const char *BoundArch) const {
- return new DerivedArgList(Args, true);
-}
-
-
/// TCEToolChain - A tool chain using the llvm bitcode tools to perform
/// all subcommands. See http://tce.cs.tut.fi for our peculiar target.
/// Currently does not support anything else but compilation.
return *T;
}
-DerivedArgList *TCEToolChain::TranslateArgs(InputArgList &Args,
- const char *BoundArch) const {
- return new DerivedArgList(Args, true);
-}
-
/// OpenBSD - OpenBSD tool chain which can call as(1) and ld(1) directly.
OpenBSD::OpenBSD(const HostInfo &Host, const llvm::Triple& Triple)
Generic_GCC(const HostInfo &Host, const llvm::Triple& Triple);
~Generic_GCC();
- virtual DerivedArgList *TranslateArgs(InputArgList &Args,
- const char *BoundArch) const;
-
virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
virtual bool IsUnwindTablesDefault() const;
/// @name ToolChain Implementation
/// {
- virtual DerivedArgList *TranslateArgs(InputArgList &Args,
+ virtual DerivedArgList *TranslateArgs(const DerivedArgList &Args,
const char *BoundArch) const;
virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
TCEToolChain(const HostInfo &Host, const llvm::Triple& Triple);
~TCEToolChain();
- virtual DerivedArgList *TranslateArgs(InputArgList &Args,
- const char *BoundArch) const;
virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
bool IsMathErrnoDefault() const;
bool IsUnwindTablesDefault() const;