Nick Lewycky | 3fdcc6f | 2010-12-31 17:31:54 +0000 | [diff] [blame] | 1 | //===--- ArgList.cpp - Argument List Management ---------------------------===// |
Daniel Dunbar | 6ac1e22 | 2009-03-04 17:10:42 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "clang/Driver/ArgList.h" |
| 11 | #include "clang/Driver/Arg.h" |
Daniel Dunbar | 03e8ab2 | 2010-05-20 16:54:55 +0000 | [diff] [blame] | 12 | #include "clang/Driver/DriverDiagnostic.h" |
Daniel Dunbar | 9358dc8 | 2009-03-04 22:40:08 +0000 | [diff] [blame] | 13 | #include "clang/Driver/Option.h" |
Daniel Dunbar | 6ac1e22 | 2009-03-04 17:10:42 +0000 | [diff] [blame] | 14 | |
Daniel Dunbar | 16484af | 2009-09-09 22:32:26 +0000 | [diff] [blame] | 15 | #include "llvm/ADT/SmallString.h" |
| 16 | #include "llvm/ADT/Twine.h" |
| 17 | #include "llvm/Support/raw_ostream.h" |
| 18 | |
Benjamin Kramer | a5ddbca | 2010-05-21 19:58:44 +0000 | [diff] [blame] | 19 | using namespace clang; |
Daniel Dunbar | 6ac1e22 | 2009-03-04 17:10:42 +0000 | [diff] [blame] | 20 | using namespace clang::driver; |
| 21 | |
Daniel Dunbar | 3b84f5b | 2009-11-25 11:33:30 +0000 | [diff] [blame] | 22 | void arg_iterator::SkipToNextArg() { |
| 23 | for (; Current != Args.end(); ++Current) { |
| 24 | // Done if there are no filters. |
| 25 | if (!Id0.isValid()) |
| 26 | break; |
| 27 | |
| 28 | // Otherwise require a match. |
| 29 | const Option &O = (*Current)->getOption(); |
| 30 | if (O.matches(Id0) || |
| 31 | (Id1.isValid() && O.matches(Id1)) || |
| 32 | (Id2.isValid() && O.matches(Id2))) |
| 33 | break; |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | // |
| 38 | |
Daniel Dunbar | 3612bc8 | 2010-06-11 22:00:22 +0000 | [diff] [blame] | 39 | ArgList::ArgList() { |
Daniel Dunbar | 6ac1e22 | 2009-03-04 17:10:42 +0000 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | ArgList::~ArgList() { |
Daniel Dunbar | 6ac1e22 | 2009-03-04 17:10:42 +0000 | [diff] [blame] | 43 | } |
Daniel Dunbar | 9358dc8 | 2009-03-04 22:40:08 +0000 | [diff] [blame] | 44 | |
| 45 | void ArgList::append(Arg *A) { |
Daniel Dunbar | 9358dc8 | 2009-03-04 22:40:08 +0000 | [diff] [blame] | 46 | Args.push_back(A); |
| 47 | } |
Daniel Dunbar | d8cadd4 | 2009-03-12 01:36:44 +0000 | [diff] [blame] | 48 | |
Daniel Dunbar | 9e1f982 | 2009-11-19 04:14:53 +0000 | [diff] [blame] | 49 | Arg *ArgList::getLastArgNoClaim(OptSpecifier Id) const { |
Daniel Dunbar | d8cadd4 | 2009-03-12 01:36:44 +0000 | [diff] [blame] | 50 | // FIXME: Make search efficient? |
Daniel Dunbar | e4bdae7 | 2009-11-19 04:00:53 +0000 | [diff] [blame] | 51 | for (const_reverse_iterator it = rbegin(), ie = rend(); it != ie; ++it) |
| 52 | if ((*it)->getOption().matches(Id)) |
Daniel Dunbar | 0c562a2 | 2009-03-12 16:03:38 +0000 | [diff] [blame] | 53 | return *it; |
Daniel Dunbar | 0c562a2 | 2009-03-12 16:03:38 +0000 | [diff] [blame] | 54 | return 0; |
Daniel Dunbar | d8cadd4 | 2009-03-12 01:36:44 +0000 | [diff] [blame] | 55 | } |
Daniel Dunbar | bca58cb | 2009-03-12 18:20:18 +0000 | [diff] [blame] | 56 | |
Daniel Dunbar | 9e1f982 | 2009-11-19 04:14:53 +0000 | [diff] [blame] | 57 | Arg *ArgList::getLastArg(OptSpecifier Id) const { |
Rafael Espindola | 592f241 | 2010-12-20 22:45:09 +0000 | [diff] [blame] | 58 | Arg *Res = 0; |
| 59 | for (const_iterator it = begin(), ie = end(); it != ie; ++it) { |
| 60 | if ((*it)->getOption().matches(Id)) { |
| 61 | Res = *it; |
| 62 | Res->claim(); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | return Res; |
Daniel Dunbar | e4bdae7 | 2009-11-19 04:00:53 +0000 | [diff] [blame] | 67 | } |
| 68 | |
Daniel Dunbar | 9e1f982 | 2009-11-19 04:14:53 +0000 | [diff] [blame] | 69 | Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1) const { |
Daniel Dunbar | fdbe65e | 2010-06-14 20:20:44 +0000 | [diff] [blame] | 70 | Arg *Res = 0; |
Rafael Espindola | 592f241 | 2010-12-20 22:45:09 +0000 | [diff] [blame] | 71 | for (const_iterator it = begin(), ie = end(); it != ie; ++it) { |
Daniel Dunbar | fdbe65e | 2010-06-14 20:20:44 +0000 | [diff] [blame] | 72 | if ((*it)->getOption().matches(Id0) || |
| 73 | (*it)->getOption().matches(Id1)) { |
| 74 | Res = *it; |
Rafael Espindola | 592f241 | 2010-12-20 22:45:09 +0000 | [diff] [blame] | 75 | Res->claim(); |
| 76 | |
Daniel Dunbar | fdbe65e | 2010-06-14 20:20:44 +0000 | [diff] [blame] | 77 | } |
| 78 | } |
Daniel Dunbar | cd4e186 | 2009-03-17 18:51:42 +0000 | [diff] [blame] | 79 | |
Daniel Dunbar | cd4e186 | 2009-03-17 18:51:42 +0000 | [diff] [blame] | 80 | return Res; |
| 81 | } |
| 82 | |
Daniel Dunbar | 9e1f982 | 2009-11-19 04:14:53 +0000 | [diff] [blame] | 83 | Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1, |
| 84 | OptSpecifier Id2) const { |
Bill Wendling | 45483f7 | 2009-06-28 07:36:13 +0000 | [diff] [blame] | 85 | Arg *Res = 0; |
Rafael Espindola | 592f241 | 2010-12-20 22:45:09 +0000 | [diff] [blame] | 86 | for (const_iterator it = begin(), ie = end(); it != ie; ++it) { |
Daniel Dunbar | fdbe65e | 2010-06-14 20:20:44 +0000 | [diff] [blame] | 87 | if ((*it)->getOption().matches(Id0) || |
| 88 | (*it)->getOption().matches(Id1) || |
| 89 | (*it)->getOption().matches(Id2)) { |
| 90 | Res = *it; |
Rafael Espindola | 592f241 | 2010-12-20 22:45:09 +0000 | [diff] [blame] | 91 | Res->claim(); |
Daniel Dunbar | fdbe65e | 2010-06-14 20:20:44 +0000 | [diff] [blame] | 92 | } |
Bill Wendling | 45483f7 | 2009-06-28 07:36:13 +0000 | [diff] [blame] | 93 | } |
| 94 | |
Bill Wendling | 45483f7 | 2009-06-28 07:36:13 +0000 | [diff] [blame] | 95 | return Res; |
| 96 | } |
| 97 | |
Daniel Dunbar | 47e879d | 2010-07-13 23:31:40 +0000 | [diff] [blame] | 98 | Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1, |
| 99 | OptSpecifier Id2, OptSpecifier Id3) const { |
| 100 | Arg *Res = 0; |
Rafael Espindola | 592f241 | 2010-12-20 22:45:09 +0000 | [diff] [blame] | 101 | for (const_iterator it = begin(), ie = end(); it != ie; ++it) { |
Daniel Dunbar | 47e879d | 2010-07-13 23:31:40 +0000 | [diff] [blame] | 102 | if ((*it)->getOption().matches(Id0) || |
| 103 | (*it)->getOption().matches(Id1) || |
| 104 | (*it)->getOption().matches(Id2) || |
| 105 | (*it)->getOption().matches(Id3)) { |
| 106 | Res = *it; |
Rafael Espindola | 592f241 | 2010-12-20 22:45:09 +0000 | [diff] [blame] | 107 | Res->claim(); |
Daniel Dunbar | 47e879d | 2010-07-13 23:31:40 +0000 | [diff] [blame] | 108 | } |
| 109 | } |
| 110 | |
Daniel Dunbar | 47e879d | 2010-07-13 23:31:40 +0000 | [diff] [blame] | 111 | return Res; |
| 112 | } |
| 113 | |
Daniel Dunbar | 9e1f982 | 2009-11-19 04:14:53 +0000 | [diff] [blame] | 114 | bool ArgList::hasFlag(OptSpecifier Pos, OptSpecifier Neg, bool Default) const { |
Daniel Dunbar | 9af6668 | 2009-04-07 21:08:57 +0000 | [diff] [blame] | 115 | if (Arg *A = getLastArg(Pos, Neg)) |
| 116 | return A->getOption().matches(Pos); |
Daniel Dunbar | 18a7f33 | 2009-03-18 09:29:36 +0000 | [diff] [blame] | 117 | return Default; |
| 118 | } |
| 119 | |
Daniel Dunbar | 03e8ab2 | 2010-05-20 16:54:55 +0000 | [diff] [blame] | 120 | llvm::StringRef ArgList::getLastArgValue(OptSpecifier Id, |
| 121 | llvm::StringRef Default) const { |
| 122 | if (Arg *A = getLastArg(Id)) |
| 123 | return A->getValue(*this); |
| 124 | return Default; |
| 125 | } |
| 126 | |
| 127 | int ArgList::getLastArgIntValue(OptSpecifier Id, int Default, |
Daniel Dunbar | 5e30b8b | 2010-05-22 05:05:12 +0000 | [diff] [blame] | 128 | clang::Diagnostic &Diags) const { |
Daniel Dunbar | 03e8ab2 | 2010-05-20 16:54:55 +0000 | [diff] [blame] | 129 | int Res = Default; |
| 130 | |
| 131 | if (Arg *A = getLastArg(Id)) { |
| 132 | if (llvm::StringRef(A->getValue(*this)).getAsInteger(10, Res)) |
| 133 | Diags.Report(diag::err_drv_invalid_int_value) |
| 134 | << A->getAsString(*this) << A->getValue(*this); |
| 135 | } |
| 136 | |
| 137 | return Res; |
| 138 | } |
| 139 | |
| 140 | std::vector<std::string> ArgList::getAllArgValues(OptSpecifier Id) const { |
| 141 | llvm::SmallVector<const char *, 16> Values; |
| 142 | AddAllArgValues(Values, Id); |
| 143 | return std::vector<std::string>(Values.begin(), Values.end()); |
| 144 | } |
| 145 | |
Daniel Dunbar | 9e1f982 | 2009-11-19 04:14:53 +0000 | [diff] [blame] | 146 | void ArgList::AddLastArg(ArgStringList &Output, OptSpecifier Id) const { |
Daniel Dunbar | 18a7f33 | 2009-03-18 09:29:36 +0000 | [diff] [blame] | 147 | if (Arg *A = getLastArg(Id)) { |
| 148 | A->claim(); |
| 149 | A->render(*this, Output); |
| 150 | } |
| 151 | } |
| 152 | |
Daniel Dunbar | 9e1f982 | 2009-11-19 04:14:53 +0000 | [diff] [blame] | 153 | void ArgList::AddAllArgs(ArgStringList &Output, OptSpecifier Id0, |
| 154 | OptSpecifier Id1, OptSpecifier Id2) const { |
Daniel Dunbar | 3b84f5b | 2009-11-25 11:33:30 +0000 | [diff] [blame] | 155 | for (arg_iterator it = filtered_begin(Id0, Id1, Id2), |
| 156 | ie = filtered_end(); it != ie; ++it) { |
Daniel Dunbar | 7e4953e | 2010-06-11 22:00:13 +0000 | [diff] [blame] | 157 | (*it)->claim(); |
| 158 | (*it)->render(*this, Output); |
Daniel Dunbar | 18a7f33 | 2009-03-18 09:29:36 +0000 | [diff] [blame] | 159 | } |
| 160 | } |
Daniel Dunbar | ee51031 | 2009-03-20 15:59:01 +0000 | [diff] [blame] | 161 | |
Daniel Dunbar | 9e1f982 | 2009-11-19 04:14:53 +0000 | [diff] [blame] | 162 | void ArgList::AddAllArgValues(ArgStringList &Output, OptSpecifier Id0, |
Daniel Dunbar | 3b84f5b | 2009-11-25 11:33:30 +0000 | [diff] [blame] | 163 | OptSpecifier Id1, OptSpecifier Id2) const { |
| 164 | for (arg_iterator it = filtered_begin(Id0, Id1, Id2), |
| 165 | ie = filtered_end(); it != ie; ++it) { |
Daniel Dunbar | 7e4953e | 2010-06-11 22:00:13 +0000 | [diff] [blame] | 166 | (*it)->claim(); |
| 167 | for (unsigned i = 0, e = (*it)->getNumValues(); i != e; ++i) |
| 168 | Output.push_back((*it)->getValue(*this, i)); |
Daniel Dunbar | ee51031 | 2009-03-20 15:59:01 +0000 | [diff] [blame] | 169 | } |
| 170 | } |
Daniel Dunbar | f3cad36 | 2009-03-25 04:13:45 +0000 | [diff] [blame] | 171 | |
Daniel Dunbar | 9e1f982 | 2009-11-19 04:14:53 +0000 | [diff] [blame] | 172 | void ArgList::AddAllArgsTranslated(ArgStringList &Output, OptSpecifier Id0, |
Daniel Dunbar | 4df9a66 | 2009-04-26 01:07:52 +0000 | [diff] [blame] | 173 | const char *Translation, |
| 174 | bool Joined) const { |
Daniel Dunbar | 3b84f5b | 2009-11-25 11:33:30 +0000 | [diff] [blame] | 175 | for (arg_iterator it = filtered_begin(Id0), |
| 176 | ie = filtered_end(); it != ie; ++it) { |
Daniel Dunbar | 7e4953e | 2010-06-11 22:00:13 +0000 | [diff] [blame] | 177 | (*it)->claim(); |
Daniel Dunbar | 4df9a66 | 2009-04-26 01:07:52 +0000 | [diff] [blame] | 178 | |
Daniel Dunbar | 3b84f5b | 2009-11-25 11:33:30 +0000 | [diff] [blame] | 179 | if (Joined) { |
| 180 | Output.push_back(MakeArgString(llvm::StringRef(Translation) + |
Daniel Dunbar | 7e4953e | 2010-06-11 22:00:13 +0000 | [diff] [blame] | 181 | (*it)->getValue(*this, 0))); |
Daniel Dunbar | 3b84f5b | 2009-11-25 11:33:30 +0000 | [diff] [blame] | 182 | } else { |
| 183 | Output.push_back(Translation); |
Daniel Dunbar | 7e4953e | 2010-06-11 22:00:13 +0000 | [diff] [blame] | 184 | Output.push_back((*it)->getValue(*this, 0)); |
Daniel Dunbar | 524b9fb | 2009-03-26 15:39:22 +0000 | [diff] [blame] | 185 | } |
| 186 | } |
| 187 | } |
| 188 | |
Daniel Dunbar | 9e1f982 | 2009-11-19 04:14:53 +0000 | [diff] [blame] | 189 | void ArgList::ClaimAllArgs(OptSpecifier Id0) const { |
Daniel Dunbar | 3b84f5b | 2009-11-25 11:33:30 +0000 | [diff] [blame] | 190 | for (arg_iterator it = filtered_begin(Id0), |
| 191 | ie = filtered_end(); it != ie; ++it) |
Daniel Dunbar | 7e4953e | 2010-06-11 22:00:13 +0000 | [diff] [blame] | 192 | (*it)->claim(); |
Daniel Dunbar | 68fb469 | 2009-04-03 20:51:31 +0000 | [diff] [blame] | 193 | } |
| 194 | |
Daniel Dunbar | 16484af | 2009-09-09 22:32:26 +0000 | [diff] [blame] | 195 | const char *ArgList::MakeArgString(const llvm::Twine &T) const { |
| 196 | llvm::SmallString<256> Str; |
| 197 | T.toVector(Str); |
| 198 | return MakeArgString(Str.str()); |
| 199 | } |
| 200 | |
Daniel Dunbar | 312a8b7 | 2010-06-09 18:49:38 +0000 | [diff] [blame] | 201 | const char *ArgList::GetOrMakeJoinedArgString(unsigned Index, |
| 202 | llvm::StringRef LHS, |
| 203 | llvm::StringRef RHS) const { |
| 204 | llvm::StringRef Cur = getArgString(Index); |
| 205 | if (Cur.size() == LHS.size() + RHS.size() && |
| 206 | Cur.startswith(LHS) && Cur.endswith(RHS)) |
| 207 | return Cur.data(); |
| 208 | |
| 209 | return MakeArgString(LHS + RHS); |
| 210 | } |
| 211 | |
Daniel Dunbar | f3cad36 | 2009-03-25 04:13:45 +0000 | [diff] [blame] | 212 | // |
| 213 | |
Axel Naumann | 9d520c5 | 2010-10-11 09:18:43 +0000 | [diff] [blame] | 214 | InputArgList::InputArgList(const char* const *ArgBegin, |
| 215 | const char* const *ArgEnd) |
Daniel Dunbar | 3612bc8 | 2010-06-11 22:00:22 +0000 | [diff] [blame] | 216 | : NumInputArgStrings(ArgEnd - ArgBegin) { |
Daniel Dunbar | f3cad36 | 2009-03-25 04:13:45 +0000 | [diff] [blame] | 217 | ArgStrings.append(ArgBegin, ArgEnd); |
| 218 | } |
| 219 | |
| 220 | InputArgList::~InputArgList() { |
| 221 | // An InputArgList always owns its arguments. |
| 222 | for (iterator it = begin(), ie = end(); it != ie; ++it) |
| 223 | delete *it; |
| 224 | } |
| 225 | |
Daniel Dunbar | 16484af | 2009-09-09 22:32:26 +0000 | [diff] [blame] | 226 | unsigned InputArgList::MakeIndex(llvm::StringRef String0) const { |
Daniel Dunbar | f3cad36 | 2009-03-25 04:13:45 +0000 | [diff] [blame] | 227 | unsigned Index = ArgStrings.size(); |
| 228 | |
| 229 | // Tuck away so we have a reliable const char *. |
| 230 | SynthesizedStrings.push_back(String0); |
| 231 | ArgStrings.push_back(SynthesizedStrings.back().c_str()); |
| 232 | |
| 233 | return Index; |
| 234 | } |
| 235 | |
Daniel Dunbar | 16484af | 2009-09-09 22:32:26 +0000 | [diff] [blame] | 236 | unsigned InputArgList::MakeIndex(llvm::StringRef String0, |
| 237 | llvm::StringRef String1) const { |
Daniel Dunbar | f3cad36 | 2009-03-25 04:13:45 +0000 | [diff] [blame] | 238 | unsigned Index0 = MakeIndex(String0); |
| 239 | unsigned Index1 = MakeIndex(String1); |
| 240 | assert(Index0 + 1 == Index1 && "Unexpected non-consecutive indices!"); |
| 241 | (void) Index1; |
| 242 | return Index0; |
| 243 | } |
| 244 | |
Daniel Dunbar | 16484af | 2009-09-09 22:32:26 +0000 | [diff] [blame] | 245 | const char *InputArgList::MakeArgString(llvm::StringRef Str) const { |
Daniel Dunbar | f3cad36 | 2009-03-25 04:13:45 +0000 | [diff] [blame] | 246 | return getArgString(MakeIndex(Str)); |
| 247 | } |
| 248 | |
| 249 | // |
| 250 | |
Daniel Dunbar | 279c1db | 2010-06-11 22:00:26 +0000 | [diff] [blame] | 251 | DerivedArgList::DerivedArgList(const InputArgList &_BaseArgs) |
Daniel Dunbar | 3612bc8 | 2010-06-11 22:00:22 +0000 | [diff] [blame] | 252 | : BaseArgs(_BaseArgs) { |
Daniel Dunbar | f3cad36 | 2009-03-25 04:13:45 +0000 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | DerivedArgList::~DerivedArgList() { |
| 256 | // We only own the arguments we explicitly synthesized. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 257 | for (iterator it = SynthesizedArgs.begin(), ie = SynthesizedArgs.end(); |
Daniel Dunbar | f3cad36 | 2009-03-25 04:13:45 +0000 | [diff] [blame] | 258 | it != ie; ++it) |
| 259 | delete *it; |
| 260 | } |
| 261 | |
Daniel Dunbar | 16484af | 2009-09-09 22:32:26 +0000 | [diff] [blame] | 262 | const char *DerivedArgList::MakeArgString(llvm::StringRef Str) const { |
Daniel Dunbar | f3cad36 | 2009-03-25 04:13:45 +0000 | [diff] [blame] | 263 | return BaseArgs.MakeArgString(Str); |
| 264 | } |
| 265 | |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 266 | Arg *DerivedArgList::MakeFlagArg(const Arg *BaseArg, const Option *Opt) const { |
Daniel Dunbar | 532c1ec | 2010-06-09 22:31:08 +0000 | [diff] [blame] | 267 | Arg *A = new Arg(Opt, BaseArgs.MakeIndex(Opt->getName()), BaseArg); |
Daniel Dunbar | fd48cb3 | 2010-03-11 18:04:53 +0000 | [diff] [blame] | 268 | SynthesizedArgs.push_back(A); |
| 269 | return A; |
Daniel Dunbar | f3cad36 | 2009-03-25 04:13:45 +0000 | [diff] [blame] | 270 | } |
| 271 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 272 | Arg *DerivedArgList::MakePositionalArg(const Arg *BaseArg, const Option *Opt, |
Daniel Dunbar | 16484af | 2009-09-09 22:32:26 +0000 | [diff] [blame] | 273 | llvm::StringRef Value) const { |
Daniel Dunbar | 4465a77 | 2010-06-09 22:31:00 +0000 | [diff] [blame] | 274 | unsigned Index = BaseArgs.MakeIndex(Value); |
Daniel Dunbar | 532c1ec | 2010-06-09 22:31:08 +0000 | [diff] [blame] | 275 | Arg *A = new Arg(Opt, Index, BaseArgs.getArgString(Index), BaseArg); |
Daniel Dunbar | fd48cb3 | 2010-03-11 18:04:53 +0000 | [diff] [blame] | 276 | SynthesizedArgs.push_back(A); |
| 277 | return A; |
Daniel Dunbar | f3cad36 | 2009-03-25 04:13:45 +0000 | [diff] [blame] | 278 | } |
| 279 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 280 | Arg *DerivedArgList::MakeSeparateArg(const Arg *BaseArg, const Option *Opt, |
Daniel Dunbar | 16484af | 2009-09-09 22:32:26 +0000 | [diff] [blame] | 281 | llvm::StringRef Value) const { |
Daniel Dunbar | 4465a77 | 2010-06-09 22:31:00 +0000 | [diff] [blame] | 282 | unsigned Index = BaseArgs.MakeIndex(Opt->getName(), Value); |
Daniel Dunbar | fdbe65e | 2010-06-14 20:20:44 +0000 | [diff] [blame] | 283 | Arg *A = new Arg(Opt, Index, BaseArgs.getArgString(Index + 1), BaseArg); |
Daniel Dunbar | fd48cb3 | 2010-03-11 18:04:53 +0000 | [diff] [blame] | 284 | SynthesizedArgs.push_back(A); |
| 285 | return A; |
Daniel Dunbar | f3cad36 | 2009-03-25 04:13:45 +0000 | [diff] [blame] | 286 | } |
| 287 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 288 | Arg *DerivedArgList::MakeJoinedArg(const Arg *BaseArg, const Option *Opt, |
Daniel Dunbar | 16484af | 2009-09-09 22:32:26 +0000 | [diff] [blame] | 289 | llvm::StringRef Value) const { |
Daniel Dunbar | 4465a77 | 2010-06-09 22:31:00 +0000 | [diff] [blame] | 290 | unsigned Index = BaseArgs.MakeIndex(Opt->getName() + Value.str()); |
Daniel Dunbar | 532c1ec | 2010-06-09 22:31:08 +0000 | [diff] [blame] | 291 | Arg *A = new Arg(Opt, Index, |
| 292 | BaseArgs.getArgString(Index) + strlen(Opt->getName()), |
| 293 | BaseArg); |
Daniel Dunbar | fd48cb3 | 2010-03-11 18:04:53 +0000 | [diff] [blame] | 294 | SynthesizedArgs.push_back(A); |
| 295 | return A; |
Daniel Dunbar | f3cad36 | 2009-03-25 04:13:45 +0000 | [diff] [blame] | 296 | } |