[cfe-commits] r130066 - in /cfe/trunk: include/clang/Basic/LangOptions.h include/clang/Driver/CC1Options.td lib/Driver/Tools.cpp lib/Frontend/CompilerInvocation.cpp lib/Frontend/InitPreprocessor.cpp test/Driver/clang_f_opts.c test/Preprocessor/init.c
Chandler Carruth
chandlerc at gmail.com
Sat Apr 23 12:48:40 PDT 2011
Author: chandlerc
Date: Sat Apr 23 14:48:40 2011
New Revision: 130066
URL: http://llvm.org/viewvc/llvm-project?rev=130066&view=rev
Log:
Move all of the logic for __DEPRECATED to the driver based on comments
from dgregor.
Modified:
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Driver/clang_f_opts.c
cfe/trunk/test/Preprocessor/init.c
Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=130066&r1=130065&r2=130066&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Sat Apr 23 14:48:40 2011
@@ -215,7 +215,7 @@
GNUInline = 0;
NoInline = 0;
- Deprecated = 1; // -Wdeprecated defaults to "on".
+ Deprecated = 0;
CharIsSigned = 1;
ShortWChar = 0;
Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=130066&r1=130065&r2=130066&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Sat Apr 23 14:48:40 2011
@@ -540,9 +540,9 @@
def funknown_anytype : Flag<"-funknown-anytype">,
HelpText<"Enable parser support for the __unknown_anytype type; for testing purposes only">;
def fdeprecated_macro : Flag<"-fdeprecated-macro">,
- HelpText<"Defines the __DEPRECATED macro in C++ compilations">;
+ HelpText<"Defines the __DEPRECATED macro">;
def fno_deprecated_macro : Flag<"-fno-deprecated-macro">,
- HelpText<"Undefines the __DEPRECATED macro in C++ compilations">;
+ HelpText<"Undefines the __DEPRECATED macro">;
//===----------------------------------------------------------------------===//
// Header Search Options
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=130066&r1=130065&r2=130066&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Sat Apr 23 14:48:40 2011
@@ -1363,14 +1363,12 @@
}
// 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");
+ // during C++ compilation, which it is by default. GCC keeps this define even
+ // in the presence of '-w', match this behavior bug-for-bug.
+ if (types::isCXX(InputType) &&
+ Args.hasFlag(options::OPT_Wdeprecated, options::OPT_Wno_deprecated,
+ true)) {
+ CmdArgs.push_back("-fdeprecated-macro");
}
// Translate GCC's misnamer '-fasm' arguments to '-fgnu-keywords'.
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=130066&r1=130065&r2=130066&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Sat Apr 23 14:48:40 2011
@@ -694,8 +694,8 @@
Res.push_back("-funknown-anytype");
if (Opts.DelayedTemplateParsing)
Res.push_back("-fdelayed-template-parsing");
- if (!Opts.Deprecated)
- Res.push_back("-fno-deprecated-macro");
+ if (Opts.Deprecated)
+ Res.push_back("-fdeprecated-macro");
}
static void PreprocessorOptsToArgs(const PreprocessorOptions &Opts,
Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=130066&r1=130065&r2=130066&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Sat Apr 23 14:48:40 2011
@@ -318,9 +318,10 @@
if (LangOpts.SjLjExceptions)
Builder.defineMacro("__USING_SJLJ_EXCEPTIONS__");
+ if (LangOpts.Deprecated)
+ Builder.defineMacro("__DEPRECATED");
+
if (LangOpts.CPlusPlus) {
- if (LangOpts.Deprecated)
- Builder.defineMacro("__DEPRECATED");
Builder.defineMacro("__GNUG__", "4");
Builder.defineMacro("__GXX_WEAK__");
if (LangOpts.GNUMode)
Modified: cfe/trunk/test/Driver/clang_f_opts.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang_f_opts.c?rev=130066&r1=130065&r2=130066&view=diff
==============================================================================
--- cfe/trunk/test/Driver/clang_f_opts.c (original)
+++ cfe/trunk/test/Driver/clang_f_opts.c Sat Apr 23 14:48:40 2011
@@ -20,10 +20,12 @@
// RUN: %clang -### -S -Wwrite-strings -w %s 2>&1 | FileCheck -check-prefix=WRITE-STRINGS3 %s
// WRITE-STRINGS3: -fconst-strings
-// RUN: %clang -### -c %s 2>&1 | FileCheck -check-prefix=DEPRECATED-ON-CHECK %s
-// RUN: %clang -### -c -Wdeprecated %s 2>&1 | FileCheck -check-prefix=DEPRECATED-ON-CHECK %s
-// RUN: %clang -### -c -Wno-deprecated %s 2>&1 | FileCheck -check-prefix=DEPRECATED-OFF-CHECK %s
-// RUN: %clang -### -c -Wno-deprecated -Wdeprecated %s 2>&1 | FileCheck -check-prefix=DEPRECATED-ON-CHECK %s
-// RUN: %clang -### -c -w %s 2>&1 | FileCheck -check-prefix=DEPRECATED-ON-CHECK %s
-// DEPRECATED-OFF-CHECK: -fno-deprecated-macro
-// DEPRECATED-ON-CHECK-NOT: -fno-deprecated-macro
+// RUN: %clang -### -x c++ -c %s 2>&1 | FileCheck -check-prefix=DEPRECATED-ON-CHECK %s
+// RUN: %clang -### -x c++ -c -Wdeprecated %s 2>&1 | FileCheck -check-prefix=DEPRECATED-ON-CHECK %s
+// RUN: %clang -### -x c++ -c -Wno-deprecated %s 2>&1 | FileCheck -check-prefix=DEPRECATED-OFF-CHECK %s
+// RUN: %clang -### -x c++ -c -Wno-deprecated -Wdeprecated %s 2>&1 | FileCheck -check-prefix=DEPRECATED-ON-CHECK %s
+// RUN: %clang -### -x c++ -c -w %s 2>&1 | FileCheck -check-prefix=DEPRECATED-ON-CHECK %s
+// RUN: %clang -### -c %s 2>&1 | FileCheck -check-prefix=DEPRECATED-OFF-CHECK %s
+// RUN: %clang -### -c -Wdeprecated %s 2>&1 | FileCheck -check-prefix=DEPRECATED-OFF-CHECK %s
+// DEPRECATED-ON-CHECK: -fdeprecated-macro
+// DEPRECATED-OFF-CHECK-NOT: -fdeprecated-macro
Modified: cfe/trunk/test/Preprocessor/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=130066&r1=130065&r2=130066&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Sat Apr 23 14:48:40 2011
@@ -11,7 +11,6 @@
//
// RUN: %clang_cc1 -x c++ -std=c++0x -E -dM < /dev/null | FileCheck -check-prefix CXX0X %s
//
-// CXX0X:#define __DEPRECATED 1
// CXX0X:#define __GNUG__
// CXX0X:#define __GXX_EXPERIMENTAL_CXX0X__ 1
// CXX0X:#define __GXX_RTTI 1
@@ -22,7 +21,6 @@
//
// RUN: %clang_cc1 -x c++ -std=c++98 -E -dM < /dev/null | FileCheck -check-prefix CXX98 %s
//
-// CXX98:#define __DEPRECATED 1
// CXX98:#define __GNUG__
// CXX98:#define __GXX_RTTI 1
// CXX98:#define __GXX_WEAK__ 1
@@ -30,6 +28,11 @@
// CXX98:#define __private_extern__ extern
//
//
+// RUN: %clang_cc1 -fdeprecated-macro -E -dM < /dev/null | FileCheck -check-prefix DEPRECATED %s
+//
+// DEPRECATED:#define __DEPRECATED 1
+//
+//
// RUN: %clang_cc1 -std=c99 -E -dM < /dev/null | FileCheck -check-prefix C99 %s
//
// C99:#define __STDC_VERSION__ 199901L
@@ -62,7 +65,6 @@
//
// RUN: %clang_cc1 -x c++ -std=gnu++98 -E -dM < /dev/null | FileCheck -check-prefix GXX98 %s
//
-// GXX98:#define __DEPRECATED 1
// GXX98:#define __GNUG__
// GXX98:#define __GXX_WEAK__ 1
// GXX98:#define __cplusplus 1
More information about the cfe-commits
mailing list