aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Driver/Arg.h4
-rw-r--r--lib/Driver/Arg.cpp16
-rw-r--r--lib/Driver/Driver.cpp12
3 files changed, 26 insertions, 6 deletions
diff --git a/include/clang/Driver/Arg.h b/include/clang/Driver/Arg.h
index 30bb56ad77..a9e34d20c8 100644
--- a/include/clang/Driver/Arg.h
+++ b/include/clang/Driver/Arg.h
@@ -95,6 +95,10 @@ namespace driver {
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.
diff --git a/lib/Driver/Arg.cpp b/lib/Driver/Arg.cpp
index eba39dd4f4..c43c9fbe4b 100644
--- a/lib/Driver/Arg.cpp
+++ b/lib/Driver/Arg.cpp
@@ -50,6 +50,22 @@ void Arg::dump() const {
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);
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index 2ae88267b0..2c324010da 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -75,7 +75,7 @@ ArgList *Driver::ParseArgStrings(const char **ArgBegin, const char **ArgEnd) {
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;
}
@@ -368,10 +368,10 @@ void Driver::BuildUniversalActions(const ArgList &Args,
// 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;
@@ -534,7 +534,7 @@ void Driver::BuildActions(const ArgList &Args, ActionList &Actions) const {
// 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;
@@ -552,7 +552,7 @@ void Driver::BuildActions(const ArgList &Args, ActionList &Actions) const {
// 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;
@@ -699,7 +699,7 @@ void Driver::BuildJobs(Compilation &C) const {
// printed.
if (!A->isClaimed())
Diag(clang::diag::warn_drv_unused_argument)
- << A->getOption().getName();
+ << A->getAsString(C.getArgs());
}
}