const char *getArgString(unsigned Index) const { return ArgStrings[Index]; }
/// hasArg - Does the arg list contain any option matching \arg Id.
- bool hasArg(options::ID Id) const { return getLastArg(Id) != 0; }
+ ///
+ /// \arg Claim Whether the argument should be claimed, if it exists.
+ bool hasArg(options::ID Id, bool Claim=true) const {
+ return getLastArg(Id, Claim) != 0;
+ }
/// getLastArg - Return the last argument matching \arg Id, or null.
- Arg *getLastArg(options::ID Id) const;
+ ///
+ /// \arg Claim Whether the argument should be claimed, if it exists.
+ Arg *getLastArg(options::ID Id, bool Claim=true) const;
/// @name Arg Synthesis
/// @{
Args.push_back(A);
}
-Arg *ArgList::getLastArg(options::ID Id) const {
+Arg *ArgList::getLastArg(options::ID Id, bool Claim) const {
// FIXME: Make search efficient?
// FIXME: This needs to not require loading of the option.
- for (const_iterator it = begin(), ie = end(); it != ie; ++it)
- if ((*it)->getOption().matches(Id))
+ for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
+ if ((*it)->getOption().matches(Id)) {
+ if (Claim) (*it)->claim();
return *it;
+ }
+ }
return 0;
}
//
// Otherwise emit an error but still use a valid type to
// avoid spurious errors (e.g., no inputs).
- if (!Args.hasArg(options::OPT_E))
+ if (!Args.hasArg(options::OPT_E, false))
Diag(clang::diag::err_drv_unknown_stdin_type);
Ty = types::TY_C;
} else {
(FinalPhaseArg = Args.getLastArg(options::OPT_MM))) {
FinalPhase = phases::Preprocess;
- // -{-analyze,fsyntax-only,S} only run up to the compiler.
- } else if ((FinalPhaseArg = Args.getLastArg(options::OPT__analyze)) ||
- (FinalPhaseArg = Args.getLastArg(options::OPT_fsyntax_only)) ||
+ // -{fsyntax-only,-analyze,emit-llvm,S} only run up to the compiler.
+ } else if ((FinalPhaseArg = Args.getLastArg(options::OPT_fsyntax_only)) ||
+ (FinalPhaseArg = Args.getLastArg(options::OPT__analyze)) ||
+ (FinalPhaseArg = Args.getLastArg(options::OPT_emit_llvm)) ||
(FinalPhaseArg = Args.getLastArg(options::OPT_S))) {
FinalPhase = phases::Compile;
} else
FinalPhase = phases::Link;
- if (FinalPhaseArg)
- FinalPhaseArg->claim();
-
// Reject -Z* at the top level, these options should never have been
// exposed by gcc.
if (Arg *A = Args.getLastArg(options::OPT_Z))