aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Driver/Option.h8
-rw-r--r--include/clang/Driver/Options.def11
-rw-r--r--lib/Driver/Driver.cpp6
-rw-r--r--lib/Driver/OptTable.cpp1
-rw-r--r--lib/Driver/Option.cpp2
5 files changed, 22 insertions, 6 deletions
diff --git a/include/clang/Driver/Option.h b/include/clang/Driver/Option.h
index c7b6d0e08c..c59faef897 100644
--- a/include/clang/Driver/Option.h
+++ b/include/clang/Driver/Option.h
@@ -82,9 +82,12 @@ namespace driver {
/// Always render this option joined with its value.
bool ForceJoinedRender : 1;
- /// This option is only for consumed by the driver.
+ /// This option is only consumed by the driver.
bool DriverOption : 1;
+ /// This option should not report argument unused errors.
+ bool NoArgumentUnused : 1;
+
protected:
Option(OptionClass Kind, options::ID ID, const char *Name,
const OptionGroup *Group, const Option *Alias);
@@ -115,6 +118,9 @@ namespace driver {
bool isDriverOption() const { return DriverOption; }
void setDriverOption(bool Value) { DriverOption = Value; }
+ bool hasNoArgumentUnused() const { return NoArgumentUnused; }
+ void setNoArgumentUnused(bool Value) { NoArgumentUnused = Value; }
+
bool hasForwardToGCC() const { return !DriverOption && !LinkerInput; }
/// getUnaliasedOption - Return the final option this option
diff --git a/include/clang/Driver/Options.def b/include/clang/Driver/Options.def
index b8591815b4..7e77a1a51c 100644
--- a/include/clang/Driver/Options.def
+++ b/include/clang/Driver/Options.def
@@ -57,6 +57,11 @@
//
// l: The option is a linker input.
//
+// q: Don't report argument unused warnings for this option; this is
+// useful for options like -static or -dynamic which a user may
+// always end up passing, even if the platform defaults to (or
+// only supports) that option.
+//
// u: The option is unsupported, and the driver will reject command
// lines that use it.
//
@@ -405,7 +410,7 @@ OPTION("-dylib_file", dylib__file, Separate, INVALID, INVALID, "", 0, 0, 0)
OPTION("-dylinker_install_name", dylinker__install__name, JoinedOrSeparate, INVALID, INVALID, "", 0, 0, 0)
OPTION("-dylinker", dylinker, Flag, INVALID, INVALID, "", 0, 0, 0)
OPTION("-dynamiclib", dynamiclib, Flag, INVALID, INVALID, "", 0, 0, 0)
-OPTION("-dynamic", dynamic, Flag, INVALID, INVALID, "", 0, 0, 0)
+OPTION("-dynamic", dynamic, Flag, INVALID, INVALID, "q", 0, 0, 0)
OPTION("-d", d_Flag, Flag, d_Group, INVALID, "", 0, 0, 0)
OPTION("-d", d_Joined, Joined, d_Group, INVALID, "", 0, 0, 0)
OPTION("-emit-llvm", emit_llvm, Flag, INVALID, INVALID, "", 0,
@@ -534,7 +539,7 @@ OPTION("-m3dnowa", m3dnowa, Flag, m_Group, INVALID, "", 0, 0, 0)
OPTION("-m3dnow", m3dnow, Flag, m_Group, INVALID, "", 0, 0, 0)
OPTION("-m64", m64, Flag, m_Group, INVALID, "", 0, 0, 0)
OPTION("-mconstant-cfstrings", mconstant_cfstrings, Flag, clang_ignored_m_Group, INVALID, "", 0, 0, 0)
-OPTION("-mdynamic-no-pic", mdynamic_no_pic, Joined, m_Group, INVALID, "", 0, 0, 0)
+OPTION("-mdynamic-no-pic", mdynamic_no_pic, Joined, m_Group, INVALID, "q", 0, 0, 0)
OPTION("-mfix-and-continue", mfix_and_continue, Flag, clang_ignored_m_Group, INVALID, "", 0, 0, 0)
OPTION("-miphoneos-version-min=", miphoneos_version_min_EQ, Joined, m_Group, INVALID, "", 0, 0, 0)
OPTION("-mkernel", mkernel, Flag, m_Group, INVALID, "", 0, 0, 0)
@@ -636,7 +641,7 @@ OPTION("-single_module", single__module, Flag, INVALID, INVALID, "", 0, 0, 0)
OPTION("-specs=", specs_EQ, Joined, INVALID, INVALID, "", 0, 0, 0)
OPTION("-specs", specs, Separate, INVALID, INVALID, "u", 0, 0, 0)
OPTION("-static-libgcc", static_libgcc, Flag, INVALID, INVALID, "", 0, 0, 0)
-OPTION("-static", static, Flag, INVALID, INVALID, "", 0, 0, 0)
+OPTION("-static", static, Flag, INVALID, INVALID, "q", 0, 0, 0)
OPTION("-std=", std_EQ, Joined, INVALID, INVALID, "", 0, 0, 0)
OPTION("-sub_library", sub__library, JoinedOrSeparate, INVALID, INVALID, "", 0, 0, 0)
OPTION("-sub_umbrella", sub__umbrella, JoinedOrSeparate, INVALID, INVALID, "", 0, 0, 0)
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index 68ff8bc8b0..f9a82ff78d 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -802,7 +802,8 @@ void Driver::BuildJobs(Compilation &C) const {
// If the user passed -Qunused-arguments or there were errors, don't
// warn about any unused arguments.
- if (Diags.getNumErrors() || C.getArgs().hasArg(options::OPT_Qunused_arguments))
+ if (Diags.getNumErrors() ||
+ C.getArgs().hasArg(options::OPT_Qunused_arguments))
return;
// Claim -### here.
@@ -816,6 +817,9 @@ void Driver::BuildJobs(Compilation &C) const {
// Diagnostic, so that extra values, position, and so on could be
// printed.
if (!A->isClaimed()) {
+ if (A->getOption().hasNoArgumentUnused())
+ continue;
+
// Suppress the warning automatically if this is just a flag,
// and it is an instance of an argument we already claimed.
const Option &Opt = A->getOption();
diff --git a/lib/Driver/OptTable.cpp b/lib/Driver/OptTable.cpp
index cbbeea1974..7ea6a8b0d9 100644
--- a/lib/Driver/OptTable.cpp
+++ b/lib/Driver/OptTable.cpp
@@ -204,6 +204,7 @@ Option *OptTable::constructOption(options::ID id) const {
case 'd': Opt->setDriverOption(true); break;
case 'i': Opt->setNoOptAsInput(true); break;
case 'l': Opt->setLinkerInput(true); break;
+ case 'q': Opt->setNoArgumentUnused(true); break;
case 'u': Opt->setUnsupported(true); break;
}
}
diff --git a/lib/Driver/Option.cpp b/lib/Driver/Option.cpp
index 624854815d..cad2bbf2b7 100644
--- a/lib/Driver/Option.cpp
+++ b/lib/Driver/Option.cpp
@@ -21,7 +21,7 @@ Option::Option(OptionClass _Kind, options::ID _ID, const char *_Name,
: Kind(_Kind), ID(_ID), Name(_Name), Group(_Group), Alias(_Alias),
Unsupported(false), LinkerInput(false), NoOptAsInput(false),
ForceSeparateRender(false), ForceJoinedRender(false),
- DriverOption(false)
+ DriverOption(false), NoArgumentUnused(false)
{
// Multi-level aliases are not supported, and alias options cannot