[cfe-commits] r67366 - in /cfe/trunk: include/clang/Driver/Arg.h lib/Driver/Arg.cpp lib/Driver/Driver.cpp
Daniel Dunbar
daniel at zuster.org
Thu Mar 19 23:14:28 PDT 2009
Author: ddunbar
Date: Fri Mar 20 01:14:23 2009
New Revision: 67366
URL: http://llvm.org/viewvc/llvm-project?rev=67366&view=rev
Log:
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.
Modified:
cfe/trunk/include/clang/Driver/Arg.h
cfe/trunk/lib/Driver/Arg.cpp
cfe/trunk/lib/Driver/Driver.cpp
Modified: cfe/trunk/include/clang/Driver/Arg.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Arg.h?rev=67366&r1=67365&r2=67366&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Arg.h (original)
+++ cfe/trunk/include/clang/Driver/Arg.h Fri Mar 20 01:14:23 2009
@@ -95,6 +95,10 @@
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.
Modified: cfe/trunk/lib/Driver/Arg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Arg.cpp?rev=67366&r1=67365&r2=67366&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Arg.cpp (original)
+++ cfe/trunk/lib/Driver/Arg.cpp Fri Mar 20 01:14:23 2009
@@ -50,6 +50,22 @@
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);
Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=67366&r1=67365&r2=67366&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Mar 20 01:14:23 2009
@@ -75,7 +75,7 @@
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 @@
// 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 @@
// 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 @@
// 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 @@
// printed.
if (!A->isClaimed())
Diag(clang::diag::warn_drv_unused_argument)
- << A->getOption().getName();
+ << A->getAsString(C.getArgs());
}
}
More information about the cfe-commits
mailing list