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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68535 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2009-04-07 19:04:18 +00:00
Родитель 235c5ed8be
Коммит 1e23f5f963
5 изменённых файлов: 22 добавлений и 6 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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)

Просмотреть файл

@ -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();

Просмотреть файл

@ -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;
}
}

Просмотреть файл

@ -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