[cfe-commits] r67015 - in /cfe/trunk: include/clang/Basic/DiagnosticDriverKinds.def include/clang/Driver/Arg.h lib/Driver/Driver.cpp
Daniel Dunbar
daniel at zuster.org
Sat Mar 14 18:38:15 PDT 2009
Author: ddunbar
Date: Sat Mar 14 20:38:15 2009
New Revision: 67015
URL: http://llvm.org/viewvc/llvm-project?rev=67015&view=rev
Log:
Driver: Start warning about unused arguments.
- This has a number of current flaws, enabling now to flush out
problems while bringing up other parts.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.def
cfe/trunk/include/clang/Driver/Arg.h
cfe/trunk/lib/Driver/Driver.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.def?rev=67015&r1=67014&r2=67015&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.def Sat Mar 14 20:38:15 2009
@@ -31,3 +31,5 @@
DIAG(warn_drv_input_file_unused, WARNING,
"%0: '%1' input file unused when '%2' is present")
+DIAG(warn_drv_unused_argument, WARNING,
+ "argument unused during compilatin: '%0'")
Modified: cfe/trunk/include/clang/Driver/Arg.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Arg.h?rev=67015&r1=67014&r2=67015&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Arg.h (original)
+++ cfe/trunk/include/clang/Driver/Arg.h Sat Mar 14 20:38:15 2009
@@ -72,11 +72,7 @@
unsigned getIndex() const { return Index; }
- virtual unsigned getNumValues() const = 0;
- virtual const char *getValue(const ArgList &Args, unsigned N=0) const = 0;
-
- /// render - Append the argument onto the given array as strings.
- virtual void render(const ArgList &Args, ArgStringList &Output) const = 0;
+ bool isClaimed() const { return Claimed; }
/// claim - Set the Arg claimed bit.
@@ -84,6 +80,12 @@
// in the original argument; not the derived one.
void claim() { Claimed = true; }
+ virtual unsigned getNumValues() const = 0;
+ virtual const char *getValue(const ArgList &Args, unsigned N=0) const = 0;
+
+ /// render - Append the argument onto the given array as strings.
+ virtual void render(const ArgList &Args, ArgStringList &Output) const = 0;
+
static bool classof(const Arg *) { return true; }
void dump() const;
Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=67015&r1=67014&r2=67015&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Sat Mar 14 20:38:15 2009
@@ -171,7 +171,21 @@
return 0;
}
- return BuildJobs(*Args, Actions);
+ Compilation *C = BuildJobs(*Args, Actions);
+
+ // If there were no errors, warn about any unused arguments.
+ for (ArgList::iterator it = Args->begin(), ie = Args->end(); it != ie; ++it) {
+ Arg *A = *it;
+
+ // FIXME: It would be nice to be able to send the argument to the
+ // Diagnostic, so that extra values, position, and so on could be
+ // printed.
+ if (!A->isClaimed())
+ Diag(clang::diag::warn_drv_unused_argument)
+ << A->getOption().getName();
+ }
+
+ return C;
}
void Driver::PrintOptions(const ArgList &Args) const {
@@ -563,7 +577,6 @@
Compilation *Driver::BuildJobs(const ArgList &Args,
const ActionList &Actions) const {
- assert(0 && "FIXME: Implement");
return 0;
}
More information about the cfe-commits
mailing list