r212753 - Avoid definining more GCC specific predefined macros in clang-cl
Ehsan Akhgari
ehsan.akhgari at gmail.com
Thu Jul 10 11:44:24 PDT 2014
Author: ehsan
Date: Thu Jul 10 13:44:24 2014
New Revision: 212753
URL: http://llvm.org/viewvc/llvm-project?rev=212753&view=rev
Log:
Avoid definining more GCC specific predefined macros in clang-cl
Reviewers: hansw, rnk
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D4419
Modified:
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Preprocessor/predefined-macros.c
Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=212753&r1=212752&r2=212753&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Thu Jul 10 13:44:24 2014
@@ -481,7 +481,7 @@ static void InitializePredefinedMacros(c
if (!LangOpts.GNUMode && !LangOpts.MSVCCompat)
Builder.defineMacro("__STRICT_ANSI__");
- if (LangOpts.CPlusPlus11)
+ if (!LangOpts.MSVCCompat && LangOpts.CPlusPlus11)
Builder.defineMacro("__GXX_EXPERIMENTAL_CXX0X__");
if (LangOpts.ObjC1) {
@@ -541,7 +541,7 @@ static void InitializePredefinedMacros(c
if (!LangOpts.MSVCCompat && LangOpts.CXXExceptions)
Builder.defineMacro("__EXCEPTIONS");
- if (LangOpts.RTTI)
+ if (!LangOpts.MSVCCompat && LangOpts.RTTI)
Builder.defineMacro("__GXX_RTTI");
if (LangOpts.SjLjExceptions)
Builder.defineMacro("__USING_SJLJ_EXCEPTIONS__");
@@ -549,7 +549,7 @@ static void InitializePredefinedMacros(c
if (LangOpts.Deprecated)
Builder.defineMacro("__DEPRECATED");
- if (LangOpts.CPlusPlus) {
+ if (!LangOpts.MSVCCompat && LangOpts.CPlusPlus) {
Builder.defineMacro("__GNUG__", "4");
Builder.defineMacro("__GXX_WEAK__");
Builder.defineMacro("__private_extern__", "extern");
@@ -746,36 +746,38 @@ static void InitializePredefinedMacros(c
else
Builder.defineMacro("__FINITE_MATH_ONLY__", "0");
- if (LangOpts.GNUInline)
- Builder.defineMacro("__GNUC_GNU_INLINE__");
- else
- Builder.defineMacro("__GNUC_STDC_INLINE__");
-
- // The value written by __atomic_test_and_set.
- // FIXME: This is target-dependent.
- Builder.defineMacro("__GCC_ATOMIC_TEST_AND_SET_TRUEVAL", "1");
+ if (!LangOpts.MSVCCompat) {
+ if (LangOpts.GNUInline)
+ Builder.defineMacro("__GNUC_GNU_INLINE__");
+ else
+ Builder.defineMacro("__GNUC_STDC_INLINE__");
+
+ // The value written by __atomic_test_and_set.
+ // FIXME: This is target-dependent.
+ Builder.defineMacro("__GCC_ATOMIC_TEST_AND_SET_TRUEVAL", "1");
- // Used by libstdc++ to implement ATOMIC_<foo>_LOCK_FREE.
- unsigned InlineWidthBits = TI.getMaxAtomicInlineWidth();
+ // Used by libstdc++ to implement ATOMIC_<foo>_LOCK_FREE.
+ unsigned InlineWidthBits = TI.getMaxAtomicInlineWidth();
#define DEFINE_LOCK_FREE_MACRO(TYPE, Type) \
- Builder.defineMacro("__GCC_ATOMIC_" #TYPE "_LOCK_FREE", \
- getLockFreeValue(TI.get##Type##Width(), \
- TI.get##Type##Align(), \
- InlineWidthBits));
- DEFINE_LOCK_FREE_MACRO(BOOL, Bool);
- DEFINE_LOCK_FREE_MACRO(CHAR, Char);
- DEFINE_LOCK_FREE_MACRO(CHAR16_T, Char16);
- DEFINE_LOCK_FREE_MACRO(CHAR32_T, Char32);
- DEFINE_LOCK_FREE_MACRO(WCHAR_T, WChar);
- DEFINE_LOCK_FREE_MACRO(SHORT, Short);
- DEFINE_LOCK_FREE_MACRO(INT, Int);
- DEFINE_LOCK_FREE_MACRO(LONG, Long);
- DEFINE_LOCK_FREE_MACRO(LLONG, LongLong);
- Builder.defineMacro("__GCC_ATOMIC_POINTER_LOCK_FREE",
- getLockFreeValue(TI.getPointerWidth(0),
- TI.getPointerAlign(0),
- InlineWidthBits));
+ Builder.defineMacro("__GCC_ATOMIC_" #TYPE "_LOCK_FREE", \
+ getLockFreeValue(TI.get##Type##Width(), \
+ TI.get##Type##Align(), \
+ InlineWidthBits));
+ DEFINE_LOCK_FREE_MACRO(BOOL, Bool);
+ DEFINE_LOCK_FREE_MACRO(CHAR, Char);
+ DEFINE_LOCK_FREE_MACRO(CHAR16_T, Char16);
+ DEFINE_LOCK_FREE_MACRO(CHAR32_T, Char32);
+ DEFINE_LOCK_FREE_MACRO(WCHAR_T, WChar);
+ DEFINE_LOCK_FREE_MACRO(SHORT, Short);
+ DEFINE_LOCK_FREE_MACRO(INT, Int);
+ DEFINE_LOCK_FREE_MACRO(LONG, Long);
+ DEFINE_LOCK_FREE_MACRO(LLONG, LongLong);
+ Builder.defineMacro("__GCC_ATOMIC_POINTER_LOCK_FREE",
+ getLockFreeValue(TI.getPointerWidth(0),
+ TI.getPointerAlign(0),
+ InlineWidthBits));
#undef DEFINE_LOCK_FREE_MACRO
+ }
if (LangOpts.NoInlineDefine)
Builder.defineMacro("__NO_INLINE__");
Modified: cfe/trunk/test/Preprocessor/predefined-macros.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-macros.c?rev=212753&r1=212752&r2=212753&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/predefined-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-macros.c Thu Jul 10 13:44:24 2014
@@ -8,8 +8,23 @@
// CHECK-MS: #define _M_IX86 600
// CHECK-MS: #define _M_IX86_FP
// CHECK-MS: #define _WIN32 1
-// CHECK-MS-NOT: #define __GNUC__
// CHECK-MS-NOT: #define __STRICT_ANSI__
+// CHECK-MS-NOT: GCC
+// CHECK-MS-NOT: GNU
+// CHECK-MS-NOT: GXX
+//
+// RUN: %clang_cc1 %s -E -dM -triple x86_64-pc-win32 -fms-extensions -fms-compatibility \
+// RUN: -fmsc-version=1300 -o - | FileCheck %s --check-prefix=CHECK-MS64
+// CHECK-MS64: #define _INTEGRAL_MAX_BITS 64
+// CHECK-MS64: #define _MSC_EXTENSIONS 1
+// CHECK-MS64: #define _MSC_VER 1300
+// CHECK-MS64: #define _M_AMD64 1
+// CHECK-MS64: #define _M_X64 1
+// CHECK-MS64: #define _WIN64 1
+// CHECK-MS64-NOT: #define __STRICT_ANSI__
+// CHECK-MS64-NOT: GCC
+// CHECK-MS64-NOT: GNU
+// CHECK-MS64-NOT: GXX
//
// RUN: %clang_cc1 %s -E -dM -triple i686-pc-win32 -fms-compatibility \
// RUN: -o - | FileCheck %s --check-prefix=CHECK-MS-STDINT
More information about the cfe-commits
mailing list