llvm-project/clang-tools-extra/clang-tidy/cppcoreguidelines
Jonas Toth 6ccc1c342a [clang-tidy] Implement type-based check for `gsl::owner`
This check implements the typebased semantic of `gsl::owner`.
Meaning, that 
- only `gsl::owner` is allowed to get `delete`d
- `new` expression must be assigned to `gsl::owner`
- function calls that expect `gsl::owner` as argument, must get either an owner
  or a newly created and recognized resource (in the moment only `new`ed memory)
- assignment to `gsl::owner` must be either a resource or another owner
- functions returning an `gsl::owner` are considered as factories, and their result
  must be assigned to an `gsl::owner`
- classes that have an `gsl::owner`-member must declare a non-default destructor

There are some problems that occur when typededuction is in place.
For example `auto Var = function_that_returns_owner();` the type of `Var` will not be
an `gsl::owner`. This case is catched, and explicitly noted.

But cases like fully templated functions
```
template <typename T> 
void f(T t) { delete t; }
// ...
f(gsl::owner<int*>(new int(42)));
```
Will created false positive (the deletion is problematic), since the type deduction
removes the wrapping `typeAlias`.

Codereview in D36354

llvm-svn: 313067
2017-09-12 20:00:42 +00:00
..
CMakeLists.txt [clang-tidy] Implement type-based check for `gsl::owner` 2017-09-12 20:00:42 +00:00
CppCoreGuidelinesTidyModule.cpp [clang-tidy] Implement type-based check for `gsl::owner` 2017-09-12 20:00:42 +00:00
InterfacesGlobalInitCheck.cpp [clang-tidy] cppcoreguidelines-interfaces-global-init 2016-04-08 09:51:06 +00:00
InterfacesGlobalInitCheck.h [clang-tidy] cppcoreguidelines-interfaces-global-init 2016-04-08 09:51:06 +00:00
NoMallocCheck.cpp [clang-tidy] test commit for granted access 2017-08-30 07:50:28 +00:00
NoMallocCheck.h Spelling mistakes in comments. NFCI. 2017-03-30 13:10:33 +00:00
OwningMemoryCheck.cpp [clang-tidy] Implement type-based check for `gsl::owner` 2017-09-12 20:00:42 +00:00
OwningMemoryCheck.h [clang-tidy] Implement type-based check for `gsl::owner` 2017-09-12 20:00:42 +00:00
ProBoundsArrayToPointerDecayCheck.cpp Reverting r298421 due to using a header that's unavailable to all systems and some other post-commit review feedback. 2017-03-22 01:08:54 +00:00
ProBoundsArrayToPointerDecayCheck.h [clang-tidy] remove trailing whitespaces and retab 2016-08-01 12:06:18 +00:00
ProBoundsConstantArrayIndexCheck.cpp [clang-tidy] Unify the way IncludeStyle and HeaderFileExtesions options are used 2017-07-20 12:02:03 +00:00
ProBoundsConstantArrayIndexCheck.h [clang-tidy] Cleanup namespace in utils folder. 2016-05-03 02:54:05 +00:00
ProBoundsPointerArithmeticCheck.cpp [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
ProBoundsPointerArithmeticCheck.h [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
ProTypeConstCastCheck.cpp [clang-tidy] remove trailing whitespaces and retab 2016-08-01 12:06:18 +00:00
ProTypeConstCastCheck.h [clang-tidy] remove trailing whitespaces and retab 2016-08-01 12:06:18 +00:00
ProTypeCstyleCastCheck.cpp [clang-tidy] Cleaning up language options. 2016-09-24 02:13:45 +00:00
ProTypeCstyleCastCheck.h [clang-tidy] Cleaning namespaces to be more consistant across checkers. 2016-05-02 18:00:29 +00:00
ProTypeMemberInitCheck.cpp [cppcoreguidelines] Don't rely on SmallPtrSet iteration order. 2017-08-30 20:18:40 +00:00
ProTypeMemberInitCheck.h Fix some false-positives with cppcoreguidelines-pro-type-member-init. Handle classes with default constructors that are defaulted or are not present in the AST. 2016-10-04 14:48:05 +00:00
ProTypeReinterpretCastCheck.cpp [clang-tidy] Cleaning namespaces to be more consistant across checkers. 2016-05-02 18:00:29 +00:00
ProTypeReinterpretCastCheck.h [clang-tidy] Cleaning namespaces to be more consistant across checkers. 2016-05-02 18:00:29 +00:00
ProTypeStaticCastDowncastCheck.cpp [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
ProTypeStaticCastDowncastCheck.h [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
ProTypeUnionAccessCheck.cpp [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
ProTypeUnionAccessCheck.h [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
ProTypeVarargCheck.cpp [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
ProTypeVarargCheck.h [clang-tidy] Cleaning namespaces to be more consistant across checkers. 2016-05-02 18:00:29 +00:00
SlicingCheck.cpp [clang-tidy] cppcoreguidelines-slicing: display discarded state size in bytes 2016-12-22 14:12:31 +00:00
SlicingCheck.h Revert "Revert "[clang-tidy] new cppcoreguidelines-slicing"" 2016-07-22 13:45:00 +00:00
SpecialMemberFunctionsCheck.cpp Don't make unqualified calls to functions that could well be found via 2017-03-21 20:15:42 +00:00
SpecialMemberFunctionsCheck.h Apply clang-tidy's performance-unnecessary-value-param to clang-tidy. 2017-03-21 21:34:58 +00:00