Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixing #1151

Open
wants to merge 69 commits into
base: dmitrykobets-msft/experiment/fix-span-2020-gtest-failures
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
bcf008a
Fix/implement C++2020 compilation, tests, and CI (#1017)
dmitrykobets-msft Dec 9, 2021
c412deb
Update compiler support (#1019)
dmitrykobets-msft Dec 10, 2021
ebf0498
Update compiler support (#1021)
dmitrykobets-msft Jan 6, 2022
99a29ce
Document safe usage of undefined behavior in gsl::narrow (#1024)
dmitrykobets-msft Jan 27, 2022
a353456
Fixed wrong version number in exported CMake configs. (#1027)
xvitaly Jan 28, 2022
4377f6e
quoted form of #include when GSL includes GSL files (#1030)
beinhaerter Jan 31, 2022
f22f524
Suppress reserved identifier warning (#1041)
dmitrykobets-msft Mar 22, 2022
3837236
Make gsl::span's iterators use the contiguous_iterator concept (#1035)
dmitrykobets-msft Mar 22, 2022
2bfd495
Suppress -Wfloat-equal warning in implementation of gsl::narrow (#1043)
dmitrykobets-msft Apr 14, 2022
f21f29d
gsl/narrow should include <exception> (#1044)
TheJCAB Apr 26, 2022
7fefaaf
Fix reason for including assert inside gsl/narrow (#1045)
dmitrykobets-msft Apr 28, 2022
d8c493c
Suppress es.46 warning in implementation of gsl::narrow (#1046)
dmitrykobets-msft Apr 28, 2022
da01eb2
Remove useless runtime checks in span implementation (#1029)
dmitrykobets-msft Apr 28, 2022
d9fc52e
Microsoft mandatory file (#1047)
microsoft-github-policy-service[bot] May 23, 2022
330583f
Resolve MSVC warning C5260 (#1049)
dmitrykobets-msft Jul 19, 2022
2e94541
Use updated NDK version in android test suite (#1053)
dmitrykobets-msft Aug 17, 2022
10df83d
solve span compile problem with gcc 5.5.0 (#1052)
beinhaerter Aug 18, 2022
1683d87
Fix NDK version in Android CI (#1054)
dmitrykobets-msft Sep 28, 2022
849f7ce
Fix Clang-tidy 15 warnings (#1058)
AtariDreams Oct 6, 2022
7d49d4b
Clean up `final_act` and `finally`, closes #846 (#977)
hsutter Oct 10, 2022
991fa66
Prevent inefficient copying when using not_null::get (#1059)
dmitrykobets-msft Oct 11, 2022
c52bad3
CMake cleanup (#1060)
jpr42 Oct 18, 2022
1e0d044
README.md: fixed a typo (#1062)
eli-b Oct 24, 2022
9c4212a
Raise CMake min to 3.8 (#1061)
jpr42 Oct 29, 2022
d69e578
clang-tidy: performance-noexcept-move-constructor (#1063)
jpr42 Nov 1, 2022
517ed29
Fix GSL_SUPPRESS definition when nvcc is in-use (#1064)
snnn Nov 7, 2022
f3620bb
Suppress false postive warning (#1068)
dmitrykobets-msft Dec 14, 2022
6c6111a
Remove null check inside not_null::get (#1067)
dmitrykobets-msft Dec 15, 2022
46c7271
Document potentially confusing behavior in gsl::narrow (#1073)
dmitrykobets-msft Dec 24, 2022
c016bdc
remove all deprecated string_span stuff (#1074)
beinhaerter Dec 27, 2022
ac26d7b
cleanup natvis (#1077)
beinhaerter Dec 29, 2022
f94c1f6
use code spans in README.md (#1078)
beinhaerter Dec 29, 2022
0822838
Add Linguist language override for include files (#1079)
gerlero Jan 6, 2023
a381a37
1075 Wrong Expects in gsl::at? (#1076)
beinhaerter Jan 18, 2023
cbf5e66
Fix `max` macro collision (#1081)
dmitrykobets-msft Jan 19, 2023
f7da2e4
Raise CMake min to 3.14 (#1083)
jpr42 Feb 6, 2023
49c88f2
add not_null and strict_not_null tests for const (#1085)
beinhaerter Feb 6, 2023
3ba80d5
simplify to_byte (#1090)
beinhaerter Feb 14, 2023
7439397
Documentation (#1086)
beinhaerter Feb 17, 2023
9851b94
add some span test for constructor from other span (#1093)
beinhaerter Feb 17, 2023
7a297d4
Extend docs and tests for span ctor (#1096)
beinhaerter Feb 21, 2023
7f7108a
Better links to CoreGuidelines (#1094)
beinhaerter Feb 22, 2023
78eb6ca
Document span_ext (#1098)
dmitrykobets-msft Feb 23, 2023
9f85e4e
minor docs improvements (#1097)
beinhaerter Feb 23, 2023
b080081
Add missing link to documentation
dmitrykobets-msft Feb 27, 2023
50d6eef
Add `span_iterator::_Prevent_inheriting_unwrap`. (#1100)
StephanTLavavej Mar 14, 2023
43d60c5
Suppress warning C26481 (#1099)
beinhaerter Mar 14, 2023
1d03658
Add testcase for #1100 (#1101)
dmitrykobets-msft Mar 30, 2023
9face82
Remove unnecessary check from size_bytes() (#1105)
dmitrykobets-msft May 9, 2023
5dc7fae
Use the implementation-defined strict total order for pointer compari…
dmitrykobets-msft May 9, 2023
4b5b5a1
Disable std::hash<gsl::not_null<T>> if std::hash<T> is not enabled. (…
dmitrykobets-msft May 10, 2023
afaaa71
Install GSL.natvis (#1112)
jpr42 May 11, 2023
303d964
Deprecate the Ptr make_span overloads (#1113)
dmitrykobets-msft May 22, 2023
65a5995
Remove deprecated headers (#1124)
dmitrykobets-msft Jun 28, 2023
3549e31
Deprecate `<gsl/string_span>` and replace with `<gsl/zstring>` (#1125)
dmitrykobets-msft Jun 28, 2023
87e2140
remove gcc noexcept warning (#1122)
beinhaerter Jun 28, 2023
167c77d
add missing include (#1126)
beinhaerter Jul 4, 2023
b34f735
get back gcc 8.4 compatibility (#1127)
beinhaerter Jul 6, 2023
4300304
Remove unused macros (#1128)
dmitrykobets-msft Jul 26, 2023
9695da9
fix and optimize documentation (#1131)
beinhaerter Sep 5, 2023
2940006
Suppress some noisy / buggy warnings (#1136)
dmitrykobets-msft Sep 11, 2023
52212c2
Update Clang GSL_SUPPRESS to stringize parameter instead of using fix…
edgchen1 Sep 11, 2023
e64c97f
Mark not_null constructors as noexcept when underlying type can be mo…
mymedia2 Oct 18, 2023
77b2f4f
Fix some typos. (#1143)
waywardmonkeys Jan 17, 2024
f1a494c
ci: Update to `actions/checkout@v4`. (#1142)
waywardmonkeys Jan 17, 2024
caae4dd
Fix some typos. (#1146)
waywardmonkeys Feb 21, 2024
1b4d42c
Fix initialization in test (#1140)
d-winsor Feb 26, 2024
2e0d1ba
Test only `__cpp_lib_byte`, drop `_HAS_STD_BYTE`. (#1145)
StephanTLavavej Feb 26, 2024
b39e7e4
Add documentation for to_integer(byte) (#1144)
beinhaerter Feb 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include/gsl/* linguist-language=C++
4 changes: 2 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
run:
working-directory: build
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Create build directory
run: mkdir -p build
Expand All @@ -29,7 +29,7 @@ jobs:
echo "Emulator starting"

- name: Configure
run: cmake -Werror=dev -DCMAKE_TOOLCHAIN_FILE=$ANDROID_HOME/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=16 -DANDROID_ABI=x86_64 -DCMAKE_BUILD_TYPE=Debug ..
run: cmake -Werror=dev -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_LATEST_HOME/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=16 -DANDROID_ABI=x86_64 -DCMAKE_BUILD_TYPE=Debug ..

- name: Build
run: cmake --build . --parallel
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/cmake_find_package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: cmake_find_package
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
cmake-find-package:
name: Build ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
steps:
- uses: actions/checkout@v4
- uses: lukka/get-cmake@latest
with:
cmakeVersion: 3.14.0
- name: Configure GSL
run: cmake -S . -B build -G "Ninja" -D GSL_TEST=OFF -D CMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/build/install
- name: Install GSL
run: cmake --build build --target install
- name: Test GSL find_package support
run: cmake -S tests/ -B build/tests_find_package -G "Ninja" -D CMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/build/install -D CMAKE_BUILD_TYPE=Release
2 changes: 1 addition & 1 deletion .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
run:
working-directory: build
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Create build directory
run: mkdir -p build
Expand Down
77 changes: 32 additions & 45 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,61 +1,48 @@
cmake_minimum_required(VERSION 3.1.3...3.16)
cmake_minimum_required(VERSION 3.14...3.16)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
include(guidelineSupportLibrary)
project(GSL VERSION 4.0.0 LANGUAGES CXX)

project(GSL
VERSION 3.1.0
LANGUAGES CXX
)

# Must include after the project call due to GNUInstallDirs requiring a language be enabled (IE. CXX)
include(GNUInstallDirs)

# Creates a library GSL which is an interface (header files only)
add_library(GSL INTERFACE)

# NOTE: If you want to use GSL prefer to link against GSL using this alias target
# EX:
# target_link_libraries(foobar PRIVATE Microsoft.GSL::GSL)
#
# Add Microsoft.GSL::GSL alias for GSL so that dependents can be agnostic about
# whether GSL was added via `add_subdirectory` or `find_package`
add_library(Microsoft.GSL::GSL ALIAS GSL)

# Determine whether this is a standalone project or included by other projects
set(GSL_STANDALONE_PROJECT OFF)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(GSL_STANDALONE_PROJECT ON)
endif()

### Project options
option(GSL_INSTALL "Generate and install GSL target" ${GSL_STANDALONE_PROJECT})
option(GSL_TEST "Build and perform GSL tests" ${GSL_STANDALONE_PROJECT})
# https://cmake.org/cmake/help/latest/variable/PROJECT_IS_TOP_LEVEL.html
string(COMPARE EQUAL ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} PROJECT_IS_TOP_LEVEL)

# This GSL implementation generally assumes a platform that implements C++14 support.
set(gsl_min_cxx_standard "14")
option(GSL_INSTALL "Generate and install GSL target" ${PROJECT_IS_TOP_LEVEL})
option(GSL_TEST "Build and perform GSL tests" ${PROJECT_IS_TOP_LEVEL})

if (GSL_STANDALONE_PROJECT)
gsl_set_default_cxx_standard(${gsl_min_cxx_standard})
else()
gsl_client_set_cxx_standard(${gsl_min_cxx_standard})
endif()
# The implementation generally assumes a platform that implements C++14 support
target_compile_features(GSL INTERFACE "cxx_std_14")

# Setup include directory
add_subdirectory(include)

# Add natvis file
gsl_add_native_visualizer_support()

# Add packaging support
gsl_create_packaging_file()

if (GSL_INSTALL)
# Setup install/export logic
gsl_install_logic()
endif()
target_sources(GSL INTERFACE $<BUILD_INTERFACE:${GSL_SOURCE_DIR}/GSL.natvis>)

if (GSL_TEST)
enable_testing()
add_subdirectory(tests)
endif()

if (GSL_INSTALL)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/gsl" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

set(export_name "Microsoft.GSLConfig")
set(namespace "Microsoft.GSL::")
set(cmake_files_install_dir ${CMAKE_INSTALL_DATADIR}/cmake/Microsoft.GSL)

install(TARGETS GSL EXPORT ${export_name} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(EXPORT ${export_name} NAMESPACE ${namespace} DESTINATION ${cmake_files_install_dir})
export(TARGETS GSL NAMESPACE ${namespace} FILE ${export_name}.cmake)

set(gls_config_version "${CMAKE_CURRENT_BINARY_DIR}/Microsoft.GSLConfigVersion.cmake")

write_basic_package_version_file(${gls_config_version} COMPATIBILITY SameMajorVersion ARCH_INDEPENDENT)

install(FILES ${gls_config_version} DESTINATION ${cmake_files_install_dir})

install(FILES GSL.natvis DESTINATION ${cmake_files_install_dir})
endif()
35 changes: 4 additions & 31 deletions GSL.natvis
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@
vim: syntax=xml
-->
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<!-- These types are from the gsl_assert header. -->
<Type Name="gsl::fail_fast">
<!-- na hides the address, otherwise it would appear as 0x.... "Message" -->
<DisplayString>{_Data._What,nasb}</DisplayString>
</Type>

<!-- These types are from the gsl_util header. -->
<!-- These types are from the util header. -->
<Type Name="gsl::final_action&lt;*&gt;">
<DisplayString>{{ invoke = {invoke_}, action = {f_} }}</DisplayString>
<Expand>
Expand All @@ -19,7 +13,8 @@
</Expand>
</Type>

<Type Name="gsl::span&lt;*, *&gt;">
<!-- These types are from the span header. -->
<Type Name="gsl::span&lt;*, *&gt;">
<DisplayString>{{ extent = {storage_.size_} }}</DisplayString>
<Expand>
<ArrayItems>
Expand All @@ -29,29 +24,7 @@
</Expand>
</Type>

<Type Name="gsl::basic_string_span&lt;*, *&gt;">
<DisplayString>{span_.storage_.data_,[span_.storage_.size_]na}</DisplayString>
<Expand>
<Item Name="[size]">span_.storage_.size_</Item>
<ArrayItems>
<Size>span_.storage_.size_</Size>
<ValuePointer>span_.storage_.data_</ValuePointer>
</ArrayItems>
</Expand>
</Type>

<Type Name="gsl::basic_zstring_span&lt;*, *&gt;">
<DisplayString>{span_.storage_.data_,[span_.storage_.size_]na}</DisplayString>
<Expand>
<Item Name="[size]">span_.storage_.size_</Item>
<ArrayItems>
<Size>span_.storage_.size_</Size>
<ValuePointer>span_.storage_.data_</ValuePointer>
</ArrayItems>
</Expand>
</Type>

<!-- These types are from the gsl header. -->
<!-- These types are from the pointers header. -->
<Type Name="gsl::not_null&lt;*&gt;">
<!-- We can always dereference this since it's an invariant. -->
<DisplayString>value = {*ptr_}</DisplayString>
Expand Down