|
12 | 12 | #include "clang/Driver/Arg.h"
|
13 | 13 | #include "clang/Driver/ArgList.h"
|
14 | 14 | #include "clang/Driver/Driver.h"
|
| 15 | +#include "clang/Driver/DriverDiagnostic.h" |
15 | 16 | #include "clang/Driver/HostInfo.h"
|
| 17 | +#include "clang/Driver/Option.h" |
16 | 18 |
|
17 | 19 | #include "llvm/ADT/StringExtras.h"
|
18 | 20 | #include "llvm/System/Path.h"
|
@@ -125,8 +127,45 @@ Tool &Darwin_X86::SelectTool(const Compilation &C,
|
125 | 127 | }
|
126 | 128 |
|
127 | 129 | DerivedArgList *Darwin_X86::TranslateArgs(InputArgList &Args) const {
|
128 |
| - // FIXME: Implement! |
129 |
| - return new DerivedArgList(Args, true); |
| 130 | + DerivedArgList *DAL = new DerivedArgList(Args, false); |
| 131 | + |
| 132 | + for (ArgList::iterator it = Args.begin(), ie = Args.end(); it != ie; ++it) { |
| 133 | + Arg *A = *it; |
| 134 | + |
| 135 | + if (A->getOption().matches(options::OPT_Xarch__)) { |
| 136 | + // FIXME: Canonicalize name. |
| 137 | + if (getArchName() != A->getValue(Args, 0)) |
| 138 | + continue; |
| 139 | + |
| 140 | + // FIXME: The arg is leaked here, and we should have a nicer |
| 141 | + // interface for this. |
| 142 | + const Driver &D = getHost().getDriver(); |
| 143 | + unsigned Prev, Index = Prev = A->getIndex() + 1; |
| 144 | + Arg *XarchArg = D.getOpts().ParseOneArg(Args, Index); |
| 145 | + |
| 146 | + // If the argument parsing failed or more than one argument was |
| 147 | + // consumed, the -Xarch_ argument's parameter tried to consume |
| 148 | + // extra arguments. Emit an error and ignore. |
| 149 | + // |
| 150 | + // We also want to disallow any options which would alter the |
| 151 | + // driver behavior; that isn't going to work in our model. We |
| 152 | + // use isDriverOption() as an approximation, although things |
| 153 | + // like -O4 are going to slip through. |
| 154 | + if (!XarchArg || Index > Prev + 1 || |
| 155 | + XarchArg->getOption().isDriverOption()) { |
| 156 | + D.Diag(clang::diag::err_drv_invalid_Xarch_argument) |
| 157 | + << A->getAsString(Args); |
| 158 | + continue; |
| 159 | + } |
| 160 | + |
| 161 | + A = XarchArg; |
| 162 | + } |
| 163 | + |
| 164 | + // FIXME: Translate. |
| 165 | + DAL->append(A); |
| 166 | + } |
| 167 | + |
| 168 | + return DAL; |
130 | 169 | }
|
131 | 170 |
|
132 | 171 | bool Darwin_X86::IsMathErrnoDefault() const {
|
|
0 commit comments