diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2012-10-22 22:13:48 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2012-10-22 22:13:48 +0000 |
commit | c635710bcbb9598acd5a14647ba7ca28bee89a68 (patch) | |
tree | 978feeef3e87ac75ea630c0c301bc5c96a79b1af /lib/Driver/ArgList.cpp | |
parent | 6b8194e4d7ca980087a3a5e1addb74090be990ff (diff) |
[Options] Add prefixes to options.
Each option has a set of prefixes. When matching an argument such as
-funroll-loops. First the leading - is removed as it is a prefix. Then
a lower_bound search for "funroll-loops" is done against the option table by
option name. From there each option prefix + option name combination is tested
against the argument.
This allows us to support Microsoft style options where both / and - are valid
prefixes. It also simplifies the cases we already have where options come in
both - and -- forms. Almost every option for gnu-ld happens to have this form.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166444 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/ArgList.cpp')
-rw-r--r-- | lib/Driver/ArgList.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/Driver/ArgList.cpp b/lib/Driver/ArgList.cpp index 3b824f7c81..28d6b1e023 100644 --- a/lib/Driver/ArgList.cpp +++ b/lib/Driver/ArgList.cpp @@ -363,7 +363,9 @@ const char *DerivedArgList::MakeArgString(StringRef Str) const { } Arg *DerivedArgList::MakeFlagArg(const Arg *BaseArg, const Option Opt) const { - Arg *A = new Arg(Opt, BaseArgs.MakeIndex(Opt.getName()), BaseArg); + Arg *A = new Arg(Opt, ArgList::MakeArgString(Twine(Opt.getPrefix()) + + Twine(Opt.getName())), + BaseArgs.MakeIndex(Opt.getName()), BaseArg); SynthesizedArgs.push_back(A); return A; } @@ -371,7 +373,9 @@ Arg *DerivedArgList::MakeFlagArg(const Arg *BaseArg, const Option Opt) const { 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); + Arg *A = new Arg(Opt, ArgList::MakeArgString(Twine(Opt.getPrefix()) + + Twine(Opt.getName())), + Index, BaseArgs.getArgString(Index), BaseArg); SynthesizedArgs.push_back(A); return A; } @@ -379,7 +383,9 @@ Arg *DerivedArgList::MakePositionalArg(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); - Arg *A = new Arg(Opt, Index, BaseArgs.getArgString(Index + 1), BaseArg); + Arg *A = new Arg(Opt, ArgList::MakeArgString(Twine(Opt.getPrefix()) + + Twine(Opt.getName())), + Index, BaseArgs.getArgString(Index + 1), BaseArg); SynthesizedArgs.push_back(A); return A; } @@ -387,7 +393,8 @@ Arg *DerivedArgList::MakeSeparateArg(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()); - Arg *A = new Arg(Opt, Index, + Arg *A = new Arg(Opt, ArgList::MakeArgString(Twine(Opt.getPrefix()) + + Twine(Opt.getName())), Index, BaseArgs.getArgString(Index) + Opt.getName().size(), BaseArg); SynthesizedArgs.push_back(A); |