summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-03-20 06:14:23 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-03-20 06:14:23 +0000
commit0e75994e8bfd5fe8fee2ef0ad2a34aabceb27bab (patch)
tree9da9ccfbf5f66d0d5c60931c7c5e394f5ed35040 /clang/lib/Driver
parent03b886e301736a9df2ae08ce6e43f1811a25fa6f (diff)
downloadbcm5719-llvm-0e75994e8bfd5fe8fee2ef0ad2a34aabceb27bab.tar.gz
bcm5719-llvm-0e75994e8bfd5fe8fee2ef0ad2a34aabceb27bab.zip
Driver: Add Arg::getAsString and use when dumping arguments to
diagnostics. - This ensures that the whole argument and values are printed, instead of just the option name. llvm-svn: 67366
Diffstat (limited to 'clang/lib/Driver')
-rw-r--r--clang/lib/Driver/Arg.cpp16
-rw-r--r--clang/lib/Driver/Driver.cpp12
2 files changed, 22 insertions, 6 deletions
diff --git a/clang/lib/Driver/Arg.cpp b/clang/lib/Driver/Arg.cpp
index eba39dd4f48..c43c9fbe4b1 100644
--- a/clang/lib/Driver/Arg.cpp
+++ b/clang/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/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 2ae88267b0e..2c324010dac 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/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());
}
}
OpenPOWER on IntegriCloud