diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-10-18 22:42:31 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-10-18 22:42:31 +0000 |
commit | f38523388174760dcbad810ef60d8504d7df6b4c (patch) | |
tree | 336884232711ddc238e70b9acca37f23e12bda96 /lib/Driver | |
parent | 25dfaacde51df0834f10e3ab1646e6de9e229788 (diff) |
Revert r166223 and the subsequent commits that depend on it, r166230 & r166235.
This seems to have introduced assertion hit when building compiler-rt.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166245 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver')
-rw-r--r-- | lib/Driver/Arg.cpp | 10 | ||||
-rw-r--r-- | lib/Driver/ArgList.cpp | 16 | ||||
-rw-r--r-- | lib/Driver/Driver.cpp | 6 | ||||
-rw-r--r-- | lib/Driver/OptTable.cpp | 34 | ||||
-rw-r--r-- | lib/Driver/Option.cpp | 29 | ||||
-rw-r--r-- | lib/Driver/ToolChains.cpp | 18 | ||||
-rw-r--r-- | lib/Driver/Tools.cpp | 10 |
7 files changed, 60 insertions, 63 deletions
diff --git a/lib/Driver/Arg.cpp b/lib/Driver/Arg.cpp index b156d7cf71..c0a2a506a6 100644 --- a/lib/Driver/Arg.cpp +++ b/lib/Driver/Arg.cpp @@ -16,19 +16,19 @@ using namespace clang::driver; -Arg::Arg(const Option _Opt, unsigned _Index, const Arg *_BaseArg) +Arg::Arg(const Option *_Opt, unsigned _Index, const Arg *_BaseArg) : Opt(_Opt), BaseArg(_BaseArg), Index(_Index), Claimed(false), OwnsValues(false) { } -Arg::Arg(const Option _Opt, unsigned _Index, +Arg::Arg(const Option *_Opt, unsigned _Index, const char *Value0, const Arg *_BaseArg) : Opt(_Opt), BaseArg(_BaseArg), Index(_Index), Claimed(false), OwnsValues(false) { Values.push_back(Value0); } -Arg::Arg(const Option _Opt, unsigned _Index, +Arg::Arg(const Option *_Opt, unsigned _Index, const char *Value0, const char *Value1, const Arg *_BaseArg) : Opt(_Opt), BaseArg(_BaseArg), Index(_Index), Claimed(false), OwnsValues(false) { @@ -47,7 +47,7 @@ void Arg::dump() const { llvm::errs() << "<"; llvm::errs() << " Opt:"; - Opt.dump(); + Opt->dump(); llvm::errs() << " Index:" << Index; @@ -104,7 +104,7 @@ void Arg::render(const ArgList &Args, ArgStringList &Output) const { Output.push_back(Args.MakeArgString(OS.str())); break; } - + case Option::RenderJoinedStyle: Output.push_back(Args.GetOrMakeJoinedArgString( getIndex(), getOption().getName(), getValue(Args, 0))); diff --git a/lib/Driver/ArgList.cpp b/lib/Driver/ArgList.cpp index 3b824f7c81..7fd439e630 100644 --- a/lib/Driver/ArgList.cpp +++ b/lib/Driver/ArgList.cpp @@ -362,13 +362,13 @@ const char *DerivedArgList::MakeArgString(StringRef Str) const { return BaseArgs.MakeArgString(Str); } -Arg *DerivedArgList::MakeFlagArg(const Arg *BaseArg, const Option Opt) const { - Arg *A = new Arg(Opt, BaseArgs.MakeIndex(Opt.getName()), BaseArg); +Arg *DerivedArgList::MakeFlagArg(const Arg *BaseArg, const Option *Opt) const { + Arg *A = new Arg(Opt, BaseArgs.MakeIndex(Opt->getName()), BaseArg); SynthesizedArgs.push_back(A); return A; } -Arg *DerivedArgList::MakePositionalArg(const Arg *BaseArg, const Option Opt, +Arg *DerivedArgList::MakePositionalArg(const Arg *BaseArg, const Option *Opt, StringRef Value) const { unsigned Index = BaseArgs.MakeIndex(Value); Arg *A = new Arg(Opt, Index, BaseArgs.getArgString(Index), BaseArg); @@ -376,19 +376,19 @@ Arg *DerivedArgList::MakePositionalArg(const Arg *BaseArg, const Option Opt, return A; } -Arg *DerivedArgList::MakeSeparateArg(const Arg *BaseArg, const Option Opt, +Arg *DerivedArgList::MakeSeparateArg(const Arg *BaseArg, const Option *Opt, StringRef Value) const { - unsigned Index = BaseArgs.MakeIndex(Opt.getName(), Value); + unsigned Index = BaseArgs.MakeIndex(Opt->getName(), Value); Arg *A = new Arg(Opt, Index, BaseArgs.getArgString(Index + 1), BaseArg); SynthesizedArgs.push_back(A); return A; } -Arg *DerivedArgList::MakeJoinedArg(const Arg *BaseArg, const Option Opt, +Arg *DerivedArgList::MakeJoinedArg(const Arg *BaseArg, const Option *Opt, StringRef Value) const { - unsigned Index = BaseArgs.MakeIndex(Opt.getName().str() + Value.str()); + unsigned Index = BaseArgs.MakeIndex(Opt->getName().str() + Value.str()); Arg *A = new Arg(Opt, Index, - BaseArgs.getArgString(Index) + Opt.getName().size(), + BaseArgs.getArgString(Index) + Opt->getName().size(), BaseArg); SynthesizedArgs.push_back(A); return A; diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 59cebf58c1..f747621b8c 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -98,7 +98,7 @@ InputArgList *Driver::ParseArgStrings(ArrayRef<const char *> ArgList) { for (ArgList::const_iterator it = Args->begin(), ie = Args->end(); it != ie; ++it) { Arg *A = *it; - if (A->getOption().hasFlag(options::Unsupported)) { + if (A->getOption().isUnsupported()) { Diag(clang::diag::err_drv_unsupported_opt) << A->getAsString(*Args); continue; } @@ -1033,7 +1033,7 @@ void Driver::BuildInputs(const ToolChain &TC, const DerivedArgList &Args, } else Inputs.push_back(std::make_pair(Ty, A)); - } else if (A->getOption().hasFlag(options::LinkerInput)) { + } else if (A->getOption().isLinkerInput()) { // Just treat as object type, we could make a special type for this if // necessary. Inputs.push_back(std::make_pair(types::TY_Object, A)); @@ -1300,7 +1300,7 @@ void Driver::BuildJobs(Compilation &C) const { // DiagnosticsEngine, so that extra values, position, and so on could be // printed. if (!A->isClaimed()) { - if (A->getOption().hasFlag(options::NoArgumentUnused)) + if (A->getOption().hasNoArgumentUnused()) continue; // Suppress the warning automatically if this is just a flag, and it is an diff --git a/lib/Driver/OptTable.cpp b/lib/Driver/OptTable.cpp index 433c3869b5..e108106fa7 100644 --- a/lib/Driver/OptTable.cpp +++ b/lib/Driver/OptTable.cpp @@ -11,7 +11,6 @@ #include "clang/Driver/Arg.h" #include "clang/Driver/ArgList.h" #include "clang/Driver/Option.h" -#include "clang/Driver/Options.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/ErrorHandling.h" #include <algorithm> @@ -80,16 +79,22 @@ OptSpecifier::OptSpecifier(const Option *Opt) : ID(Opt->getID()) {} OptTable::OptTable(const Info *_OptionInfos, unsigned _NumOptionInfos) : OptionInfos(_OptionInfos), NumOptionInfos(_NumOptionInfos), - FirstSearchableIndex(0) + Options(new Option*[NumOptionInfos]), + TheInputOption(0), TheUnknownOption(0), FirstSearchableIndex(0) { // Explicitly zero initialize the error to work around a bug in array // value-initialization on MinGW with gcc 4.3.5. + memset(Options, 0, sizeof(*Options) * NumOptionInfos); // Find start of normal options. for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { unsigned Kind = getInfo(i + 1).Kind; if (Kind == Option::InputClass) { + assert(!TheInputOption && "Cannot have multiple input options!"); + TheInputOption = getOption(i + 1); } else if (Kind == Option::UnknownClass) { + assert(!TheUnknownOption && "Cannot have multiple input options!"); + TheUnknownOption = getOption(i + 1); } else if (Kind != Option::GroupClass) { FirstSearchableIndex = i; break; @@ -110,8 +115,8 @@ OptTable::OptTable(const Info *_OptionInfos, unsigned _NumOptionInfos) // Check that options are in order. for (unsigned i = FirstSearchableIndex+1, e = getNumOptions(); i != e; ++i) { if (!(getInfo(i) < getInfo(i + 1))) { - getOption(i).dump(); - getOption(i + 1).dump(); + getOption(i)->dump(); + getOption(i + 1)->dump(); llvm_unreachable("Options are not in order!"); } } @@ -119,27 +124,26 @@ OptTable::OptTable(const Info *_OptionInfos, unsigned _NumOptionInfos) } OptTable::~OptTable() { -} - -const Option OptTable::getOption(OptSpecifier Opt) const { - unsigned id = Opt.getID(); - if (id == 0) - return Option(0, 0); - assert((unsigned) (id - 1) < getNumOptions() && "Invalid ID."); - return Option(&getInfo(id), this); + for (unsigned i = 0, e = getNumOptions(); i != e; ++i) + delete Options[i]; + delete[] Options; } bool OptTable::isOptionHelpHidden(OptSpecifier id) const { return getInfo(id).Flags & options::HelpHidden; } +Option *OptTable::CreateOption(unsigned id) const { + return new Option(&getInfo(id), this); +} + Arg *OptTable::ParseOneArg(const ArgList &Args, unsigned &Index) const { unsigned Prev = Index; const char *Str = Args.getArgString(Index); // Anything that doesn't start with '-' is an input, as is '-' itself. if (Str[0] != '-' || Str[1] == '\0') - return new Arg(getOption(options::OPT_INPUT), Index++, Str); + return new Arg(TheInputOption, Index++, Str); const Info *Start = OptionInfos + FirstSearchableIndex; const Info *End = OptionInfos + getNumOptions(); @@ -165,7 +169,7 @@ Arg *OptTable::ParseOneArg(const ArgList &Args, unsigned &Index) const { break; // See if this option matches. - if (Arg *A = getOption(Start - OptionInfos + 1).accept(Args, Index)) + if (Arg *A = getOption(Start - OptionInfos + 1)->accept(Args, Index)) return A; // Otherwise, see if this argument was missing values. @@ -173,7 +177,7 @@ Arg *OptTable::ParseOneArg(const ArgList &Args, unsigned &Index) const { return 0; } - return new Arg(getOption(options::OPT_UNKNOWN), Index++, Str); + return new Arg(TheUnknownOption, Index++, Str); } InputArgList *OptTable::ParseArgs(const char* const *ArgBegin, diff --git a/lib/Driver/Option.cpp b/lib/Driver/Option.cpp index 116dbca5b0..117021b880 100644 --- a/lib/Driver/Option.cpp +++ b/lib/Driver/Option.cpp @@ -23,8 +23,7 @@ Option::Option(const OptTable::Info *info, const OptTable *owner) // Multi-level aliases are not supported, and alias options cannot // have groups. This just simplifies option tracking, it is not an // inherent limitation. - assert(!Info || (!getAlias().isValid() || (!getAlias().getAlias().isValid() && - !getGroup().isValid())) && + assert((!getAlias() || (!getAlias()->getAlias() && !getGroup())) && "Multi-level aliases and aliases with groups are unsupported."); } @@ -50,16 +49,16 @@ void Option::dump() const { llvm::errs() << " Name:\"" << getName() << '"'; - const Option Group = getGroup(); - if (Group.isValid()) { + const Option *Group = getGroup(); + if (Group) { llvm::errs() << " Group:"; - Group.dump(); + Group->dump(); } - const Option Alias = getAlias(); - if (Alias.isValid()) { + const Option *Alias = getAlias(); + if (Alias) { llvm::errs() << " Alias:"; - Alias.dump(); + Alias->dump(); } if (getKind() == MultiArgClass) @@ -70,17 +69,17 @@ void Option::dump() const { bool Option::matches(OptSpecifier Opt) const { // Aliases are never considered in matching, look through them. - const Option Alias = getAlias(); - if (Alias.isValid()) - return Alias.matches(Opt); + const Option *Alias = getAlias(); + if (Alias) + return Alias->matches(Opt); // Check exact match. if (getID() == Opt.getID()) return true; - const Option Group = getGroup(); - if (Group.isValid()) - return Group.matches(Opt); + const Option *Group = getGroup(); + if (Group) + return Group->matches(Opt); return false; } @@ -156,7 +155,7 @@ Arg *Option::accept(const ArgList &Args, unsigned &Index) const { // FIXME: Avoid strlen. if (getName().size() != strlen(Args.getArgString(Index))) { const char *Value = Args.getArgString(Index) + getName().size(); - return new Arg(*this, Index++, Value); + return new Arg(this, Index++, Value); } // Otherwise it must be separate. diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index e5773fbe4a..529f7bff48 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -485,7 +485,7 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { } // When using the define to indicate the simulator, we force // 10.6 macosx target. - const Option O = Opts.getOption(options::OPT_mmacosx_version_min_EQ); + const Option *O = Opts.getOption(options::OPT_mmacosx_version_min_EQ); OSXVersion = Args.MakeJoinedArg(0, O, "10.6"); Args.append(OSXVersion); break; @@ -559,21 +559,21 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { } if (!OSXTarget.empty()) { - const Option O = Opts.getOption(options::OPT_mmacosx_version_min_EQ); + const Option *O = Opts.getOption(options::OPT_mmacosx_version_min_EQ); OSXVersion = Args.MakeJoinedArg(0, O, OSXTarget); Args.append(OSXVersion); } else if (!iOSTarget.empty()) { - const Option O = Opts.getOption(options::OPT_miphoneos_version_min_EQ); + const Option *O = Opts.getOption(options::OPT_miphoneos_version_min_EQ); iOSVersion = Args.MakeJoinedArg(0, O, iOSTarget); Args.append(iOSVersion); } else if (!iOSSimTarget.empty()) { - const Option O = Opts.getOption( + const Option *O = Opts.getOption( options::OPT_mios_simulator_version_min_EQ); iOSSimVersion = Args.MakeJoinedArg(0, O, iOSSimTarget); Args.append(iOSSimVersion); } else { // Otherwise, assume we are targeting OS X. - const Option O = Opts.getOption(options::OPT_mmacosx_version_min_EQ); + const Option *O = Opts.getOption(options::OPT_mmacosx_version_min_EQ); OSXVersion = Args.MakeJoinedArg(0, O, MacosxVersionMin); Args.append(OSXVersion); } @@ -737,7 +737,7 @@ DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args, getDriver().Diag(diag::err_drv_invalid_Xarch_argument_with_args) << A->getAsString(Args); continue; - } else if (XarchArg->getOption().hasFlag(options::DriverOption)) { + } else if (XarchArg->getOption().isDriverOption()) { getDriver().Diag(diag::err_drv_invalid_Xarch_argument_isdriver) << A->getAsString(Args); continue; @@ -751,7 +751,7 @@ DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args, // Linker input arguments require custom handling. The problem is that we // have already constructed the phase actions, so we can not treat them as // "input arguments". - if (A->getOption().hasFlag(options::LinkerInput)) { + if (A->getOption().isLinkerInput()) { // Convert the argument into individual Zlinker_input_args. for (unsigned i = 0, e = A->getNumValues(); i != e; ++i) { DAL->AddSeparateArg(OriginalArg, @@ -835,8 +835,8 @@ DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args, // how the driver driver works. if (BoundArch) { StringRef Name = BoundArch; - const Option MCpu = Opts.getOption(options::OPT_mcpu_EQ); - const Option MArch = Opts.getOption(options::OPT_march_EQ); + const Option *MCpu = Opts.getOption(options::OPT_mcpu_EQ); + const Option *MArch = Opts.getOption(options::OPT_march_EQ); // This code must be kept in sync with LLVM's getArchTypeForDarwinArch, // which defines the list of which architectures we accept. diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 80691ee9c4..07d24b411c 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -200,12 +200,6 @@ static void addProfileRT(const ToolChain &TC, const ArgList &Args, CmdArgs.push_back(Args.MakeArgString(ProfileRT)); } -static bool forwardToGCC(const Option &O) { - return !O.hasFlag(options::NoForward) && - !O.hasFlag(options::DriverOption) && - !O.hasFlag(options::LinkerInput); -} - void Clang::AddPreprocessingOptions(Compilation &C, const Driver &D, const ArgList &Args, @@ -3201,7 +3195,7 @@ void gcc::Common::ConstructJob(Compilation &C, const JobAction &JA, for (ArgList::const_iterator it = Args.begin(), ie = Args.end(); it != ie; ++it) { Arg *A = *it; - if (forwardToGCC(A->getOption())) { + if (A->getOption().hasForwardToGCC()) { // Don't forward any -g arguments to assembly steps. if (isa<AssembleJobAction>(JA) && A->getOption().matches(options::OPT_g_Group)) @@ -3426,7 +3420,7 @@ void hexagon::Link::ConstructJob(Compilation &C, const JobAction &JA, for (ArgList::const_iterator it = Args.begin(), ie = Args.end(); it != ie; ++it) { Arg *A = *it; - if (forwardToGCC(A->getOption())) { + if (A->getOption().hasForwardToGCC()) { // Don't forward any -g arguments to assembly steps. if (isa<AssembleJobAction>(JA) && A->getOption().matches(options::OPT_g_Group)) |