Commit Graph

44 Commits

Author SHA1 Message Date
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
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
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]
6b23937baf remove move constructor for not_null. 2020-01-30 17:00:13 -08:00
Roelf-Jilling
81f56796a1 MSVC and CoreChecker warning suppression for tests to CMake
Suppress CppCoreCheck warnings on GTest macros.
Suppress CppCoreCheck advice to use the GSL
2020-01-16 11:49:15 +01:00
Roelf-Jilling
186f5d21c1 Move compiler warning suppression for tests from cpp files to CMake 2020-01-16 11:49:00 +01:00
Jordan Maples [MSFT]
f04907c2f6 added suppression for missing destructor override 2020-01-08 10:13:00 -08:00
Jordan Maples [MSFT]
40bc3c3f00 testing something 2019-12-20 13:32:14 -08:00
Jordan Maples [MSFT]
8577033f13 addressing comments 2019-12-19 14:05:02 -08:00
Jordan Maples [MSFT]
6c5c708877 change from string to char* 2019-12-12 16:48:59 -08:00
Jordan Maples [MSFT]
5099e8fa3e removed string_view for string in tests 2019-12-12 11:15:41 -08:00
Jordan Maples [MSFT]
4f6f05d463 changing text in notices & readme. adding terminate handler for tests 2019-12-12 10:55:26 -08:00
Jordan Maples
9a88262544 fixing suppression of gtest warnings for gcc 2019-12-06 16:03:47 -08:00
Jordan Maples [MSFT]
b39a9732f8 attempting to fix the gtest print issues in vs17 2019-12-04 13:46:50 -08:00
Jordan Maples [MSFT]
87eaa45445 suppressing -Wundef in clang (GTest emitted) 2019-12-04 12:48:13 -08:00
Jordan Maples [MSFT]
43aca2646b ignore warnings from gtest 2019-12-04 12:30:58 -08:00
Jordan Maples [MSFT]
2b10729386 gtest migration 2019-12-03 14:32:25 -08:00
B1Z0N
787e7ef616 Thanks to @stayprivates fixed out of bounds access in "TestNotNullostream" 2019-09-01 00:35:04 +03:00
Anna Gringauze
6418b5f4de
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 7263f3289e.

* 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:
bda3d6a428
97062933ac
0f4fb04bac
1b0c19afd1
a5739ea5f0

* 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 6fe1a42035.

* 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 3c1c0794dd

* 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 2238c4760e.

* Suppress -Winvalid-noreturn for the MS STL noexception workaround

* CMake: put preprocessor definition in target_compile_definitions

