diff options
Diffstat (limited to 'lib/Driver')
-rw-r--r-- | lib/Driver/Action.cpp | 12 | ||||
-rw-r--r-- | lib/Driver/Arg.cpp | 23 | ||||
-rw-r--r-- | lib/Driver/ArgList.cpp | 30 | ||||
-rw-r--r-- | lib/Driver/Compilation.cpp | 36 | ||||
-rw-r--r-- | lib/Driver/Driver.cpp | 3 | ||||
-rw-r--r-- | lib/Driver/HostInfo.cpp | 4 | ||||
-rw-r--r-- | lib/Driver/Job.cpp | 6 | ||||
-rw-r--r-- | lib/Driver/OptTable.cpp | 12 | ||||
-rw-r--r-- | lib/Driver/Option.cpp | 57 | ||||
-rw-r--r-- | lib/Driver/Tool.cpp | 2 | ||||
-rw-r--r-- | lib/Driver/ToolChain.cpp | 6 | ||||
-rw-r--r-- | lib/Driver/ToolChains.cpp | 39 | ||||
-rw-r--r-- | lib/Driver/ToolChains.h | 6 | ||||
-rw-r--r-- | lib/Driver/Tools.cpp | 50 | ||||
-rw-r--r-- | lib/Driver/Tools.h | 100 | ||||
-rw-r--r-- | lib/Driver/Types.cpp | 46 |
16 files changed, 210 insertions, 222 deletions
diff --git a/lib/Driver/Action.cpp b/lib/Driver/Action.cpp index cabc33eaec..62434893f9 100644 --- a/lib/Driver/Action.cpp +++ b/lib/Driver/Action.cpp @@ -29,16 +29,16 @@ const char *Action::getClassName(ActionClass AC) { case LinkJobClass: return "linker"; case LipoJobClass: return "lipo"; } - + assert(0 && "invalid class"); return 0; } -InputAction::InputAction(const Arg &_Input, types::ID _Type) +InputAction::InputAction(const Arg &_Input, types::ID _Type) : Action(InputClass, _Type), Input(_Input) { } -BindArchAction::BindArchAction(Action *Input, const char *_ArchName) +BindArchAction::BindArchAction(Action *Input, const char *_ArchName) : Action(BindArchClass, Input, Input->getType()), ArchName(_ArchName) { } @@ -46,7 +46,7 @@ JobAction::JobAction(ActionClass Kind, Action *Input, types::ID Type) : Action(Kind, Input, Type) { } -JobAction::JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type) +JobAction::JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type) : Action(Kind, Inputs, Type) { } @@ -70,10 +70,10 @@ AssembleJobAction::AssembleJobAction(Action *Input, types::ID OutputType) : JobAction(AssembleJobClass, Input, OutputType) { } -LinkJobAction::LinkJobAction(ActionList &Inputs, types::ID Type) +LinkJobAction::LinkJobAction(ActionList &Inputs, types::ID Type) : JobAction(LinkJobClass, Inputs, Type) { } -LipoJobAction::LipoJobAction(ActionList &Inputs, types::ID Type) +LipoJobAction::LipoJobAction(ActionList &Inputs, types::ID Type) : JobAction(LipoJobClass, Inputs, Type) { } diff --git a/lib/Driver/Arg.cpp b/lib/Driver/Arg.cpp index e227d7e2ea..a09ba095f1 100644 --- a/lib/Driver/Arg.cpp +++ b/lib/Driver/Arg.cpp @@ -14,10 +14,9 @@ using namespace clang::driver; -Arg::Arg(ArgClass _Kind, const Option *_Opt, unsigned _Index, - const Arg *_BaseArg) - : Kind(_Kind), Opt(_Opt), BaseArg(_BaseArg), Index(_Index), Claimed(false) -{ +Arg::Arg(ArgClass _Kind, const Option *_Opt, unsigned _Index, + const Arg *_BaseArg) + : Kind(_Kind), Opt(_Opt), BaseArg(_BaseArg), Index(_Index), Claimed(false) { } Arg::~Arg() { } @@ -54,7 +53,7 @@ std::string Arg::getAsString(const ArgList &Args) const { ArgStringList ASL; render(Args, ASL); - for (ArgStringList::iterator + for (ArgStringList::iterator it = ASL.begin(), ie = ASL.end(); it != ie; ++it) { if (it != ASL.begin()) OS << ' '; @@ -87,7 +86,7 @@ const char *FlagArg::getValue(const ArgList &Args, unsigned N) const { return 0; } -PositionalArg::PositionalArg(const Option *Opt, unsigned Index, +PositionalArg::PositionalArg(const Option *Opt, unsigned Index, const Arg *BaseArg) : Arg(PositionalClass, Opt, Index, BaseArg) { } @@ -120,10 +119,10 @@ const char *JoinedArg::getValue(const ArgList &Args, unsigned N) const { return Args.getArgString(getIndex()) + strlen(getOption().getName()); } -CommaJoinedArg::CommaJoinedArg(const Option *Opt, unsigned Index, +CommaJoinedArg::CommaJoinedArg(const Option *Opt, unsigned Index, const char *Str, const Arg *BaseArg) : Arg(CommaJoinedClass, Opt, Index, BaseArg) { - const char *Prev = Str; + const char *Prev = Str; for (;; ++Str) { char c = *Str; @@ -167,23 +166,23 @@ void SeparateArg::render(const ArgList &Args, ArgStringList &Output) const { } } -const char *SeparateArg::getValue(const ArgList &Args, unsigned N) const { +const char *SeparateArg::getValue(const ArgList &Args, unsigned N) const { assert(N < getNumValues() && "Invalid index."); return Args.getArgString(getIndex() + 1 + N); } -JoinedAndSeparateArg::JoinedAndSeparateArg(const Option *Opt, unsigned Index, +JoinedAndSeparateArg::JoinedAndSeparateArg(const Option *Opt, unsigned Index, const Arg *BaseArg) : Arg(JoinedAndSeparateClass, Opt, Index, BaseArg) { } -void JoinedAndSeparateArg::render(const ArgList &Args, +void JoinedAndSeparateArg::render(const ArgList &Args, ArgStringList &Output) const { Output.push_back(Args.getArgString(getIndex())); Output.push_back(Args.getArgString(getIndex() + 1)); } -const char *JoinedAndSeparateArg::getValue(const ArgList &Args, +const char *JoinedAndSeparateArg::getValue(const ArgList &Args, unsigned N) const { assert(N < getNumValues() && "Invalid index."); if (N == 0) diff --git a/lib/Driver/ArgList.cpp b/lib/Driver/ArgList.cpp index 54dd4bb775..be7109f3f6 100644 --- a/lib/Driver/ArgList.cpp +++ b/lib/Driver/ArgList.cpp @@ -31,13 +31,13 @@ Arg *ArgList::getLastArg(options::ID Id, bool Claim) const { return *it; } } - + return 0; } Arg *ArgList::getLastArg(options::ID Id0, options::ID Id1, bool Claim) const { Arg *Res, *A0 = getLastArg(Id0, false), *A1 = getLastArg(Id1, false); - + if (A0 && A1) Res = A0->getIndex() > A1->getIndex() ? A0 : A1; else @@ -102,7 +102,7 @@ void ArgList::AddAllArgs(ArgStringList &Output, options::ID Id0) const { } } -void ArgList::AddAllArgs(ArgStringList &Output, options::ID Id0, +void ArgList::AddAllArgs(ArgStringList &Output, options::ID Id0, options::ID Id1) const { // FIXME: Make fast. for (const_iterator it = begin(), ie = end(); it != ie; ++it) { @@ -114,7 +114,7 @@ void ArgList::AddAllArgs(ArgStringList &Output, options::ID Id0, } } -void ArgList::AddAllArgs(ArgStringList &Output, options::ID Id0, +void ArgList::AddAllArgs(ArgStringList &Output, options::ID Id0, options::ID Id1, options::ID Id2) const { // FIXME: Make fast. for (const_iterator it = begin(), ie = end(); it != ie; ++it) { @@ -139,7 +139,7 @@ void ArgList::AddAllArgValues(ArgStringList &Output, options::ID Id0) const { } } -void ArgList::AddAllArgValues(ArgStringList &Output, options::ID Id0, +void ArgList::AddAllArgValues(ArgStringList &Output, options::ID Id0, options::ID Id1) const { // FIXME: Make fast. for (const_iterator it = begin(), ie = end(); it != ie; ++it) { @@ -184,9 +184,8 @@ void ArgList::ClaimAllArgs(options::ID Id0) const { // -InputArgList::InputArgList(const char **ArgBegin, const char **ArgEnd) - : ArgList(ActualArgs), NumInputArgStrings(ArgEnd - ArgBegin) -{ +InputArgList::InputArgList(const char **ArgBegin, const char **ArgEnd) + : ArgList(ActualArgs), NumInputArgStrings(ArgEnd - ArgBegin) { ArgStrings.append(ArgBegin, ArgEnd); } @@ -206,7 +205,7 @@ unsigned InputArgList::MakeIndex(const char *String0) const { return Index; } -unsigned InputArgList::MakeIndex(const char *String0, +unsigned InputArgList::MakeIndex(const char *String0, const char *String1) const { unsigned Index0 = MakeIndex(String0); unsigned Index1 = MakeIndex(String1); @@ -223,13 +222,12 @@ const char *InputArgList::MakeArgString(const char *Str) const { DerivedArgList::DerivedArgList(InputArgList &_BaseArgs, bool _OnlyProxy) : ArgList(_OnlyProxy ? _BaseArgs.getArgs() : ActualArgs), - BaseArgs(_BaseArgs), OnlyProxy(_OnlyProxy) -{ + BaseArgs(_BaseArgs), OnlyProxy(_OnlyProxy) { } DerivedArgList::~DerivedArgList() { // We only own the arguments we explicitly synthesized. - for (iterator it = SynthesizedArgs.begin(), ie = SynthesizedArgs.end(); + for (iterator it = SynthesizedArgs.begin(), ie = SynthesizedArgs.end(); it != ie; ++it) delete *it; } @@ -242,18 +240,18 @@ Arg *DerivedArgList::MakeFlagArg(const Arg *BaseArg, const Option *Opt) const { return new FlagArg(Opt, BaseArgs.MakeIndex(Opt->getName()), BaseArg); } -Arg *DerivedArgList::MakePositionalArg(const Arg *BaseArg, const Option *Opt, +Arg *DerivedArgList::MakePositionalArg(const Arg *BaseArg, const Option *Opt, const char *Value) const { return new PositionalArg(Opt, BaseArgs.MakeIndex(Value), BaseArg); } -Arg *DerivedArgList::MakeSeparateArg(const Arg *BaseArg, const Option *Opt, +Arg *DerivedArgList::MakeSeparateArg(const Arg *BaseArg, const Option *Opt, const char *Value) const { - return new SeparateArg(Opt, BaseArgs.MakeIndex(Opt->getName(), Value), 1, + return new SeparateArg(Opt, BaseArgs.MakeIndex(Opt->getName(), Value), 1, BaseArg); } -Arg *DerivedArgList::MakeJoinedArg(const Arg *BaseArg, const Option *Opt, +Arg *DerivedArgList::MakeJoinedArg(const Arg *BaseArg, const Option *Opt, const char *Value) const { std::string Joined(Opt->getName()); Joined += Value; diff --git a/lib/Driver/Compilation.cpp b/lib/Driver/Compilation.cpp index 7e29b67769..ad3cb8dbe1 100644 --- a/lib/Driver/Compilation.cpp +++ b/lib/Driver/Compilation.cpp @@ -23,20 +23,20 @@ using namespace clang::driver; Compilation::Compilation(const Driver &D, const ToolChain &_DefaultToolChain, - InputArgList *_Args) + InputArgList *_Args) : TheDriver(D), DefaultToolChain(_DefaultToolChain), Args(_Args) { } -Compilation::~Compilation() { +Compilation::~Compilation() { delete Args; - + // Free any derived arg lists. - for (llvm::DenseMap<const ToolChain*, DerivedArgList*>::iterator + for (llvm::DenseMap<const ToolChain*, DerivedArgList*>::iterator it = TCArgs.begin(), ie = TCArgs.end(); it != ie; ++it) delete it->second; // Free the actions, if built. - for (ActionList::iterator it = Actions.begin(), ie = Actions.end(); + for (ActionList::iterator it = Actions.begin(), ie = Actions.end(); it != ie; ++it) delete *it; } @@ -52,7 +52,7 @@ const DerivedArgList &Compilation::getArgsForToolChain(const ToolChain *TC) { return *Entry; } -void Compilation::PrintJob(llvm::raw_ostream &OS, const Job &J, +void Compilation::PrintJob(llvm::raw_ostream &OS, const Job &J, const char *Terminator, bool Quote) const { if (const Command *C = dyn_cast<Command>(&J)) { OS << " \"" << C->getExecutable() << '"'; @@ -65,22 +65,22 @@ void Compilation::PrintJob(llvm::raw_ostream &OS, const Job &J, } OS << Terminator; } else if (const PipedJob *PJ = dyn_cast<PipedJob>(&J)) { - for (PipedJob::const_iterator + for (PipedJob::const_iterator it = PJ->begin(), ie = PJ->end(); it != ie; ++it) PrintJob(OS, **it, (it + 1 != PJ->end()) ? " |\n" : "\n", Quote); } else { const JobList *Jobs = cast<JobList>(&J); - for (JobList::const_iterator + for (JobList::const_iterator it = Jobs->begin(), ie = Jobs->end(); it != ie; ++it) PrintJob(OS, **it, Terminator, Quote); } } -bool Compilation::CleanupFileList(const ArgStringList &Files, +bool Compilation::CleanupFileList(const ArgStringList &Files, bool IssueErrors) const { bool Success = true; - for (ArgStringList::const_iterator + for (ArgStringList::const_iterator it = Files.begin(), ie = Files.end(); it != ie; ++it) { llvm::sys::Path P(*it); std::string Error; @@ -92,7 +92,7 @@ bool Compilation::CleanupFileList(const ArgStringList &Files, // FIXME: Grumble, P.exists() is broken. PR3837. struct stat buf; - if (::stat(P.c_str(), &buf) == 0 + if (::stat(P.c_str(), &buf) == 0 || errno != ENOENT) { if (IssueErrors) getDriver().Diag(clang::diag::err_drv_unable_to_remove_file) @@ -112,12 +112,12 @@ int Compilation::ExecuteCommand(const Command &C, Argv[0] = C.getExecutable(); std::copy(C.getArguments().begin(), C.getArguments().end(), Argv+1); Argv[C.getArguments().size() + 1] = 0; - + if (getDriver().CCCEcho || getArgs().hasArg(options::OPT_v)) PrintJob(llvm::errs(), C, "\n", false); - + std::string Error; - int Res = + int Res = llvm::sys::Program::ExecuteAndWait(Prog, Argv, /*env*/0, /*redirects*/0, /*secondsToWait*/0, /*memoryLimit*/0, @@ -126,7 +126,7 @@ int Compilation::ExecuteCommand(const Command &C, assert(Res && "Error string set with 0 result code!"); getDriver().Diag(clang::diag::err_drv_command_failure) << Error; } - + if (Res) FailingCommand = &C; @@ -134,7 +134,7 @@ int Compilation::ExecuteCommand(const Command &C, return Res; } -int Compilation::ExecuteJob(const Job &J, +int Compilation::ExecuteJob(const Job &J, const Command *&FailingCommand) const { if (const Command *C = dyn_cast<Command>(&J)) { return ExecuteCommand(*C, FailingCommand); @@ -142,13 +142,13 @@ int Compilation::ExecuteJob(const Job &J, // Piped commands with a single job are easy. if (PJ->size() == 1) return ExecuteCommand(**PJ->begin(), FailingCommand); - + FailingCommand = *PJ->begin(); getDriver().Diag(clang::diag::err_drv_unsupported_opt) << "-pipe"; return 1; } else { const JobList *Jobs = cast<JobList>(&J); - for (JobList::const_iterator + for (JobList::const_iterator it = Jobs->begin(), ie = Jobs->end(); it != ie; ++it) if (int Res = ExecuteJob(**it, FailingCommand)) return Res; diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 59099a33e6..24f462f18f 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -56,8 +56,7 @@ Driver::Driver(const char *_Name, const char *_Dir, CCCUseClangCXX(true), #endif CCCUseClangCPP(true), CCCUsePCH(true), - SuppressMissingInputWarning(false) -{ + SuppressMissingInputWarning(false) { #ifdef USE_PRODUCTION_CLANG // In a "production" build, only use clang on architectures we expect to work. CCCClangArchs.insert(llvm::Triple::x86); diff --git a/lib/Driver/HostInfo.cpp b/lib/Driver/HostInfo.cpp index ceb4ed1023..e950b4a08e 100644 --- a/lib/Driver/HostInfo.cpp +++ b/lib/Driver/HostInfo.cpp @@ -26,9 +26,7 @@ using namespace clang::driver; HostInfo::HostInfo(const Driver &D, const llvm::Triple &_Triple) - : TheDriver(D), Triple(_Triple) -{ - + : TheDriver(D), Triple(_Triple) { } HostInfo::~HostInfo() { diff --git a/lib/Driver/Job.cpp b/lib/Driver/Job.cpp index 1b0ea18453..280e7c4a5a 100644 --- a/lib/Driver/Job.cpp +++ b/lib/Driver/Job.cpp @@ -14,9 +14,9 @@ using namespace clang::driver; Job::~Job() {} -Command::Command(const Action &_Source, const char *_Executable, +Command::Command(const Action &_Source, const char *_Executable, const ArgStringList &_Arguments) - : Job(CommandClass), Source(_Source), Executable(_Executable), + : Job(CommandClass), Source(_Source), Executable(_Executable), Arguments(_Arguments) { } @@ -30,4 +30,4 @@ void Job::addCommand(Command *C) { else cast<JobList>(this)->addJob(C); } - + diff --git a/lib/Driver/OptTable.cpp b/lib/Driver/OptTable.cpp index 8c88575764..affd1c5aa9 100644 --- a/lib/Driver/OptTable.cpp +++ b/lib/Driver/OptTable.cpp @@ -77,7 +77,7 @@ static Info OptionInfos[] = { { "<input>", "d", 0, 0, Option::InputClass, OPT_INVALID, OPT_INVALID, 0 }, // The UnknownOption info { "<unknown>", "", 0, 0, Option::UnknownClass, OPT_INVALID, OPT_INVALID, 0 }, - + #define OPTION(NAME, ID, KIND, GROUP, ALIAS, FLAGS, PARAM, \ HELPTEXT, METAVAR) \ { NAME, FLAGS, HELPTEXT, METAVAR, \ @@ -124,10 +124,10 @@ OptTable::OptTable() : Options(new Option*[numOptions]) { assert(0 && "Options are not in order!"); } } -#endif +#endif } -OptTable::~OptTable() { +OptTable::~OptTable() { for (unsigned i = 0; i < numOptions; ++i) delete Options[i]; delete[] Options; @@ -168,7 +168,7 @@ const Option *OptTable::getOption(options::ID id) const { Option *OptTable::constructOption(options::ID id) const { Info &info = getInfo(id); - const OptionGroup *Group = + const OptionGroup *Group = cast_or_null<OptionGroup>(getOption((options::ID) info.GroupID)); const Option *Alias = getOption((options::ID) info.AliasID); @@ -199,10 +199,10 @@ Option *OptTable::constructOption(options::ID id) const { for (const char *s = info.Flags; *s; ++s) { switch (*s) { default: assert(0 && "Invalid option flag."); - case 'J': + case 'J': assert(info.Kind == Option::SeparateClass && "Invalid option."); Opt->setForceJoinedRender(true); break; - case 'S': + case 'S': assert(info.Kind == Option::JoinedClass && "Invalid option."); Opt->setForceSeparateRender(true); break; case 'd': Opt->setDriverOption(true); break; diff --git a/lib/Driver/Option.cpp b/lib/Driver/Option.cpp index cad2bbf2b7..c2ace05aa4 100644 --- a/lib/Driver/Option.cpp +++ b/lib/Driver/Option.cpp @@ -17,18 +17,17 @@ using namespace clang::driver; Option::Option(OptionClass _Kind, options::ID _ID, const char *_Name, - const OptionGroup *_Group, const Option *_Alias) + const OptionGroup *_Group, const Option *_Alias) : Kind(_Kind), ID(_ID), Name(_Name), Group(_Group), Alias(_Alias), Unsupported(false), LinkerInput(false), NoOptAsInput(false), ForceSeparateRender(false), ForceJoinedRender(false), - DriverOption(false), NoArgumentUnused(false) -{ + DriverOption(false), NoArgumentUnused(false) { // Multi-level aliases are not supported, and alias options cannot // have groups. This just simplifies option tracking, it is not an // inherent limitation. assert((!Alias || (!Alias->Alias && !Group)) && - "Multi-level aliases and aliases with groups are unsupported."); + "Multi-level aliases and aliases with groups are unsupported."); } Option::~Option() { @@ -59,12 +58,12 @@ void Option::dump() const { llvm::errs() << " Group:"; Group->dump(); } - + if (Alias) { llvm::errs() << " Alias:"; Alias->dump(); } - + if (const MultiArgOption *MOA = dyn_cast<MultiArgOption>(this)) llvm::errs() << " NumArgs:" << MOA->getNumArgs(); @@ -77,10 +76,10 @@ bool Option::matches(const Option *Opt) const { return matches(Opt->getAlias()); if (Alias) return Alias->matches(Opt); - + if (this == Opt) return true; - + if (Group) return Group->matches(Opt); return false; @@ -93,16 +92,16 @@ bool Option::matches(options::ID Id) const { // the option table). if (Alias) return Alias->matches(Id); - + if (ID == Id) return true; - + if (Group) return Group->matches(Id); return false; } -OptionGroup::OptionGroup(options::ID ID, const char *Name, +OptionGroup::OptionGroup(options::ID ID, const char *Name, const OptionGroup *Group) : Option(Option::GroupClass, ID, Name, Group, 0) { } @@ -130,13 +129,13 @@ Arg *UnknownOption::accept(const InputArgList &Args, unsigned &Index) const { return 0; } -FlagOption::FlagOption(options::ID ID, const char *Name, +FlagOption::FlagOption(options::ID ID, const char *Name, const OptionGroup *Group, const Option *Alias) : Option(Option::FlagClass, ID, Name, Group, Alias) { } Arg *FlagOption::accept(const InputArgList &Args, unsigned &Index) const { - // Matches iff this is an exact match. + // Matches iff this is an exact match. // FIXME: Avoid strlen. if (strlen(getName()) != strlen(Args.getArgString(Index))) return 0; @@ -144,7 +143,7 @@ Arg *FlagOption::accept(const InputArgList &Args, unsigned &Index) const { return new FlagArg(this, Index++); } -JoinedOption::JoinedOption(options::ID ID, const char *Name, +JoinedOption::JoinedOption(options::ID ID, const char *Name, const OptionGroup *Group, const Option *Alias) : Option(Option::JoinedClass, ID, Name, Group, Alias) { } @@ -154,30 +153,30 @@ Arg *JoinedOption::accept(const InputArgList &Args, unsigned &Index) const { return new JoinedArg(this, Index++); } -CommaJoinedOption::CommaJoinedOption(options::ID ID, const char *Name, - const OptionGroup *Group, +CommaJoinedOption::CommaJoinedOption(options::ID ID, const char *Name, + const OptionGroup *Group, const Option *Alias) : Option(Option::CommaJoinedClass, ID, Name, Group, Alias) { } -Arg *CommaJoinedOption::accept(const InputArgList &Args, +Arg *CommaJoinedOption::accept(const InputArgList &Args, unsigned &Index) const { // Always matches. We count the commas now so we can answer // getNumValues easily. - + // Get the suffix string. // FIXME: Avoid strlen, and move to helper method? const char *Suffix = Args.getArgString(Index) + strlen(getName()); return new CommaJoinedArg(this, Index++, Suffix); } -SeparateOption::SeparateOption(options::ID ID, const char *Name, +SeparateOption::SeparateOption(options::ID ID, const char *Name, const OptionGroup *Group, const Option *Alias) : Option(Option::SeparateClass, ID, Name, Group, Alias) { } Arg *SeparateOption::accept(const InputArgList &Args, unsigned &Index) const { - // Matches iff this is an exact match. + // Matches iff this is an exact match. // FIXME: Avoid strlen. if (strlen(getName()) != strlen(Args.getArgString(Index))) return 0; @@ -189,15 +188,15 @@ Arg *SeparateOption::accept(const InputArgList &Args, unsigned &Index) const { return new SeparateArg(this, Index - 2, 1); } -MultiArgOption::MultiArgOption(options::ID ID, const char *Name, - const OptionGroup *Group, const Option *Alias, +MultiArgOption::MultiArgOption(options::ID ID, const char *Name, + const OptionGroup *Group, const Option *Alias, unsigned _NumArgs) : Option(Option::MultiArgClass, ID, Name, Group, Alias), NumArgs(_NumArgs) { assert(NumArgs > 1 && "Invalid MultiArgOption!"); } Arg *MultiArgOption::accept(const InputArgList &Args, unsigned &Index) const { - // Matches iff this is an exact match. + // Matches iff this is an exact match. // FIXME: Avoid strlen. if (strlen(getName()) != strlen(Args.getArgString(Index))) return 0; @@ -210,12 +209,12 @@ Arg *MultiArgOption::accept(const InputArgList &Args, unsigned &Index) const { } JoinedOrSeparateOption::JoinedOrSeparateOption(options::ID ID, const char *Name, - const OptionGroup *Group, + const OptionGroup *Group, const Option *Alias) : Option(Option::JoinedOrSeparateClass, ID, Name, Group, Alias) { } -Arg *JoinedOrSeparateOption::accept(const InputArgList &Args, +Arg *JoinedOrSeparateOption::accept(const InputArgList &Args, unsigned &Index) const { // If this is not an exact match, it is a joined arg. // FIXME: Avoid strlen. @@ -227,17 +226,17 @@ Arg *JoinedOrSeparateOption::accept(const InputArgList &Args, if (Index > Args.getNumInputArgStrings()) return 0; - return new SeparateArg(this, Index - 2, 1); + return new SeparateArg(this, Index - 2, 1); } JoinedAndSeparateOption::JoinedAndSeparateOption(options::ID ID, - const char *Name, - const OptionGroup *Group, + const char *Name, + const OptionGroup *Group, const Option *Alias) : Option(Option::JoinedAndSeparateClass, ID, Name, Group, Alias) { } -Arg *JoinedAndSeparateOption::accept(const InputArgList &Args, +Arg *JoinedAndSeparateOption::accept(const InputArgList &Args, unsigned &Index) const { // Always matches. diff --git a/lib/Driver/Tool.cpp b/lib/Driver/Tool.cpp index 6f6589ab13..781e0a7020 100644 --- a/lib/Driver/Tool.cpp +++ b/lib/Driver/Tool.cpp @@ -11,7 +11,7 @@ using namespace clang::driver; -Tool::Tool(const char *_Name, const ToolChain &TC) : Name(_Name), +Tool::Tool(const char *_Name, const ToolChain &TC) : Name(_Name), TheToolChain(TC) { } diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp index 20ed31bd6e..46b460381f 100644 --- a/lib/Driver/ToolChain.cpp +++ b/lib/Driver/ToolChain.cpp @@ -22,13 +22,13 @@ ToolChain::ToolChain(const HostInfo &_Host, const llvm::Triple &_Triple) ToolChain::~ToolChain() { } -llvm::sys::Path ToolChain::GetFilePath(const Compilation &C, +llvm::sys::Path ToolChain::GetFilePath(const Compilation &C, const char *Name) const { return Host.getDriver().GetFilePath(Name, *this); - + } -llvm::sys::Path ToolChain::GetProgramPath(const Compilation &C, +llvm::sys::Path ToolChain::GetProgramPath(const Compilation &C, const char *Name, bool WantFile) const { return Host.getDriver().GetProgramPath(Name, *this, WantFile); diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 6512203d09..fb6217d3ed 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -68,7 +68,7 @@ Darwin::Darwin(const HostInfo &Host, const llvm::Triple& Triple, Path += "/x86_64"; getFilePaths().push_back(Path); } - + Path = getHost().getDriver().Dir; Path += "/../lib/gcc/"; Path += getToolChainDir(); @@ -142,16 +142,16 @@ DerivedArgList *Darwin::TranslateArgs(InputArgList &Args) const { // more opaque. For now, we follow gcc closely solely for the // purpose of easily achieving feature parity & testability. Once we // have something that works, we should reevaluate each translation - // and try to push it down into tool specific logic. + // and try to push it down into tool specific logic. - Arg *OSXVersion = + Arg *OSXVersion = Args.getLastArg(options::OPT_mmacosx_version_min_EQ, false); Arg *iPhoneVersion = - Args.getLastArg(options::OPT_miphoneos_version_min_EQ, false); + Args.getLastArg(options::OPT_miphoneos_version_min_EQ, false); if (OSXVersion && iPhoneVersion) { getHost().getDriver().Diag(clang::diag::err_drv_argument_not_allowed_with) << OSXVersion->getAsString(Args) - << iPhoneVersion->getAsString(Args); + << iPhoneVersion->getAsString(Args); } else if (!OSXVersion && !iPhoneVersion) { // Chose the default version based on the arch. // @@ -171,7 +171,7 @@ DerivedArgList *Darwin::TranslateArgs(InputArgList &Args) const { DAL->append(DAL->MakeJoinedArg(0, O, Version)); } } - + for (ArgList::iterator it = Args.begin(), ie = Args.end(); it != ie; ++it) { Arg *A = *it; @@ -184,7 +184,7 @@ DerivedArgList *Darwin::TranslateArgs(InputArgList &Args) const { // interface for this. unsigned Prev, Index = Prev = A->getIndex() + 1; Arg *XarchArg = Opts.ParseOneArg(Args, Index); - + // If the argument parsing failed or more than one argument was // consumed, the -Xarch_ argument's parameter tried to consume // extra arguments. Emit an error and ignore. @@ -193,7 +193,7 @@ DerivedArgList *Darwin::TranslateArgs(InputArgList &Args) const { // driver behavior; that isn't going to work in our model. We // use isDriverOption() as an approximation, although things // like -O4 are going to slip through. - if (!XarchArg || Index > Prev + 1 || + if (!XarchArg || Index > Prev + 1 || XarchArg->getOption().isDriverOption()) { getHost().getDriver().Diag(clang::diag::err_drv_invalid_Xarch_argument) << A->getAsString(Args); @@ -202,7 +202,7 @@ DerivedArgList *Darwin::TranslateArgs(InputArgList &Args) const { XarchArg->setBaseArg(A); A = XarchArg; - } + } // Sob. These is strictly gcc compatible for the time being. Apple // gcc translates options twice, which means that self-expanding @@ -219,7 +219,7 @@ DerivedArgList *Darwin::TranslateArgs(InputArgList &Args) const { DAL->append(DAL->MakeFlagArg(A, Opts.getOption(options::OPT_static))); DAL->append(DAL->MakeFlagArg(A, Opts.getOption(options::OPT_static))); break; - + case options::OPT_dependency_file: DAL->append(DAL->MakeSeparateArg(A, Opts.getOption(options::OPT_MF), A->getValue(Args))); @@ -292,10 +292,10 @@ DerivedArgList *Darwin::TranslateArgs(InputArgList &Args) const { "core2")); return DAL; -} +} bool Darwin::IsMathErrnoDefault() const { - return false; + return false; } bool Darwin::IsUnwindTablesDefault() const { @@ -319,13 +319,12 @@ const char *Darwin::GetForcedPicModel() const { /// command line options. Generic_GCC::Generic_GCC(const HostInfo &Host, const llvm::Triple& Triple) - : ToolChain(Host, Triple) -{ + : ToolChain(Host, Triple) { std::string Path(getHost().getDriver().Dir); Path += "/../libexec"; getProgramPaths().push_back(Path); - getProgramPaths().push_back(getHost().getDriver().Dir); + getProgramPaths().push_back(getHost().getDriver().Dir); } Generic_GCC::~Generic_GCC() { @@ -335,7 +334,7 @@ Generic_GCC::~Generic_GCC() { delete it->second; } -Tool &Generic_GCC::SelectTool(const Compilation &C, +Tool &Generic_GCC::SelectTool(const Compilation &C, const JobAction &JA) const { Action::ActionClass Key; if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple())) @@ -361,7 +360,7 @@ Tool &Generic_GCC::SelectTool(const Compilation &C, T = new tools::gcc::Assemble(*this); break; case Action::LinkJobClass: T = new tools::gcc::Link(*this); break; - + // This is a bit ungeneric, but the only platform using a driver // driver is Darwin. case Action::LipoJobClass: @@ -373,7 +372,7 @@ Tool &Generic_GCC::SelectTool(const Compilation &C, } bool Generic_GCC::IsMathErrnoDefault() const { - return true; + return true; } bool Generic_GCC::IsUnwindTablesDefault() const { @@ -469,7 +468,7 @@ AuroraUX::AuroraUX(const HostInfo &Host, const llvm::Triple& Triple) Path += "/../libexec"; getProgramPaths().push_back(Path); - getProgramPaths().push_back(getHost().getDriver().Dir); + getProgramPaths().push_back(getHost().getDriver().Dir); getFilePaths().push_back(getHost().getDriver().Dir + "/../lib"); getFilePaths().push_back("/usr/lib"); @@ -536,7 +535,7 @@ DragonFly::DragonFly(const HostInfo &Host, const llvm::Triple& Triple) Path += "/../libexec"; getProgramPaths().push_back(Path); - getProgramPaths().push_back(getHost().getDriver().Dir); + getProgramPaths().push_back(getHost().getDriver().Dir); getFilePaths().push_back(getHost().getDriver().Dir + "/../lib"); getFilePaths().push_back("/usr/lib"); diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h index b0cc9cbecd..6a3ce37975 100644 --- a/lib/Driver/ToolChains.h +++ b/lib/Driver/ToolChains.h @@ -69,7 +69,7 @@ class VISIBILITY_HIDDEN Darwin : public ToolChain { const char *getMacosxVersionMin() const; public: - Darwin(const HostInfo &Host, const llvm::Triple& Triple, + Darwin(const HostInfo &Host, const llvm::Triple& Triple, const unsigned (&DarwinVersion)[3], const unsigned (&GCCVersion)[3], bool IsIPhone); @@ -95,7 +95,7 @@ public: return IPhoneOSVersionMin.c_str(); } - const std::string &getToolChainDir() const { + const std::string &getToolChainDir() const { return ToolChainDir; } @@ -114,7 +114,7 @@ public: |