summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/Tools.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-04-23 09:27:53 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-04-23 09:27:53 +0000
commit61fbf6283816f4d9b8539cdc17bc147ed596281e (patch)
tree3fe3d67bacee831737dab3065a0736e32ff5230d /clang/lib/Driver/Tools.cpp
parent72e705ed942beed43ef6d00109a215baa2d3cd7d (diff)
downloadbcm5719-llvm-61fbf6283816f4d9b8539cdc17bc147ed596281e.tar.gz
bcm5719-llvm-61fbf6283816f4d9b8539cdc17bc147ed596281e.zip
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
Diffstat (limited to 'clang/lib/Driver/Tools.cpp')
-rw-r--r--clang/lib/Driver/Tools.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index 436a2a42a42..f5dacfa6cfa 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -1362,6 +1362,17 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-fconst-strings");
}
+ // GCC provides a macro definition '__DEPRECATED' when -Wdeprecated is active
+ // during C++ compilation. CC1 uses '-fdeprecated-macro' to control this.
+ // Both '-Wdeprecated' and '-fdeprecated-macro' default to on, so the flag
+ // logic here is inverted.
+ if (Args.hasFlag(options::OPT_Wno_deprecated, options::OPT_Wdeprecated,
+ false)) {
+ // GCC keeps this define even in the presence of '-w', match this behavior
+ // bug-for-bug.
+ CmdArgs.push_back("-fno-deprecated-macro");
+ }
+
// Translate GCC's misnamer '-fasm' arguments to '-fgnu-keywords'.
if (Arg *Asm = Args.getLastArg(options::OPT_fasm, options::OPT_fno_asm)) {
if (Asm->getOption().matches(options::OPT_fasm))
OpenPOWER on IntegriCloud