From: Daniel Dunbar Date: Thu, 19 Nov 2009 04:25:06 +0000 (+0000) Subject: Driver: Take option ID for {Input,Unknown}Option, to drop dependency on actual options. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a0289fda5b5d67ad49596a5e1f62e1f9db497d06;p=clang Driver: Take option ID for {Input,Unknown}Option, to drop dependency on actual options. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89312 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/Option.h b/include/clang/Driver/Option.h index 5daeef942e..08b94b1d79 100644 --- a/include/clang/Driver/Option.h +++ b/include/clang/Driver/Option.h @@ -177,7 +177,7 @@ namespace driver { /// InputOption - Dummy option class for representing driver inputs. class InputOption : public Option { public: - InputOption(); + InputOption(OptSpecifier ID); virtual Arg *accept(const InputArgList &Args, unsigned &Index) const; @@ -190,7 +190,7 @@ namespace driver { /// UnknownOption - Dummy option class for represent unknown arguments. class UnknownOption : public Option { public: - UnknownOption(); + UnknownOption(OptSpecifier ID); virtual Arg *accept(const InputArgList &Args, unsigned &Index) const; diff --git a/lib/Driver/OptTable.cpp b/lib/Driver/OptTable.cpp index fae7f75f37..890907b2a7 100644 --- a/lib/Driver/OptTable.cpp +++ b/lib/Driver/OptTable.cpp @@ -136,9 +136,9 @@ Option *OptTable::CreateOption(unsigned id) const { Option *Opt = 0; switch (info.Kind) { case Option::InputClass: - Opt = new InputOption(); break; + Opt = new InputOption(id); break; case Option::UnknownClass: - Opt = new UnknownOption(); break; + Opt = new UnknownOption(id); break; case Option::GroupClass: Opt = new OptionGroup(id, info.Name, Group); break; case Option::FlagClass: @@ -188,7 +188,7 @@ Arg *OptTable::ParseOneArg(const InputArgList &Args, unsigned &Index) const { return new PositionalArg(TheInputOption, Index++); const Info *Start = OptionInfos + FirstSearchableIndex; - const Info *End = OptionInfos + LastOption - 1; + const Info *End = OptionInfos + getNumOptions(); // Search for the first next option which could be a prefix. Start = std::lower_bound(Start, End, Str); @@ -210,8 +210,7 @@ Arg *OptTable::ParseOneArg(const InputArgList &Args, unsigned &Index) const { break; // See if this option matches. - options::ID id = (options::ID) (Start - OptionInfos + 1); - if (Arg *A = getOption(id)->accept(Args, Index)) + if (Arg *A = getOption(Start - OptionInfos + 1)->accept(Args, Index)) return A; // Otherwise, see if this argument was missing values. diff --git a/lib/Driver/Option.cpp b/lib/Driver/Option.cpp index 89e99999cf..17d00f50aa 100644 --- a/lib/Driver/Option.cpp +++ b/lib/Driver/Option.cpp @@ -94,8 +94,8 @@ Arg *OptionGroup::accept(const InputArgList &Args, unsigned &Index) const { return 0; } -InputOption::InputOption() - : Option(Option::InputClass, options::OPT_INPUT, "", 0, 0) { +InputOption::InputOption(OptSpecifier ID) + : Option(Option::InputClass, ID, "", 0, 0) { } Arg *InputOption::accept(const InputArgList &Args, unsigned &Index) const { @@ -103,8 +103,8 @@ Arg *InputOption::accept(const InputArgList &Args, unsigned &Index) const { return 0; } -UnknownOption::UnknownOption() - : Option(Option::UnknownClass, options::OPT_UNKNOWN, "", 0, 0) { +UnknownOption::UnknownOption(OptSpecifier ID) + : Option(Option::UnknownClass, ID, "", 0, 0) { } Arg *UnknownOption::accept(const InputArgList &Args, unsigned &Index) const {