aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAnna Gringauze <annagrin@microsoft.com>2019-01-15 10:27:34 -0800
committerGitHub <noreply@github.com>2019-01-15 10:27:34 -0800
commit6418b5f4de2204cd5a335b00d2f8754301b8b382 (patch)
treea755048982e8389bf9c8610b15ae157f172958f0 /include
parent6eeed739f1acb81c8b69ceae11bd5f350dab3601 (diff)
downloadMicrosoft-GSL-6418b5f4de2204cd5a335b00d2f8754301b8b382.tar.gz
Clang cl (#762)
* Added c++17 test configurations for clang5.0 and clang6.0 * Fix #739 correct cppcorecheck warnings for clang-cl * Add clang-cl configurations * Corrections Appveyor; Temporarily disable msvc compilation for faster testing (#741) * Add path to clang-cl.exe (#741) * Escape backslash in path (#741) * Update vcpkg (#741) * Check vcpkg version; try without building vcpkg; use latest clang-cl from path (#741) * Fix blocks in ps script (#741) * Try accessing APPVEYOR_BUILD_FOLDER variable (#471) * Update span size() bug confirmation test for GCC 6.5 (#741) * MSVC flags to Clang-cl; disable c++98-compat and undefined macro warnings (#741) * Suppress clang warning on tests (missing-prototypes) (#741) * Fix clang warning -Wnewline-eof (#741) * Fix clang warning -Wdouble-promotion (#741) * Set linker explicitly * Clean condition statement * For Clang, fallback to the AppVeyor installed version of CMake * Fix clang warning -Wmissing-variable-declarations * Fallback to the MSVC linker until vcpkg has been updated * Revert "Fallback to the MSVC linker until vcpkg has been updated" This reverts commit 7263f3289e6e835c32fc7800d0c2d4e58bd21178. * Fix clang warning -Wunused-member-function * Fix clang warning -Wmissing-noreturn * Fix clang warning -Winvalid-noreturn on Windows * Add macro block end comment on large #if blocks * Workaround: fallback to mscv link.exe * Workaround: get msvc paths into PowerShell through intermediate file * Workaround: fix, remove "PATH=" from text * Workaround: try with full-path; and return user PATH * Workaround: fix, escape backslashes * Revert all since "Workaround: fallback to mscv link.exe" did not work on AppVeyor This reverts the commits: bda3d6a428e5d19e97375b2e575b0f51ff1b4bc0 97062933acfb6428535c0fdcab5d94371ce72bfc 0f4fb04bac9c2d091005b791294237250dbe0668 1b0c19afd154f4ffc5ef793014c1bc2324534fd0 a5739ea5f0cd7633527b5e5d3b16a9e3ade7149f * Suppress output of git pull; remove vcpkg from cache * Re-enable AppVeyor builds for all platforms * Correct typo Co-Authored-By: Farwaykorse <Farwaykorse@users.noreply.github.com> * Add Clang-cl 7.0.0 to the supported platforms * Revert "Fix clang warning -Wunused-member-function" This reverts commit 6fe1a4203501145ab4350b9152ecc11f3a30e49a. * Fix or locally suppress clang warning -Wunused-member-function * format touched code and correct comment * git pull --quiet * fix logic error in workaround * fix missing bracket * Suppress output of mkdir * Replace MSBuild with Ninja * Suppress output of 7z * Add architecture flags for Clang * Drop workaround for lld-link * 7-zip Overwrite and Alternative output suppression without suppressing errors Replaces 3c1c0794dd9a29908cc7c38f591bd3c7b4929677 * AppVeyor setup and CMake before build * reorder compiler configuration * remove unnecessary * remove -fno-strict-aliasing * remove -Wsign-conversion, since before v4.0 part of -Wconversion * -Wctor-dtor-privacy is GCC only * remove -Woverloaded-virtual part of -Wmost, part of -Wall * add -Wmissing-noreturn * remove the pragmas for -Wunused-member-function * Re-add MSBuild generator on AppVeyor * Print CMake commands * Add MSBuild toolset selection * Separate Architecture setting * clang-cl: add -Weverything * clang-cl -Wno-c++98-compat * clang-cl -Wno-c++98-compat-pedantic * clang-cl -Wno-missing-prototypes * clang-cl C++14 -Wno-unused-member-function * clang-cl -Wundef __GNUC__ * clang++: add -Weverything * clang++ -Wno-c++98-compat * clang++ -Wno-c++98-compat-pedantic * clang++ -Wno-missing-prototypes * clang++ -Wno-weak-vtables * clang++ C++14 -Wno-unused-member-function * clang++ fix -Wundef _MSC_VER * clang++ -Wno-padded * clang++ solve -Wdeprecated * Add AppleClang compiler target Since CMake v3.0 use of Clang for both is deprecated * clang++ v5.0 C++17 -Wno-undefined-func-template * Add VS2015 + LLVM/clang-cl to AppVeyor * Do not disable constexpr when compiling with clang-cl on Windows * Clean-up clang-only warnings (now under -Weverything) * Revert "Fix clang warning -Winvalid-noreturn on Windows" This reverts commit 2238c4760e86feebb2a18620b77312bd01055f61. * Suppress -Winvalid-noreturn for the MS STL noexception workaround * CMake: put preprocessor definition in target_compile_definitions * Solve compiler warning C4668: __GNUC__ not defined
Diffstat (limited to 'include')
-rw-r--r--include/gsl/gsl_assert26
-rw-r--r--include/gsl/gsl_byte12
-rw-r--r--include/gsl/gsl_util4
-rw-r--r--include/gsl/multi_span11
-rw-r--r--include/gsl/pointers8
-rw-r--r--include/gsl/span8
-rw-r--r--include/gsl/string_span4
7 files changed, 43 insertions, 30 deletions
diff --git a/include/gsl/gsl_assert b/include/gsl/gsl_assert
index 3c952e6..c704633 100644
--- a/include/gsl/gsl_assert
+++ b/include/gsl/gsl_assert
@@ -22,17 +22,17 @@
//
// make suppress attributes parse for some compilers
-// Hopefully temporary until suppresion standardization occurs
+// Hopefully temporary until suppression standardization occurs
//
-#if defined (_MSC_VER)
-#define GSL_SUPPRESS(x) [[gsl::suppress(x)]]
-#else
#if defined(__clang__)
#define GSL_SUPPRESS(x) [[gsl::suppress("x")]]
#else
+#if defined(_MSC_VER)
+#define GSL_SUPPRESS(x) [[gsl::suppress(x)]]
+#else
#define GSL_SUPPRESS(x)
-#endif // __clang__
#endif // _MSC_VER
+#endif // __clang__
//
// Temporary until MSVC STL supports no-exceptions mode.
@@ -42,6 +42,12 @@
#define GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND
#include <intrin.h>
#define RANGE_CHECKS_FAILURE 0
+
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Winvalid-noreturn"
+#endif
+
#endif
//
@@ -98,7 +104,7 @@ namespace details
#if defined(GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND)
typedef void (__cdecl *terminate_handler)();
-
+
GSL_SUPPRESS(f.6) // NO-FORMAT: attribute
[[noreturn]] inline void __cdecl default_terminate_handler()
{
@@ -138,7 +144,7 @@ namespace details
throw std::forward<Exception>(exception);
}
-#endif
+#endif // GSL_TERMINATE_ON_CONTRACT_VIOLATION
} // namespace details
} // namespace gsl
@@ -159,9 +165,13 @@ namespace details
#define GSL_CONTRACT_CHECK(type, cond) GSL_ASSUME(cond)
-#endif
+#endif // GSL_THROW_ON_CONTRACT_VIOLATION
#define Expects(cond) GSL_CONTRACT_CHECK("Precondition", cond)
#define Ensures(cond) GSL_CONTRACT_CHECK("Postcondition", cond)
+#if defined(GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND) && defined(__clang__)
+#pragma clang diagnostic pop
+#endif
+
#endif // GSL_CONTRACTS_H
diff --git a/include/gsl/gsl_byte b/include/gsl/gsl_byte
index bc18886..861446d 100644
--- a/include/gsl/gsl_byte
+++ b/include/gsl/gsl_byte
@@ -19,17 +19,17 @@
//
// make suppress attributes work for some compilers
-// Hopefully temporary until suppresion standardization occurs
+// Hopefully temporary until suppression standardization occurs
//
-#if defined(_MSC_VER)
-#define GSL_SUPPRESS(x) [[gsl::suppress(x)]]
-#else
#if defined(__clang__)
#define GSL_SUPPRESS(x) [[gsl::suppress("x")]]
#else
+#if defined(_MSC_VER)
+#define GSL_SUPPRESS(x) [[gsl::suppress(x)]]
+#else
#define GSL_SUPPRESS(x)
-#endif // __clang__
#endif // _MSC_VER
+#endif // __clang__
#include <type_traits>
@@ -79,7 +79,7 @@
#endif // _MSC_VER
// Use __may_alias__ attribute on gcc and clang
-#if defined __clang__ || (__GNUC__ > 5)
+#if defined __clang__ || (defined(__GNUC__) && __GNUC__ > 5)
#define byte_may_alias __attribute__((__may_alias__))
#else // defined __clang__ || defined __GNUC__
#define byte_may_alias
diff --git a/include/gsl/gsl_util b/include/gsl/gsl_util
index 1558044..4addde6 100644
--- a/include/gsl/gsl_util
+++ b/include/gsl/gsl_util
@@ -26,7 +26,7 @@
#include <type_traits> // for is_signed, integral_constant
#include <utility> // for forward
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(push)
#pragma warning(disable : 4127) // conditional expression is constant
@@ -161,7 +161,7 @@ constexpr T at(const std::initializer_list<T> cont, const index i)
} // namespace gsl
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) && !defined(__clang__)
#if _MSC_VER < 1910
#undef constexpr
#pragma pop_macro("constexpr")
diff --git a/include/gsl/multi_span b/include/gsl/multi_span
index 9995808..f1a909e 100644
--- a/include/gsl/multi_span
+++ b/include/gsl/multi_span
@@ -37,7 +37,7 @@
#include <type_traits> // for enable_if_t, remove_cv_t, is_same, is_co...
#include <utility>
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && !defined(__clang__)
// turn off some warnings that are noisy about our Expects statements
#pragma warning(push)
@@ -62,7 +62,7 @@
// compiletime, so the compiler wouldn't have to warn indiscriminently, but
// could check if the source value actually doesn't fit into the target type
// and only warn in those cases.
-#if __GNUC__ > 6
+#if defined(__GNUC__) && __GNUC__ > 6
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
@@ -596,7 +596,6 @@ public:
using sliced_type = static_bounds<RestRanges...>;
using mapping_type = contiguous_mapping_tag;
- constexpr static_bounds(const static_bounds&) noexcept = default;
constexpr static_bounds() /*noexcept*/ = default;
template <typename SourceType, typename TargetType, std::size_t Rank>
@@ -1887,6 +1886,8 @@ public:
auto d = narrow_cast<size_type>(sizeof(OtherValueType) / sizeof(value_type));
const size_type size = this->bounds().total_size() / d;
+
+ GSL_SUPPRESS(type.3) // NO-FORMAT: attribute
return {const_cast<OtherValueType*>(reinterpret_cast<const OtherValueType*>(this->data())),
size,
bounds_type{resize_extent(this->bounds().index_bounds(), d),
@@ -2274,7 +2275,7 @@ general_span_iterator<Span> operator+(typename general_span_iterator<Span>::diff
} // namespace gsl
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && !defined(__clang__)
#if _MSC_VER < 1910
#undef constexpr
@@ -2285,7 +2286,7 @@ general_span_iterator<Span> operator+(typename general_span_iterator<Span>::diff
#endif // _MSC_VER
-#if __GNUC__ > 6
+#if defined(__GNUC__) && __GNUC__ > 6
#pragma GCC diagnostic pop
#endif // __GNUC__ > 6
diff --git a/include/gsl/pointers b/include/gsl/pointers
index 52c2bfd..0f2987a 100644
--- a/include/gsl/pointers
+++ b/include/gsl/pointers
@@ -25,7 +25,7 @@
#include <system_error> // for hash
#include <type_traits> // for enable_if_t, is_convertible, is_assignable
-#if defined(_MSC_VER) && _MSC_VER < 1910
+#if defined(_MSC_VER) && _MSC_VER < 1910 && !defined(__clang__)
#pragma push_macro("constexpr")
#define constexpr /*constexpr*/
@@ -283,10 +283,12 @@ struct hash<gsl::strict_not_null<T>>
};
} // namespace std
-#if defined(_MSC_VER) && _MSC_VER < 1910
+
+#if defined(_MSC_VER) && _MSC_VER < 1910 && !defined(__clang__)
+
#undef constexpr
#pragma pop_macro("constexpr")
-#endif // defined(_MSC_VER) && _MSC_VER < 1910
+#endif // defined(_MSC_VER) && _MSC_VER < 1910 && !defined(__clang__)
#endif // GSL_POINTERS_H
diff --git a/include/gsl/span b/include/gsl/span
index fae1522..b4da532 100644
--- a/include/gsl/span
+++ b/include/gsl/span
@@ -31,7 +31,7 @@
#include <utility>
#include <memory> // for std::addressof
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(push)
// turn off some warnings that are noisy about our Expects statements
@@ -61,7 +61,7 @@
// compiletime, so the compiler wouldn't have to warn indiscriminently, but
// could check if the source value actually doesn't fit into the target type
// and only warn in those cases.
-#if __GNUC__ > 6
+#if defined(__GNUC__) && __GNUC__ > 6
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
@@ -776,7 +776,7 @@ constexpr ElementType& at(span<ElementType, Extent> s, index i)
} // namespace gsl
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && !defined(__clang__)
#if _MSC_VER < 1910
#undef constexpr
#pragma pop_macro("constexpr")
@@ -786,7 +786,7 @@ constexpr ElementType& at(span<ElementType, Extent> s, index i)
#pragma warning(pop)
#endif // _MSC_VER
-#if __GNUC__ > 6
+#if defined(__GNUC__) && __GNUC__ > 6
#pragma GCC diagnostic pop
#endif // __GNUC__ > 6
diff --git a/include/gsl/string_span b/include/gsl/string_span
index d298039..b5dfd18 100644
--- a/include/gsl/string_span
+++ b/include/gsl/string_span
@@ -30,7 +30,7 @@
#include <string> // for basic_string, allocator, char_traits
#include <type_traits> // for declval, is_convertible, enable_if_t, add_...
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(push)
// Turn MSVC /analyze rules that generate too much noise. TODO: fix in the tool.
@@ -706,7 +706,7 @@ bool operator>=(const T& one, gsl::basic_string_span<CharT, Extent> other)
#endif
} // namespace gsl
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(pop)
#if _MSC_VER < 1910