diff options
author | Andreas Holzammer <andreas.holzammer@kdab.com> | 2016-02-10 13:05:26 +0100 |
---|---|---|
committer | Andreas Holzammer <andreas.holzammer@kdab.com> | 2016-02-11 12:54:06 +0000 |
commit | 7e85e7ced7079d620ae73f8664a68530992c6af1 (patch) | |
tree | cbf9665ac00132838a57afeeae976aa877b9a7af /src/corelib | |
parent | 9e8c84aa14ee26c04ab04ff28f0bab22e04887d6 (diff) |
Add initial clang-cl support to Qt
This adds the functionality to build Qt with clang under Windows against
the Microsoft Visual Studio 2015 runtime.
In order to replicate this, a Clang 3.8 build with Visual Studio 2015
Update 1 is needed.
Adds compiler detection to Qt to distinguish correctly the clang compiler
and Windows with Visual Studio.
Clang has some built-in numeric functions, there is no need to use the
Microsoft versions, which also conflict here.
Task-number: QTBUG-50804
Change-Id: Ia4b267a298310ac7d73edf473b12792991249d8a
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/global/qcompilerdetection.h | 9 | ||||
-rw-r--r-- | src/corelib/global/qnumeric_p.h | 6 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index e655aace32..7575fe06b2 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -83,6 +83,9 @@ # endif #elif defined(_MSC_VER) +# ifdef __clang__ +# define Q_CC_CLANG ((__clang_major__ * 100) + __clang_minor__) +# endif # define Q_CC_MSVC (_MSC_VER) # define Q_CC_MSVC_NET # define Q_OUTOFLINE_TEMPLATE inline @@ -97,7 +100,9 @@ # define Q_UNREACHABLE_IMPL() __assume(0) # define Q_NORETURN __declspec(noreturn) # define Q_DECL_DEPRECATED __declspec(deprecated) -# define Q_DECL_DEPRECATED_X(text) __declspec(deprecated(text)) +# ifndef Q_CC_CLANG +# define Q_DECL_DEPRECATED_X(text) __declspec(deprecated(text)) +# endif # define Q_DECL_EXPORT __declspec(dllexport) # define Q_DECL_IMPORT __declspec(dllimport) /* Intel C++ disguising as Visual C++: the `using' keyword avoids warnings */ @@ -1177,7 +1182,7 @@ # define QT_WARNING_DISABLE_MSVC(number) # define QT_WARNING_DISABLE_CLANG(text) # define QT_WARNING_DISABLE_GCC(text) -#elif defined(Q_CC_MSVC) && _MSC_VER >= 1500 +#elif defined(Q_CC_MSVC) && _MSC_VER >= 1500 && !defined(Q_CC_CLANG) # undef QT_DO_PRAGMA /* not needed */ # define QT_WARNING_PUSH __pragma(warning(push)) # define QT_WARNING_POP __pragma(warning(pop)) diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h index f58e062dbd..5705bc29c8 100644 --- a/src/corelib/global/qnumeric_p.h +++ b/src/corelib/global/qnumeric_p.h @@ -222,7 +222,7 @@ template <> inline bool mul_overflow(unsigned long long v1, unsigned long long v # define HAVE_MUL64_OVERFLOW #endif -#if ((defined(Q_CC_MSVC) && _MSC_VER >= 1800) || defined(Q_CC_INTEL)) && defined(Q_PROCESSOR_X86) +#if ((defined(Q_CC_MSVC) && _MSC_VER >= 1800) || defined(Q_CC_INTEL)) && defined(Q_PROCESSOR_X86) && !QT_HAS_BUILTIN(__builtin_uadd_overflow) template <> inline bool add_overflow(unsigned v1, unsigned v2, unsigned *r) { return _addcarry_u32(0, v1, v2, r); } # ifdef Q_CC_MSVC // longs are 32-bit @@ -230,7 +230,7 @@ template <> inline bool add_overflow(unsigned long v1, unsigned long v2, unsigne { return _addcarry_u32(0, v1, v2, reinterpret_cast<unsigned *>(r)); } # endif #endif -#if ((defined(Q_CC_MSVC) && _MSC_VER >= 1800) || defined(Q_CC_INTEL)) && defined(Q_PROCESSOR_X86_64) +#if ((defined(Q_CC_MSVC) && _MSC_VER >= 1800) || defined(Q_CC_INTEL)) && defined(Q_PROCESSOR_X86_64) && !QT_HAS_BUILTIN(__builtin_uadd_overflow) template <> inline bool add_overflow(quint64 v1, quint64 v2, quint64 *r) { return _addcarry_u64(0, v1, v2, reinterpret_cast<unsigned __int64 *>(r)); } # ifndef Q_CC_MSVC // longs are 64-bit @@ -239,7 +239,7 @@ template <> inline bool add_overflow(unsigned long v1, unsigned long v2, unsigne # endif #endif -#if defined(Q_CC_MSVC) && (defined(Q_PROCESSOR_X86_64) || defined(Q_PROCESSOR_IA64)) +#if defined(Q_CC_MSVC) && (defined(Q_PROCESSOR_X86_64) || defined(Q_PROCESSOR_IA64)) && !QT_HAS_BUILTIN(__builtin_uadd_overflow) #pragma intrinsic(_umul128) template <> inline bool mul_overflow(quint64 v1, quint64 v2, quint64 *r) { |