static bool classof(const Arg *) { return true; }
void dump() const;
+
+ /// getAsString - Return a formatted version of the argument and
+ /// its values, for debugging and diagnostics.
+ std::string getAsString(const ArgList &Args) const;
};
/// FlagArg - An argument with no value.
llvm::errs() << ">\n";
}
+std::string Arg::getAsString(const ArgList &Args) const {
+ std::string Res;
+ llvm::raw_string_ostream OS(Res);
+
+ ArgStringList ASL;
+ render(Args, ASL);
+ for (ArgStringList::iterator
+ it = ASL.begin(), ie = ASL.end(); it != ie; ++it) {
+ if (it != ASL.begin())
+ OS << ' ';
+ OS << *it;
+ }
+
+ return OS.str();
+}
+
void Arg::renderAsInput(const ArgList &Args, ArgStringList &Output) const {
if (!getOption().hasNoOptAsInput()) {
render(Args, Output);
Arg *A = getOpts().ParseOneArg(*Args, Index, End);
if (A) {
if (A->getOption().isUnsupported()) {
- Diag(clang::diag::err_drv_unsupported_opt) << A->getOption().getName();
+ Diag(clang::diag::err_drv_unsupported_opt) << A->getAsString(*Args);
continue;
}
// overwriting the same files.
if (const Arg *A = Args.getLastArg(options::OPT_M_Group))
Diag(clang::diag::err_drv_invalid_opt_with_multiple_archs)
- << A->getOption().getName();
+ << A->getAsString(Args);
if (const Arg *A = Args.getLastArg(options::OPT_save_temps))
Diag(clang::diag::err_drv_invalid_opt_with_multiple_archs)
- << A->getOption().getName();
+ << A->getAsString(Args);
}
ActionList SingleActions;
// Reject -Z* at the top level, these options should never have been
// exposed by gcc.
if (Arg *A = Args.getLastArg(options::OPT_Z))
- Diag(clang::diag::err_drv_use_of_Z_option) << A->getValue(Args);
+ Diag(clang::diag::err_drv_use_of_Z_option) << A->getAsString(Args);
// Construct the actions to perform.
ActionList LinkerInputs;
// Claim here to avoid the more general unused warning.
InputArg->claim();
Diag(clang::diag::warn_drv_input_file_unused)
- << InputArg->getValue(Args)
+ << InputArg->getAsString(Args)
<< getPhaseName(InitialPhase)
<< FinalPhaseArg->getOption().getName();
continue;
// printed.
if (!A->isClaimed())
Diag(clang::diag::warn_drv_unused_argument)
- << A->getOption().getName();
+ << A->getAsString(C.getArgs());
}
}