* Solve compiler warning C4668: __GNUC__ not defined
2019-01-15 10:27:34 -08:00
Anna Gringauze
9ff6e19ea9
Dev/annagrin/remove explicit not null constructor (#743)
* Added c++17 test configurations for clang5.0 and clang6.0

* Removed explicit not_null constructor, sloppy_not_null, added strict_not_null

We added explicit not_null constructor in version 2.0.0.
It proved very difficult to switch to the new version for
large code bases that adopted previous versions of gsl,
due to not_null used extensively in the code. Still, using
explicit constructor is very benefitial for new code, since
it encorages better API design and make null checks intentional.

To resolve the issue, this change:
- removes explicit keyword from not_null constructor
- removes unneded sloppy_not_null type
- adds strict_not_null type to behave the same way as v2 not_null
- updates tests

* Removed explicit not_null constructor, sloppy_not_null, added strict_not_null

We added explicit not_null constructor in version 2.0.0.
It proved very difficult to switch to the new version for
large code bases that adopted previous versions of gsl,
due to not_null used extensively in the code. Still, using
explicit constructor is very benefitial for new code, since
it encorages better API design and make null checks intentional.

To resolve the issue, this change:
- removes explicit keyword from not_null constructor
- removes unneded sloppy_not_null type
- adds strict_not_null type to behave the same way as v2 not_null
- updates tests

* fixed build break for gcc7

* added more tests

* added more non-compiling tests

* Addressed PR comments and suppressed a code analysis warning

* Fixed test failure in not_null tests
2019-01-14 16:45:47 -08:00
Anna Gringauze
6241b3faa6
Dev/annagrin/sloppy not null (#712)
* Added c++17 test configurations for clang5.0 and clang6.0

* added transition helper sloppy_not_null

* Moved gsl_transition to a samples folder

* Fixed build break and static analysis warnings
2018-08-13 09:55:48 -07:00
Anna Gringauze
831584d947
Dev/annagrin/make not null (#711)
* Added c++17 test configurations for clang5.0 and clang6.0

* Added make_not_null helper to create a not_null

Introduction of explicit not_null constructor made it cumbersome to create not_nulls
in c++14. Adding make_not_null helper. Usage (see tests):

int i = 42;

auto x = make_not_null(&i);
helper(make_not_null(&i));
helper_const(make_not_null(&i));

* Added std::forward to make_not_null, fixed some code analysis warnings

* Fix build break in VS2015 Release configuration

* Fix build break in VS2015 Release configuration
2018-08-13 02:22:02 -07:00
Anna Gringauze
cea0d0ac2b fix cppcorecheck warnings (#703)
* Added c++17 test configurations for clang5.0 and clang6.0

* Fixed CppCoreCheck warnings in GSL and tests

- Added CMakeSettings.json for VS Open Folder configuration
	- So we can easily run CppCoreCheck in VS
- Fixed CppCorecheck warnings where it made sense
- Suppressed the rest
	- Some suppression does not work due to compiler/tool bugs,
          so replaced by #pragma disable
	- CppCoreCheck has noise, suppressed those with comments
	- Catch produces many warnings, blanket-supressed them all
- Had to fix clang formatting to keep attributes in place
	- clang-format does not support attributes, so I am using
        - "CommentPragmas: '^ NO-FORMAT:'" to skip formatiting on them
- Removed GSL_NOEXCEPT macro, removed incorred noexcepts

* Ignore unknown attributes

* ignore unknown attributes in noexception mode tests

* fixed C26472 in at()

* created GSL_SUPPRESS macro to allow all compilers to parse suppression attributes

* try to fix gcc compilation problems with attributes

* ignore gsl::suppress for gcc

* move suppression to function level on return statements

clang5.0 and up does not allow attributes on return statemets in constexpr functions

* move suppression to function level on return statements

* use GSL_SUPPRESS in algorithm_tests

* Addressed PR comments
2018-08-12 21:44:17 -07:00
Anna Gringauze
cb2d1af89a
Added template argument deduction for not_null (#689)
* Added template  argument deduction for not_null

This allows compilers with c++17 support to infer template
instantiation types when calling not_null constructor:

    int foo(not_null<const int*> x);

    int main()
    {
        int t = 0;
        not_null x{ &t };
        return foo(not_null{ &t });
    }

* replaced deduction guides by a simple constructor

* Updated tests

* fixed check for availability of std::byte

* testing c++1z on clang

* fixed cmakelists extra endif

* include cstddef header for clang and gcc in pointers

* fixed a typo

* fix missing nullptr_t type

* fixed typo in CMakeLists.tst

* change approach to c++17 testing, step one: revert cmake testing, update clang5.0 package

removed using latest c++ due to clang5.0 failing,
update clang5.0 travis config to use llvm-toolchain-trusty-5.0

* addressed comments
2018-06-07 13:36:56 -07:00
ericLemanissier
2fc94db3eb not_null constructor is now explicit (#659)
solves #395
2018-04-24 19:11:43 -07:00
Zac Hansen
ed3693fd2e make explicit not_null move constructor so it is noexcept (#630)
* make explicit not_null move constructor so it is noexcept

* added test for not_null being noexcet move constructible
2018-03-03 15:53:23 -08:00
menete
ac91ac1408 add throw on nullptr CTOR test (#577) 2018-02-12 09:31:09 -08:00
Tiago
0d33bf6794 Applied iwyu --comment to the code base (#588) 2017-11-28 07:13:49 -08:00
menete
2ad93a38dd Iosfwd (#586)
* Solves #567 with <iosfwd> approach

* adds a little testing to not_null ostream
2017-11-14 08:14:20 -08:00
Tiago
4862a270b9 Move GSL pointers to a separate header (#566) 2017-10-31 10:19:12 -07:00
Neil MacIntosh
b2ee484334 Move from unittest-cpp to catch for unit testing. (#533)
Many thanks to @rianquinn. This should fix #495, #494 and #529.
2017-07-13 13:53:56 -07:00
Alexey Malov
247c4250d4 Fixes dereferencing operator issue #517 introduced in PR #513 (#516)
* Fixes issue with dereferencing operator issue #491 introduced in PR #513

dereferencing operator added in PR#513 returned a copy of the object
instead of reference to it.
Adding decltype(auto) as return type of operator* fixes this issue.

* added more tests for not_null::operator*
2017-05-31 11:18:55 -07:00
saurabh singh
23581d4d63 Adding derference operator to not_null (#513) 2017-05-30 10:06:21 -07:00
Tiago
ebe7ebfd85 Reformat files to follow clang-format style (#492)
Project files were not following the clang-format style. For people
using IDEs were clang-format is always run after a save this would
cause unwanted changes.

This commit only applies "clang-format -i" to files.
2017-04-20 07:51:37 -07:00
Alexey Malov
534bb4c663 Added support of not_null<smart_ptr> comparison (#473)
* Added support of not_null<smart_ptr> comparison

* The return type of not_null comparison operators is determined using SFINAE
#474

* tests for gsl::not_null comparison were added

* not_null comparison tests were rewritten to compare pointers to objects located in the same array

* not_null<shared_ptr> comparison was simplified
2017-04-12 17:34:39 -07:00
Rian Quinn
d641796b21 Cleanup additional GCC warnings
When turning on the following flags, several additional warnings
were generated, which have been cleaned up in this patch. The
flags included:

-Wextra
-Wpedantic
-Wconversion
-Wsign-conversion
-Wctor-dtor-privacy
-Wshadow
-Wnon-virtual-dtor
-Wold-style-cast
-Wcast-align
-Woverloaded-virtual
2016-11-03 18:38:32 -07:00
Galik
222c2d85fd Removed .h extension from header files. 2016-08-10 17:24:00 +01:00
galik
f6cc5798a1 Renamed include/ folder to gsl/ to make including the library consistent
whether using it from the development folder, from the installation
folder or from being copied into a project. 

    #include <gsl/gsl.h>

Updated headers/tests/instructions/cmake build accordingly

This PR should address https://github.com/Microsoft/GSL/issues/277 (less
the renaming of gsl itself)
2016-08-09 15:04:58 +01:00
Neil MacIntosh
fa056f67e8 Enabled -Wall for gcc and clang. 2015-11-13 03:27:53 +00:00
Neil MacIntosh
ef626fd33a Renamed namespace to 'gsl'. Renamed macro to configure testing. 2015-09-29 16:41:37 -07:00
Kern Handa
783eaabf9d Add various copy assignment operators to not_null and maybe_null_*.
Also removed unused constant member variable that seemed to be there
to prevent maybe_null_* being used with anything other than a pointer,
which is being taken care of with a static_assert now.
2015-09-28 07:35:18 +00:00
Kern Handa
2b6d90436f not_null and maybe_null variants should only work on nullptr-assignable types.
This is in accordance with the GSL.View guidance on not_null and maybe_null
types in the CppCoreGuidelines document.
2015-09-27 19:35:23 +00:00
Neil MacIntosh
a9dcbe04ff Initial commit of library files. 2015-08-20 18:09:14 -07:00