forked from OSchip/llvm-project
Driver: Add 'q' flag for options which shouldn't be reported as unused.
- <rdar://problem/6756295> warning about '-dynamic' argument unused during compilation seems incorrect llvm-svn: 68535
This commit is contained in:
parent
b01824afb5
commit
a3cfbe33da
|
@ -82,9 +82,12 @@ namespace driver {
|
||||||
/// Always render this option joined with its value.
|
/// Always render this option joined with its value.
|
||||||
bool ForceJoinedRender : 1;
|
bool ForceJoinedRender : 1;
|
||||||
|
|
||||||
/// This option is only for consumed by the driver.
|
/// This option is only consumed by the driver.
|
||||||
bool DriverOption : 1;
|
bool DriverOption : 1;
|
||||||
|
|
||||||
|
/// This option should not report argument unused errors.
|
||||||
|
bool NoArgumentUnused : 1;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Option(OptionClass Kind, options::ID ID, const char *Name,
|
Option(OptionClass Kind, options::ID ID, const char *Name,
|
||||||
const OptionGroup *Group, const Option *Alias);
|
const OptionGroup *Group, const Option *Alias);
|
||||||
|
@ -115,6 +118,9 @@ namespace driver {
|
||||||
bool isDriverOption() const { return DriverOption; }
|
bool isDriverOption() const { return DriverOption; }
|
||||||
void setDriverOption(bool Value) { DriverOption = Value; }
|
void setDriverOption(bool Value) { DriverOption = Value; }
|
||||||
|
|
||||||
|
bool hasNoArgumentUnused() const { return NoArgumentUnused; }
|
||||||
|
void setNoArgumentUnused(bool Value) { NoArgumentUnused = Value; }
|
||||||
|
|
||||||
bool hasForwardToGCC() const { return !DriverOption && !LinkerInput; }
|
bool hasForwardToGCC() const { return !DriverOption && !LinkerInput; }
|
||||||
|
|
||||||
/// getUnaliasedOption - Return the final option this option
|
/// getUnaliasedOption - Return the final option this option
|
||||||
|
|
|
@ -57,6 +57,11 @@
|
||||||
//
|
//
|
||||||
// l: The option is a linker input.
|
// 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
|
// u: The option is unsupported, and the driver will reject command
|
||||||
// lines that use it.
|
// 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_install_name", dylinker__install__name, JoinedOrSeparate, INVALID, INVALID, "", 0, 0, 0)
|
||||||
OPTION("-dylinker", dylinker, Flag, INVALID, INVALID, "", 0, 0, 0)
|
OPTION("-dylinker", dylinker, Flag, INVALID, INVALID, "", 0, 0, 0)
|
||||||
OPTION("-dynamiclib", dynamiclib, 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_Flag, Flag, d_Group, INVALID, "", 0, 0, 0)
|
||||||
OPTION("-d", d_Joined, Joined, 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,
|
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("-m3dnow", m3dnow, Flag, m_Group, INVALID, "", 0, 0, 0)
|
||||||
OPTION("-m64", m64, 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("-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("-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("-miphoneos-version-min=", miphoneos_version_min_EQ, Joined, m_Group, INVALID, "", 0, 0, 0)
|
||||||
OPTION("-mkernel", mkernel, Flag, 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_EQ, Joined, INVALID, INVALID, "", 0, 0, 0)
|
||||||
OPTION("-specs", specs, Separate, INVALID, INVALID, "u", 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-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("-std=", std_EQ, Joined, INVALID, INVALID, "", 0, 0, 0)
|
||||||
OPTION("-sub_library", sub__library, JoinedOrSeparate, 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)
|
OPTION("-sub_umbrella", sub__umbrella, JoinedOrSeparate, INVALID, INVALID, "", 0, 0, 0)
|
||||||
|
|
|
@ -802,7 +802,8 @@ void Driver::BuildJobs(Compilation &C) const {
|
||||||
|
|
||||||
// If the user passed -Qunused-arguments or there were errors, don't
|
// If the user passed -Qunused-arguments or there were errors, don't
|
||||||
// warn about any unused arguments.
|
// 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;
|
return;
|
||||||
|
|
||||||
// Claim -### here.
|
// Claim -### here.
|
||||||
|
@ -816,6 +817,9 @@ void Driver::BuildJobs(Compilation &C) const {
|
||||||
// Diagnostic, so that extra values, position, and so on could be
|
// Diagnostic, so that extra values, position, and so on could be
|
||||||
// printed.
|
// printed.
|
||||||
if (!A->isClaimed()) {
|
if (!A->isClaimed()) {
|
||||||
|
if (A->getOption().hasNoArgumentUnused())
|
||||||
|
continue;
|
||||||
|
|
||||||
// Suppress the warning automatically if this is just a flag,
|
// Suppress the warning automatically if this is just a flag,
|
||||||
// and it is an instance of an argument we already claimed.
|
// and it is an instance of an argument we already claimed.
|
||||||
const Option &Opt = A->getOption();
|
const Option &Opt = A->getOption();
|
||||||
|
|
|
@ -204,6 +204,7 @@ Option *OptTable::constructOption(options::ID id) const {
|
||||||
case 'd': Opt->setDriverOption(true); break;
|
case 'd': Opt->setDriverOption(true); break;
|
||||||
case 'i': Opt->setNoOptAsInput(true); break;
|
case 'i': Opt->setNoOptAsInput(true); break;
|
||||||
case 'l': Opt->setLinkerInput(true); break;
|
case 'l': Opt->setLinkerInput(true); break;
|
||||||
|
case 'q': Opt->setNoArgumentUnused(true); break;
|
||||||
case 'u': Opt->setUnsupported(true); break;
|
case 'u': Opt->setUnsupported(true); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ Option::Option(OptionClass _Kind, options::ID _ID, const char *_Name,
|
||||||
: Kind(_Kind), ID(_ID), Name(_Name), Group(_Group), Alias(_Alias),
|
: Kind(_Kind), ID(_ID), Name(_Name), Group(_Group), Alias(_Alias),
|
||||||
Unsupported(false), LinkerInput(false), NoOptAsInput(false),
|
Unsupported(false), LinkerInput(false), NoOptAsInput(false),
|
||||||
ForceSeparateRender(false), ForceJoinedRender(false),
|
ForceSeparateRender(false), ForceJoinedRender(false),
|
||||||
DriverOption(false)
|
DriverOption(false), NoArgumentUnused(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Multi-level aliases are not supported, and alias options cannot
|
// Multi-level aliases are not supported, and alias options cannot
|
||||||
|
|
Loading…
Reference in New Issue