Commit Graph

328 Commits

Author SHA1 Message Date
Carson Radtke
b206bd163b
[ci]: fix android job (#1158)
Job has been failing for months and is preventing other PRs from getting
merged. This PR fixes the pipeline - it changed the following:
 - runs on macos-latest-large (which is a non-arm image)
 - starts the emulator under java8 (see
   https://learn.microsoft.com/en-us/java/openjdk/transition-from-java-8-to-java-11)
 - runs emulator with -no-audio

The above were requirements to get the pipeline running. Other changes
include the following:
 - The job will auto-cancel when a newer commit is pushed to the
 PR.
 - The 'Wait for emulator ready' step now has a 2 minute timeout. This
   is necessary because we get no indication on whether or not the
   command that started the emulator suceeded. I believe there is room
   for improvement here, but it is outside the scope of the PR.
2024-10-11 16:05:20 -07:00
d-winsor
1b4d42ca2e
Fix initialization in test (#1140)
* Suppress unsafe-buffer-usage
2024-02-26 13:17:12 -08:00
Bruce Mitchener
caae4dd0f8
Fix some typos. (#1146) 2024-02-21 15:06:29 -08:00
Nicholas Guriev
e64c97fc2c
Mark not_null constructors as noexcept when underlying type can be moved with no exception (#1135)
This enables possible optimisations for trivial types. This also avoids a bug
in std::variant::emplace from GNU's libstdc++.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106547
2023-10-18 15:15:26 -07:00
Edward Chen
52212c2d76
Update Clang GSL_SUPPRESS to stringize parameter instead of using fixed string literal. (#1133)
Fix #1130.
2023-09-11 10:52:30 -07:00
Dmitry Kobets
2940006b5c
Suppress some noisy / buggy warnings (#1136)
Two warnings were being emitted in the MSVC+LLVM tests. 

The warning `-Wunsafe-buffer-usage` is initially introduced in some capacity here https://reviews.llvm.org/D137346 pointing to documentation at https://discourse.llvm.org/t/rfc-c-buffer-hardening/65734. The warning is a stylistic checker whose goal is to "emit a warning every time an unsafe operation is performed on a raw pointer". This type of programming model is not useful for library implementations of types such as `span`, where direct manipulation of raw pointers is inevitable, so disable the warning altogether.

There is also a false-positive warning https://github.com/llvm/llvm-project/issues/65689 that I've disabled inline.
2023-09-11 10:06:40 -07:00
Dmitry Kobets
9face82309
Remove unnecessary check from size_bytes() (#1105)
`size_bytes()` returns the span's size in bytes. 
Assuming the span was constructed with an accurate size parameter, the check `size() < dynamic_extent / sizeof(element_type)` isn't required, since `size_t(-1)` (which is `dynamic_extent`) represents the size of the address space, so the number of bytes will never exceed it and in practice won't even come close.
Otherwise, it is not actually feasible to detect cases when the size parameter does not correspond to the dimensions of the underlying data pointer. In these cases, the relationship `size() < dynamic_extent / sizeof(element_type)` is simply one of many ways in which the `size()` could be incorrect, and serves no necessary purpose.

Resolves #1012
2023-05-09 09:05:26 -07:00
Dmitry Kobets
1d036585cc
Add testcase for #1100 (#1101) 2023-03-30 11:10:15 -07:00
Werner Henze
7a297d4283
Extend docs and tests for span ctor (#1096) 2023-02-21 15:46:40 -08:00
Werner Henze
9851b94d7e
add some span test for constructor from other span (#1093)
More combinations with dynamic_extent or fixed extent for higher coverage.
2023-02-17 13:05:40 -08:00
Werner Henze
3ba80d5dd4
simplify to_byte (#1090)
- to_byte_impl is not necessary, the same can be achieved with shorter code
- add test code for things that should not compile
2023-02-14 14:10:56 -08:00
Werner Henze
49c88f27bd
add not_null and strict_not_null tests for const (#1085) 2023-02-06 13:16:06 -08:00
jpr42
f7da2e41f0
Raise CMake min to 3.14 (#1083)
- Explicitly test package manager support with CMake 3.14 and Ninja
- Remove gsl_install.cmake
- Simplify installation code
2023-02-06 11:16:37 -08:00
Werner Henze
a381a3759f
1075 Wrong Expects in gsl::at? (#1076)
https://github.com/microsoft/GSL/issues/1075
- Add `static_assert` because we only support C style array `at` for up to half of the address space.
- Add `std::` before `size_t`.
- tests:
  - Add `#include <exception>`
  - Implement `span_tests` `interop_with_gsl_at` like `at_tests` `std_span`
2023-01-18 13:33:20 -08:00
Werner Henze
ac26d7bc71
cleanup natvis (#1077)
- `fail_fast`,`basic_string_span` and `basic_zstring_span` are not declared in the headers any more.
- Name the exporting header file for all types in `GSL.natvis`.
2022-12-29 10:21:11 -08:00
Werner Henze
c016bdc77f
remove all deprecated string_span stuff (#1074)
This solves issue #1070 and removes the class `string_span`. The only content remaining in the header file `gsl/string_span` is the `*zstring` types.
This also removes the `string_span_tests.cpp` unit tests as these were only for the deprecated `string_span` class.

Co-authored-by: Werner Henze <werner.henze+gitcommits@posteo.de>
2022-12-27 07:22:26 -08:00
dmitrykobets-msft
f3620bb009
Suppress false postive warning (#1068)
The Clang compiler for MSVC in Visual Studio 2022 17.4.33122.133 used by the test runner has a bug which raises -Wdeprecated "out-of-line definition of constexpr static data member is redundant in C++17 and is deprecated" in gsl/span, when compiling with C++14. Temporarily suppress this warning for MSVC Clang with C++14.
2022-12-14 15:39:34 -08:00
jpr42
9c4212aca4
Raise CMake min to 3.8 (#1061)
This avoids propagating -std=c++14 as a compile option

Currently if you use less than CMake 3.8 and you install the project
`-std=c++14` gets added to the INTERFACE_COMPILE_OPTIONS. This forces
users to use C++ 14 or remove the property from the imported target.

The solution is to raise the minimum and use `cxx_std_14`
2022-10-29 12:31:23 -07:00
dmitrykobets-msft
991fa6682e
Prevent inefficient copying when using not_null::get (#1059)
Closes issue #550, which highlighted overhead in not_null::get for larger types such as shared_ptr. Every call to get would return a copy of the contained value.
This PR implements Herb's suggestion for changing the return type of not_null::get. The not_null's value will now only be copied if it is "trivially copyable"; otherwise, it will be returned by const reference.
Note: this change also forces the returned copy to be const.
2022-10-11 16:49:16 -07:00
Herb Sutter
7d49d4b45d
Clean up final_act and finally, closes #846 (#977)
Somewhere along the way, GSL's implementation of final_act and finally seems to have become way overthought. This PR is to re-simplify these facilities back to what C++ Core Guidelines C.30 said which is simple and clear and works. It just copies the invocable thing, and doesn't bother trying to optimize the copy. This should be fine, because we're typically passing something that's cheap to copy, often a stateless lambda.

The problem in #846 appears to be because finally looks like was originally written as a const&/&& overload (its state at the time that issue was opened)... to eliminate a copy when you invoke it with a temporary. If so, then the && was probably never intended to be a forwarder, but an rvalue reference that tripped over the horrid C++ syntax collision where a && parameter magically instead means a forwarding reference because the type happens to be a template parameter type here. So I suspect the original author was just trying to write an rvalue overload, and the forwarder that's there now was never intended at all.
2022-10-10 16:09:21 -07:00
Rose
849f7ceaf7
Fix Clang-tidy 15 warnings (#1058)
These warnings were found by running clang-tidy 15.
2022-10-06 09:44:39 -07:00
dmitrykobets-msft
2bfd495080
Suppress -Wfloat-equal warning in implementation of gsl::narrow (#1043)
In the implementation of gsl::narrow, there is a comparison `static_cast<U>(t) != u` which may be comparing two floats.
The comparison here is done purposefully to categorize ill effects of narrowing conversion, since the values being compared *should* be the same when compared with `operator==`. 
Note, using #pragma GCC will suppress this warning for both GCC and Clang.
2022-04-14 11:08:28 -07:00
dmitrykobets-msft
383723676c
Make gsl::span's iterators use the contiguous_iterator concept (#1035)
Resolves #1016

Co-authored-by: Casey Carter <Casey@Carter.net>
2022-03-22 13:20:54 -07:00
dmitrykobets-msft
f22f524aa2
Suppress reserved identifier warning (#1041)
The following reserved identifiers are being used specifically to target certain MSVC constructs, so suppress the warning in VS 2022 (LLVM) "... is reserved because it starts with '_' followed by a capital letter":
- _Unchecked_type
- _Verify_range
- _Verify_offset
- _Unwrapped
- _Unwrap_when_unverified
- _Seek_to
- _Unchecked_begin
- _Unchecked_end
2022-03-22 12:24:23 -07:00
dmitrykobets-msft
c412deb31e
Update compiler support (#1019) 2021-12-10 11:17:47 -08:00
dmitrykobets-msft
bcf008ae55
Fix/implement C++2020 compilation, tests, and CI (#1017)
* Fix C++20 bugs and tests
* Rework CI for C++2020 tests
* Update readme compiler versions
2021-12-09 14:54:06 -08:00
dmitrykobets-msft
e0880931ae
Fix googletest build failure with gcc 11.1+ (#1015) 2021-11-17 12:24:40 -08:00
Werner Henze
da80ce15d8
make zstring family don't require empty angle brackets any more (#998)
Co-authored-by: Werner Henze <werner.henze+gitcommits@posteo.de>
2021-10-26 16:50:58 -07:00
Johel Ernesto Guerrero Peña
8a4b9ed0bf
feat: narrow for non totally ordered types (#986) 2021-06-23 15:28:45 -07:00
Jordan Maples [MSFT]
b26f6d5ec7
gsl::at behavior change regarding gsl::span (#985)
* move span specialization of 'at' to <gsl/span> and update the parameter to be taken by reference

* undid previous changes and acted upon decisions made in maintainer sync. Fixed tests failing in /kernel mode

* ran clang-format on the include folder

* ran clang-format on the test folder

Co-authored-by: Jordan Maples <jordan.maples@microsoft.com>
2021-05-20 18:18:08 -07:00
Tushar Maheshwari
c1cbb41b42
Fix iPhone simulator CI (#981)
* Run iOS simulator CI

* Fix link errors

- scope function linkage using anonymous namespace

* Update noexcept test for consistency
2021-05-13 10:52:09 -07:00
Nicholas Guriev
d9fa328f89
Improve build script for standalone tests (#963)
* Require Git for build tests only if installed GTest is not found

Cloning via Git is not the only path to obtain Google Test framework. In Linux,
using a system package manager is the preferred way, and gtest can be installed
through APK, APT, DNF, pacman, or many other. Now we make Git mandatory after
checking GTest existence.

See also: https://github.com/microsoft/GSL/pull/961#discussion_r548959056

* Support standalone tests

The patch makes possible to run auto-tests against globally installed GSL,
ignoring local headers. To do this, run CMake in the tests/ folder.

    cmake -B build -S tests -DGSL_CXX_STANDARD=14

This feature should not break existing build recipes.

Co-authored-by: Nicholas Guriev <nicholas@guriev.su>
2021-01-08 10:55:59 -08:00
Jordan Maples [MSFT]
e427b02c89
Reintroduce CMake changes that were reverted in #966 (#967)
* [cmake] Adding options for INSTALL and TEST (#964)

* [cmake] Adding GSL_INSTALL option

Not all consumers of GSL automatically want to have this install logic.

It's good practice to gate install logic behind an option.
For an example look at magic_enum:
https://github.com/Neargye/magic_enum/blob/master/CMakeLists.txt

If the client wants to install GSL they still can. But they should ask
for it by overriding GSL_INSTALL.

* Update cmake/guidelineSupportLibrary.cmake

added nl@eof

* Update CMakeLists.txt

* Update CMakeLists.txt

Co-authored-by: Juan Ramos <juanr0911@gmail.com>
Co-authored-by: Jordan Maples [MSFT] <49793787+JordanMaples@users.noreply.github.com>

* missing config line restored by moving GNUInstallDirs back to main file

Co-authored-by: hdf89shfdfs <31327577+hdf89shfdfs@users.noreply.github.com>
Co-authored-by: Juan Ramos <juanr0911@gmail.com>
2021-01-05 11:55:13 -08:00
Jordan Maples [MSFT]
25bb4bd948
Revert "[cmake] Adding options for INSTALL and TEST (#964)" (#966)
This reverts commit eca0eca6f1.
2021-01-04 14:17:03 -08:00
Jordan Maples [MSFT]
1c509ad8e1
update gtest (#965) 2021-01-04 11:31:01 -08:00
hdf89shfdfs
eca0eca6f1
[cmake] Adding options for INSTALL and TEST (#964)
* [cmake] Adding GSL_INSTALL option

Not all consumers of GSL automatically want to have this install logic.

It's good practice to gate install logic behind an option.
For an example look at magic_enum:
https://github.com/Neargye/magic_enum/blob/master/CMakeLists.txt

If the client wants to install GSL they still can. But they should ask
for it by overriding GSL_INSTALL.

* Update cmake/guidelineSupportLibrary.cmake

added nl@eof

* Update CMakeLists.txt

* Update CMakeLists.txt

Co-authored-by: Juan Ramos <juanr0911@gmail.com>
Co-authored-by: Jordan Maples [MSFT] <49793787+JordanMaples@users.noreply.github.com>
2021-01-04 10:42:33 -08:00
hdf89shfdfs
d15cb5fdbe
Minor cmake changes (#961)
Abstract adding natvis file.

Move call to find_package(Git) as well as making it required/quiet.
2020-12-15 10:06:46 -08:00
Jordan Maples [MSFT]
a6cef6bc6c
remove multi_span (#958) 2020-12-09 15:18:07 -08:00
Jordan Maples [MSFT]
9150ce9a95
Adding std::hash<not_null<T>> tests to notnull_tests.cpp (#947)
* added std::hash<not_null> tests

* nl
2020-11-03 16:56:09 -08:00
Jordan Maples [MSFT]
a150aaa4ed
renaming main logic files. Added warning message of the removal and include passthrough. Renamed includes in the source files. Ran Clang-Format (#946)
Header rename
2020-10-29 17:38:48 -07:00
Pascal Menuet
c25a7544b8 Fix finally with mutable lvalue invokable 2020-08-14 16:24:10 +02:00
Jordan Maples
74968d3ef8 Merge branch 'master' into exception_fix_new_file 2020-08-12 17:14:13 -07:00
Jordan Maples [MSFT]
9355982fc5
Merge pull request #868 from mymedia2/master
Search for GoogleTest via pkg-config first
2020-08-12 15:08:54 -07:00
Jordan Maples
72ddfb7a40 created new file for gsl_narrow, might want to rename if we go this approach to have all exception prone logic to live here 2020-08-11 17:11:14 -07:00
Jordan Maples
72803a7ecb adding template type to the vector to suppress clang-10 warning that vector may not intend for type deduction. 2020-05-29 15:45:25 -07:00
Jordan Maples
4d2090ebc4 fixed typo 2020-05-29 10:54:13 -07:00
Jordan Maples
c4a2ce6cc8 wrapping string_view checks in deduction guide checks to prevent 'macro unused' errors 2020-05-29 10:53:30 -07:00
Casey Carter
c143a07f61 Add string_view test case and modify deduction guides 2020-05-28 18:00:40 -07:00
Jordan Maples
6c405a1b7f adding a test to verify that the additional ctad works 2020-05-28 17:18:08 -07:00
Jordan Maples [MSFT]
0dbdf322fa
Merge pull request #886 from JordanMaples/dev/jomaples/build_matrix
compiler support revision
2020-05-26 15:14:08 -07:00