aidengrossman updated this revision to Diff 550529. aidengrossman added a comment.
Hoist _MSC_EXTENSIONS macro logic even further and add release note on chages. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D157334/new/ https://reviews.llvm.org/D157334 Files: clang/docs/ReleaseNotes.rst clang/lib/Basic/Targets/OSTargets.cpp clang/lib/Frontend/InitPreprocessor.cpp clang/test/Preprocessor/predefined-win-macros.c Index: clang/test/Preprocessor/predefined-win-macros.c =================================================================== --- clang/test/Preprocessor/predefined-win-macros.c +++ clang/test/Preprocessor/predefined-win-macros.c @@ -120,6 +120,11 @@ // CHECK-AMD64-MINGW: #define _WIN32 1 // CHECK-AMD64-MINGW: #define _WIN64 1 +// RUN: %clang_cc1 -triple x86_64-windows-gnu %s -E -dM -o - -fms-extensions \ +// RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-AMD64-MINGW-MSE + +// CHECK-AMD64-MINGW-MSE: #define _MSC_EXTENSIONS 1 + // RUN: %clang_cc1 -triple aarch64-windows-gnu %s -E -dM -o - \ // RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM64-MINGW Index: clang/lib/Frontend/InitPreprocessor.cpp =================================================================== --- clang/lib/Frontend/InitPreprocessor.cpp +++ clang/lib/Frontend/InitPreprocessor.cpp @@ -926,11 +926,19 @@ Builder.defineMacro("__private_extern__", "extern"); if (LangOpts.MicrosoftExt) { + Builder.defineMacro("_MSC_EXTENSIONS"); + if (LangOpts.WChar) { // wchar_t supported as a keyword. Builder.defineMacro("_WCHAR_T_DEFINED"); Builder.defineMacro("_NATIVE_WCHAR_T_DEFINED"); } + + if (LangOpts.CPlusPlus11) { + Builder.defineMacro("_RVALUE_REFERENCES_V2_SUPPORTED"); + Builder.defineMacro("_RVALUE_REFERENCES_SUPPORTED"); + Builder.defineMacro("_NATIVE_NULLPTR_SUPPORTED"); + } } // Macros to help identify the narrow and wide character sets Index: clang/lib/Basic/Targets/OSTargets.cpp =================================================================== --- clang/lib/Basic/Targets/OSTargets.cpp +++ clang/lib/Basic/Targets/OSTargets.cpp @@ -226,16 +226,6 @@ } } - if (Opts.MicrosoftExt) { - Builder.defineMacro("_MSC_EXTENSIONS"); - - if (Opts.CPlusPlus11) { - Builder.defineMacro("_RVALUE_REFERENCES_V2_SUPPORTED"); - Builder.defineMacro("_RVALUE_REFERENCES_SUPPORTED"); - Builder.defineMacro("_NATIVE_NULLPTR_SUPPORTED"); - } - } - if (!Opts.MSVolatile) Builder.defineMacro("_ISO_VOLATILE"); Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -110,6 +110,9 @@ Modified Compiler Flags ----------------------- +- ``-fms-extensions`` now defines the ``_MSC_EXTENSIONS`` macro regardless of + whether or not the ``-fms-compatibility`` flag is set and regardless of the + target triple. Removed Compiler Flags -------------------------
Index: clang/test/Preprocessor/predefined-win-macros.c =================================================================== --- clang/test/Preprocessor/predefined-win-macros.c +++ clang/test/Preprocessor/predefined-win-macros.c @@ -120,6 +120,11 @@ // CHECK-AMD64-MINGW: #define _WIN32 1 // CHECK-AMD64-MINGW: #define _WIN64 1 +// RUN: %clang_cc1 -triple x86_64-windows-gnu %s -E -dM -o - -fms-extensions \ +// RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-AMD64-MINGW-MSE + +// CHECK-AMD64-MINGW-MSE: #define _MSC_EXTENSIONS 1 + // RUN: %clang_cc1 -triple aarch64-windows-gnu %s -E -dM -o - \ // RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM64-MINGW Index: clang/lib/Frontend/InitPreprocessor.cpp =================================================================== --- clang/lib/Frontend/InitPreprocessor.cpp +++ clang/lib/Frontend/InitPreprocessor.cpp @@ -926,11 +926,19 @@ Builder.defineMacro("__private_extern__", "extern"); if (LangOpts.MicrosoftExt) { + Builder.defineMacro("_MSC_EXTENSIONS"); + if (LangOpts.WChar) { // wchar_t supported as a keyword. Builder.defineMacro("_WCHAR_T_DEFINED"); Builder.defineMacro("_NATIVE_WCHAR_T_DEFINED"); } + + if (LangOpts.CPlusPlus11) { + Builder.defineMacro("_RVALUE_REFERENCES_V2_SUPPORTED"); + Builder.defineMacro("_RVALUE_REFERENCES_SUPPORTED"); + Builder.defineMacro("_NATIVE_NULLPTR_SUPPORTED"); + } } // Macros to help identify the narrow and wide character sets Index: clang/lib/Basic/Targets/OSTargets.cpp =================================================================== --- clang/lib/Basic/Targets/OSTargets.cpp +++ clang/lib/Basic/Targets/OSTargets.cpp @@ -226,16 +226,6 @@ } } - if (Opts.MicrosoftExt) { - Builder.defineMacro("_MSC_EXTENSIONS"); - - if (Opts.CPlusPlus11) { - Builder.defineMacro("_RVALUE_REFERENCES_V2_SUPPORTED"); - Builder.defineMacro("_RVALUE_REFERENCES_SUPPORTED"); - Builder.defineMacro("_NATIVE_NULLPTR_SUPPORTED"); - } - } - if (!Opts.MSVolatile) Builder.defineMacro("_ISO_VOLATILE"); Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -110,6 +110,9 @@ Modified Compiler Flags ----------------------- +- ``-fms-extensions`` now defines the ``_MSC_EXTENSIONS`` macro regardless of + whether or not the ``-fms-compatibility`` flag is set and regardless of the + target triple. Removed Compiler Flags -------------------------
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits