Skip to content

Latest commit

 

History

History
83 lines (49 loc) · 4.83 KB

interfaces.md

File metadata and controls

83 lines (49 loc) · 4.83 KB
  • (Simple) A function should not make control-flow decisions based on the values of variables declared at namespace scope.
  • (Simple) A function should not write to variables declared at namespace scope.

no enforcement

  • (Simple) Report all non-const variables declared at namespace scope.

no enforcement

  • (Simple) Report the use of void* as a parameter or return type.
  • (Hard to do well) Look for member functions with many built-in type arguments.

no enforcement

  • (Not yet enforceable) A language facility is under specification. When the language facility is available, warn if any non-variadic template parameter is not constrained by a concept (in its declaration or mentioned in a requires clause).

Concepts are on the way to be standardized, clang are implementing them, soon.

no enforcement

  • (Simple) Warn on delete of a raw pointer that is not an owner. Suggest use of standard-library resource handle or use of owner.
  • (Simple) Warn on failure to either reset or explicitly delete an owner pointer on every code path.
  • (Simple) Warn if the return value of new or a function call with an owner return value is assigned to a raw pointer or non-owner reference.

partial enforcement
clang-tidy: cppcoreguidelines-owning-memory

core-check: C26400  NO_RAW_POINTER_ASSIGNMENT,C26400  NO_RAW_POINTER_ASSIGNMENT

  • (Simple) ((Foundation)) If a function checks a pointer parameter against nullptr before access, on all control-flow paths, then warn it should be declared not_null.
  • (Complex) If a function with pointer return value ensures it is not nullptr on all return paths, then warn the return type should be declared not_null.

no enforcement

  • (Simple) ((Bounds)) Warn for any expression that would rely on implicit conversion of an array type to a pointer type. Allow exception for zstring/czstring pointer types.
  • (Simple) ((Bounds)) Warn for any arithmetic operation on an expression of pointer type that results in a value of pointer type. Allow exception for zstring/czstring pointer types.

clang-tidy: cppcoreguidelines-pro-bounds-array-to-pointer-decay, cppcoreguidelines-pro-bounds-pointer-arithmetic

  • Flag initializers of globals that call non-constexpr functions
  • Flag initializers of globals that access extern objects

core-check: C26426 NO_GLOBAL_INIT_CALLS, C26427 NO_GLOBAL_INIT_EXTERNS

  • Warn when a function declares two iterators (including pointers) of the same type instead of a range or a view.
  • (Not enforceable) This is a philosophical guideline that is infeasible to check directly.

TODO: alias into cppcoreguidelines?
clang-tidy: readability-function-size

  • (Simple) Warn if two consecutive parameters share the same type.

no enforcement

  • (Simple) Warn if a pointer/reference to a class C is assigned to a pointer/reference to a base of C and the base class contains data members.

no enforcement