Author: rnk Date: Tue Jul 9 13:57:28 2019 New Revision: 365556 URL: http://llvm.org/viewvc/llvm-project?rev=365556&view=rev Log: De-templatize non-dependent VS macro logic, NFC
These macro definitions don't depend on the template parameter, so they don't need to be part of the template. Move them to a .cpp file. Modified: cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/lib/Basic/Targets.h cfe/trunk/lib/Basic/Targets/AArch64.cpp cfe/trunk/lib/Basic/Targets/AArch64.h cfe/trunk/lib/Basic/Targets/ARM.cpp cfe/trunk/lib/Basic/Targets/OSTargets.cpp cfe/trunk/lib/Basic/Targets/OSTargets.h cfe/trunk/lib/Basic/Targets/X86.h Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=365556&r1=365555&r2=365556&view=diff ============================================================================== --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Tue Jul 9 13:57:28 2019 @@ -98,19 +98,6 @@ void addCygMingDefines(const LangOptions } } -void addMinGWDefines(const llvm::Triple &Triple, const LangOptions &Opts, - MacroBuilder &Builder) { - DefineStd(Builder, "WIN32", Opts); - DefineStd(Builder, "WINNT", Opts); - if (Triple.isArch64Bit()) { - DefineStd(Builder, "WIN64", Opts); - Builder.defineMacro("__MINGW64__"); - } - Builder.defineMacro("__MSVCRT__"); - Builder.defineMacro("__MINGW32__"); - addCygMingDefines(Opts, Builder); -} - //===----------------------------------------------------------------------===// // Driver code //===----------------------------------------------------------------------===// Modified: cfe/trunk/lib/Basic/Targets.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.h?rev=365556&r1=365555&r2=365556&view=diff ============================================================================== --- cfe/trunk/lib/Basic/Targets.h (original) +++ cfe/trunk/lib/Basic/Targets.h Tue Jul 9 13:57:28 2019 @@ -39,10 +39,6 @@ void defineCPUMacros(clang::MacroBuilder bool Tuning = true); LLVM_LIBRARY_VISIBILITY -void addMinGWDefines(const llvm::Triple &Triple, const clang::LangOptions &Opts, - clang::MacroBuilder &Builder); - -LLVM_LIBRARY_VISIBILITY void addCygMingDefines(const clang::LangOptions &Opts, clang::MacroBuilder &Builder); } // namespace targets Modified: cfe/trunk/lib/Basic/Targets/AArch64.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.cpp?rev=365556&r1=365555&r2=365556&view=diff ============================================================================== --- cfe/trunk/lib/Basic/Targets/AArch64.cpp (original) +++ cfe/trunk/lib/Basic/Targets/AArch64.cpp Tue Jul 9 13:57:28 2019 @@ -534,16 +534,10 @@ MicrosoftARM64TargetInfo::MicrosoftARM64 TheCXXABI.set(TargetCXXABI::Microsoft); } -void MicrosoftARM64TargetInfo::getVisualStudioDefines( - const LangOptions &Opts, MacroBuilder &Builder) const { - WindowsTargetInfo<AArch64leTargetInfo>::getVisualStudioDefines(Opts, Builder); - Builder.defineMacro("_M_ARM64", "1"); -} - void MicrosoftARM64TargetInfo::getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const { - WindowsTargetInfo::getTargetDefines(Opts, Builder); - getVisualStudioDefines(Opts, Builder); + WindowsARM64TargetInfo::getTargetDefines(Opts, Builder); + Builder.defineMacro("_M_ARM64", "1"); } TargetInfo::CallingConvKind Modified: cfe/trunk/lib/Basic/Targets/AArch64.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.h?rev=365556&r1=365555&r2=365556&view=diff ============================================================================== --- cfe/trunk/lib/Basic/Targets/AArch64.h (original) +++ cfe/trunk/lib/Basic/Targets/AArch64.h Tue Jul 9 13:57:28 2019 @@ -123,8 +123,6 @@ public: MicrosoftARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts); - void getVisualStudioDefines(const LangOptions &Opts, - MacroBuilder &Builder) const; void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override; TargetInfo::CallingConvKind Modified: cfe/trunk/lib/Basic/Targets/ARM.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARM.cpp?rev=365556&r1=365555&r2=365556&view=diff ============================================================================== --- cfe/trunk/lib/Basic/Targets/ARM.cpp (original) +++ cfe/trunk/lib/Basic/Targets/ARM.cpp Tue Jul 9 13:57:28 2019 @@ -1030,8 +1030,6 @@ WindowsARMTargetInfo::WindowsARMTargetIn void WindowsARMTargetInfo::getVisualStudioDefines(const LangOptions &Opts, MacroBuilder &Builder) const { - WindowsTargetInfo<ARMleTargetInfo>::getVisualStudioDefines(Opts, Builder); - // FIXME: this is invalid for WindowsCE Builder.defineMacro("_M_ARM_NT", "1"); Builder.defineMacro("_M_ARMT", "_M_ARM"); Modified: cfe/trunk/lib/Basic/Targets/OSTargets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.cpp?rev=365556&r1=365555&r2=365556&view=diff ============================================================================== --- cfe/trunk/lib/Basic/Targets/OSTargets.cpp (original) +++ cfe/trunk/lib/Basic/Targets/OSTargets.cpp Tue Jul 9 13:57:28 2019 @@ -134,5 +134,84 @@ void getDarwinDefines(MacroBuilder &Buil PlatformMinVersion = VersionTuple(Maj, Min, Rev); } + +static void addMinGWDefines(const llvm::Triple &Triple, const LangOptions &Opts, + MacroBuilder &Builder) { + DefineStd(Builder, "WIN32", Opts); + DefineStd(Builder, "WINNT", Opts); + if (Triple.isArch64Bit()) { + DefineStd(Builder, "WIN64", Opts); + Builder.defineMacro("__MINGW64__"); + } + Builder.defineMacro("__MSVCRT__"); + Builder.defineMacro("__MINGW32__"); + addCygMingDefines(Opts, Builder); +} + +static void addVisualCDefines(const LangOptions &Opts, MacroBuilder &Builder) { + if (Opts.CPlusPlus) { + if (Opts.RTTIData) + Builder.defineMacro("_CPPRTTI"); + + if (Opts.CXXExceptions) + Builder.defineMacro("_CPPUNWIND"); + } + + if (Opts.Bool) + Builder.defineMacro("__BOOL_DEFINED"); + + if (!Opts.CharIsSigned) + Builder.defineMacro("_CHAR_UNSIGNED"); + + // FIXME: POSIXThreads isn't exactly the option this should be defined for, + // but it works for now. + if (Opts.POSIXThreads) + Builder.defineMacro("_MT"); + + if (Opts.MSCompatibilityVersion) { + Builder.defineMacro("_MSC_VER", + Twine(Opts.MSCompatibilityVersion / 100000)); + Builder.defineMacro("_MSC_FULL_VER", Twine(Opts.MSCompatibilityVersion)); + // FIXME We cannot encode the revision information into 32-bits + Builder.defineMacro("_MSC_BUILD", Twine(1)); + + if (Opts.CPlusPlus11 && Opts.isCompatibleWithMSVC(LangOptions::MSVC2015)) + Builder.defineMacro("_HAS_CHAR16_T_LANGUAGE_SUPPORT", Twine(1)); + + if (Opts.isCompatibleWithMSVC(LangOptions::MSVC2015)) { + if (Opts.CPlusPlus2a) + Builder.defineMacro("_MSVC_LANG", "201704L"); + else if (Opts.CPlusPlus17) + Builder.defineMacro("_MSVC_LANG", "201703L"); + else if (Opts.CPlusPlus14) + Builder.defineMacro("_MSVC_LANG", "201402L"); + } + } + + 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"); + } + } + + Builder.defineMacro("_INTEGRAL_MAX_BITS", "64"); +} + +void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts, + MacroBuilder &Builder) { + Builder.defineMacro("_WIN32"); + if (Triple.isArch64Bit()) + Builder.defineMacro("_WIN64"); + if (Triple.isWindowsGNUEnvironment()) + addMinGWDefines(Triple, Opts, Builder); + else if (Triple.isKnownWindowsMSVCEnvironment() || + (Triple.isWindowsItaniumEnvironment() && Opts.MSVCCompat)) + addVisualCDefines(Opts, Builder); +} + } // namespace targets } // namespace clang Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.h?rev=365556&r1=365555&r2=365556&view=diff ============================================================================== --- cfe/trunk/lib/Basic/Targets/OSTargets.h (original) +++ cfe/trunk/lib/Basic/Targets/OSTargets.h Tue Jul 9 13:57:28 2019 @@ -711,71 +711,16 @@ public: bool hasInt128Type() const override { return false; } }; +void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts, + MacroBuilder &Builder); + // Windows target template <typename Target> class LLVM_LIBRARY_VISIBILITY WindowsTargetInfo : public OSTargetInfo<Target> { protected: void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, MacroBuilder &Builder) const override { - Builder.defineMacro("_WIN32"); - if (Triple.isArch64Bit()) - Builder.defineMacro("_WIN64"); - if (Triple.isWindowsGNUEnvironment()) - addMinGWDefines(Triple, Opts, Builder); - - } - void getVisualStudioDefines(const LangOptions &Opts, - MacroBuilder &Builder) const { - if (Opts.CPlusPlus) { - if (Opts.RTTIData) - Builder.defineMacro("_CPPRTTI"); - - if (Opts.CXXExceptions) - Builder.defineMacro("_CPPUNWIND"); - } - - if (Opts.Bool) - Builder.defineMacro("__BOOL_DEFINED"); - - if (!Opts.CharIsSigned) - Builder.defineMacro("_CHAR_UNSIGNED"); - - // FIXME: POSIXThreads isn't exactly the option this should be defined for, - // but it works for now. - if (Opts.POSIXThreads) - Builder.defineMacro("_MT"); - - if (Opts.MSCompatibilityVersion) { - Builder.defineMacro("_MSC_VER", - Twine(Opts.MSCompatibilityVersion / 100000)); - Builder.defineMacro("_MSC_FULL_VER", Twine(Opts.MSCompatibilityVersion)); - // FIXME We cannot encode the revision information into 32-bits - Builder.defineMacro("_MSC_BUILD", Twine(1)); - - if (Opts.CPlusPlus11 && Opts.isCompatibleWithMSVC(LangOptions::MSVC2015)) - Builder.defineMacro("_HAS_CHAR16_T_LANGUAGE_SUPPORT", Twine(1)); - - if (Opts.isCompatibleWithMSVC(LangOptions::MSVC2015)) { - if (Opts.CPlusPlus2a) - Builder.defineMacro("_MSVC_LANG", "201704L"); - else if (Opts.CPlusPlus17) - Builder.defineMacro("_MSVC_LANG", "201703L"); - else if (Opts.CPlusPlus14) - Builder.defineMacro("_MSVC_LANG", "201402L"); - } - } - - 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"); - } - } - - Builder.defineMacro("_INTEGRAL_MAX_BITS", "64"); + addWindowsDefines(Triple, Opts, Builder); } public: Modified: cfe/trunk/lib/Basic/Targets/X86.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.h?rev=365556&r1=365555&r2=365556&view=diff ============================================================================== --- cfe/trunk/lib/Basic/Targets/X86.h (original) +++ cfe/trunk/lib/Basic/Targets/X86.h Tue Jul 9 13:57:28 2019 @@ -481,7 +481,6 @@ public: void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override { WindowsX86_32TargetInfo::getTargetDefines(Opts, Builder); - WindowsX86_32TargetInfo::getVisualStudioDefines(Opts, Builder); // The value of the following reflects processor type. // 300=386, 400=486, 500=Pentium, 600=Blend (default) // We lost the original triple, so we use the default. @@ -745,7 +744,6 @@ public: void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override { WindowsX86_64TargetInfo::getTargetDefines(Opts, Builder); - WindowsX86_64TargetInfo::getVisualStudioDefines(Opts, Builder); Builder.defineMacro("_M_X64", "100"); Builder.defineMacro("_M_AMD64", "100"); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits