Fix Clang's __DEPRECATED define to be controled by -Wdeprecated. This

matches GCC behavior which libstdc++ uses to limit #warning-based
messages about deprecation.

The machinery involves threading this through a new '-fdeprecated-macro'
flag for CC1. The flag defaults to "on", similarly to -Wdeprecated. We
turn the flag off in the driver when the warning is turned off (modulo
matching some GCC bugs). We record this as a language option, and key
the preprocessor on the option when introducing the define.

A separate flag rather than a '-D' flag allows us to properly represent
the difference between C and C++ builds (only C++ receives the define),
and it allows the specific behavior of following -Wdeprecated without
potentially impacting the set of user-provided macro flags.

llvm-svn: 130055
This commit is contained in:
Chandler Carruth
2011-04-23 09:27:53 +00:00
parent 72e705ed94
commit 61fbf62838
7 changed files with 38 additions and 1 deletions

View File

@@ -694,6 +694,8 @@ static void LangOptsToArgs(const LangOptions &Opts,
Res.push_back("-funknown-anytype");
if (Opts.DelayedTemplateParsing)
Res.push_back("-fdelayed-template-parsing");
if (!Opts.Deprecated)
Res.push_back("-fno-deprecated-macro");
}
static void PreprocessorOptsToArgs(const PreprocessorOptions &Opts,
@@ -1528,6 +1530,11 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
Opts.FakeAddressSpaceMap = Args.hasArg(OPT_ffake_address_space_map);
Opts.ParseUnknownAnytype = Args.hasArg(OPT_funknown_anytype);
// Record whether the __DEPRECATED define was requested.
Opts.Deprecated = Args.hasFlag(OPT_fdeprecated_macro,
OPT_fno_deprecated_macro,
Opts.Deprecated);
// FIXME: Eliminate this dependency.
unsigned Opt = getOptimizationLevel(Args, IK, Diags);
Opts.Optimize = Opt != 0;