- Flag pointer arithmetic (including ++) on a pointer that is not part of a container, view, or iterator. This rule would generate a huge number of false positives if applied to an older code base.
- Flag array names passed as simple pointers
clang-tidy: cppcoreguidelines-pro-bounds-
- (Simple) Warn on delete of a raw pointer that is not an owner.
- (Moderate) Warn on failure to either reset or explicitly delete an owner pointer on every code path.
- (Simple) Warn if the return value of new is assigned to a raw pointer.
- (Simple) Warn if a function returns an object that was allocated within the function but has a move constructor. Suggest considering returning it by value instead.
clang-tidy: cppcoreguidelines-owning-memory
TODO: owning reference are not handled right now
core-check: C26402 DONT_HEAP_ALLOCATE_MOVABLE_RESULT, C26403 RESET_OR_DELETE_OWNER, C26404 DONT_DELETE_INVALID, C26405 DONT_ASSIGN_TO_VALID, C26406 DONT_ASSIGN_RAW_TO_OWNER
- (Moderate) Warn if an object is allocated and then deallocated on all paths within a function. Suggest it should be a local auto stack object instead.
- (Simple) Warn if a local Unique_ptr or Shared_ptr is not moved, copied, reassigned or reset before its lifetime ends.
core-check: C26407 DONT_HEAP_ALLOCATE_UNNECESSARILY, C26414 RESET_LOCAL_SMART_PTR
- (??? NM: Obviously we can warn about non-const statics ... do we want to?)
no enforcement
- Flag explicit use of malloc and free.
clang-tidy: cppcoreguidelines-no-malloc
core-check: C26408 NO_MALLOC_FREE
- (Simple) Warn on any explicit use of new and delete. Suggest using make_unique instead.
clang-tidy: cppcoreguidelines-owning-memory
core-check: C26409 NO_NEW_DELETE
- Flag explicit allocations used to initialize pointers (problem: how many direct resource allocations can we recognize?)
clang-tidy: cppcoreguidelines-owning-memory
- Flag expressions with multiple explicit resource allocations (problem: how many direct resource allocations can we recognize?)
no enforcement
- Flag incomplete pairs.
clang-tidy: misc-new-delete-overloads
- (Simple) Warn if the return value of new or a function call with return value of pointer type is assigned to a raw pointer.
clang-tidy: cppcoreguidelines-owning-memory, modernize-make_unique, modernize-make-shared
- (Simple) Warn if a function uses a Shared_ptr with an object allocated within the function, but never returns the Shared_ptr or passes it to a function requiring a Shared_ptr&. Suggest using unique_ptr instead.
no enforcement
- (Simple) Warn if a shared_ptr is constructed from the result of new rather than make_shared.
clang-tidy: modernize-make-shared
(Simple) Warn if a unique_ptr is constructed from the result of new rather than make_unique.
clang-tidy: modernize-make-unique
- (Simple) Warn if a function takes a parameter of a smart pointer type (that overloads operator-> or operator*) that is copyable but the function only calls any of: operator*, operator-> or get(). Suggest using a T* or T& instead.
- Flag a parameter of a smart pointer type (a type that overloads operator-> or operator*) that is copyable/movable but never copied/moved from in the function body, and that is never modified, and that is not passed along to another function that could do so. That means the ownership semantics are not used. Suggest using a T* or T& instead.
core-check: C26415 SMART_PTR_NOT_NEEDED
- (Simple) Warn if a function takes a Unique_ptr parameter by lvalue reference and does not either assign to it or call reset() on it on at least one code path. Suggest taking a T* or T& instead.
- (Simple) ((Foundation)) Warn if a function takes a Unique_ptr parameter by reference to const. Suggest taking a const T* or const T& instead.
core-check: C26410 NO_REF_TO_CONST_UNIQUE_PTR
- (Simple) Warn if a function takes a Unique_ptr parameter by lvalue reference and does not either assign to it or call reset() on it on at least one code path. Suggest taking a T* or T& instead.
- (Simple) ((Foundation)) Warn if a function takes a Unique_ptr parameter by reference to const. Suggest taking a const T* or const T& instead.
core-check: C26411 NO_REF_TO_UNIQUE_PTR
- (Simple) Warn if a function takes a Shared_ptr parameter by lvalue reference and does not either assign to it or call reset() on it on at least one code path. Suggest taking a T* or T& instead.
- (Simple) ((Foundation)) Warn if a function takes a Shared_ptr by value or by reference to const and does not copy or move it to another Shared_ptr on at least one code path. Suggest taking a T* or T& instead.
- (Simple) ((Foundation)) Warn if a function takes a Shared_ptr by rvalue reference. Suggesting taking it by value instead.
core-check: C26416 NO_RVALUE_REF_SHARED_PTR
- (Simple) Warn if a function takes a Shared_ptr parameter by lvalue reference and does not either assign to it or call reset() on it on at least one code path. Suggest taking a T* or T& instead.
- (Simple) ((Foundation)) Warn if a function takes a Shared_ptr by value or by reference to const and does not copy or move it to another Shared_ptr on at least one code path. Suggest taking a T* or T& instead.
- (Simple) ((Foundation)) Warn if a function takes a Shared_ptr by rvalue reference. Suggesting taking it by value instead.
core-check: C26417 NO_LVALUE_REF_SHARED_PTR
R.36: Take a const shared_ptr& parameter to express that it might retain a reference count to the object ???
- (Simple) Warn if a function takes a Shared_ptr parameter by lvalue reference and does not either assign to it or call reset() on it on at least one code path. Suggest taking a T* or T& instead.
- (Simple) ((Foundation)) Warn if a function takes a Shared_ptr by value or by reference to const and does not copy or move it to another Shared_ptr on at least one code path. Suggest taking a T* or T& instead.
- (Simple) ((Foundation)) Warn if a function takes a Shared_ptr by rvalue reference. Suggesting taking it by value instead.
core-check: C26418 NO_VALUE_OR_CONST_REF_SHARED_PTR
- (Simple) Warn if a pointer or reference obtained from a smart pointer variable (Unique_ptr or Shared_ptr) that is nonlocal, or that is local but potentially aliased, is used in a function call. If the smart pointer is a Shared_ptr then suggest taking a local copy of the smart pointer and obtain a pointer or reference from that instead.
no enforcement