clang-tools 22.0.0git
clang::tidy::cppcoreguidelines Namespace Reference

Classes

struct  AssignmentPair
class  AvoidCapturingLambdaCoroutinesCheck
 Flags C++20 coroutine lambdas with non-empty capture lists that may cause use-after-free errors and suggests avoiding captures or ensuring the lambda closure object has a guaranteed lifetime. More...
class  AvoidConstOrRefDataMembersCheck
 Const-qualified or reference data members in classes should be avoided, as they make the class non-copy-assignable. More...
class  AvoidDoWhileCheck
 do-while loops are less readable than plan while loops, and can lead to subtle bugs. More...
class  AvoidGotoCheck
 The usage of goto for control flow is error prone and should be replaced with looping constructs. More...
class  AvoidNonConstGlobalVariablesCheck
 Non-const global variables hide dependencies and make the dependencies subject to unpredictable changes. More...
class  AvoidReferenceCoroutineParametersCheck
 Warns on coroutines that accept reference parameters. More...
class  CppCoreGuidelinesModule
 A module containing checks of the C++ Core Guidelines. More...
class  InitVariablesCheck
 Find uninitialized local variables. More...
class  InterfacesGlobalInitCheck
 Flags possible initialization order issues of static variables. More...
class  MacroUsageCheck
 Find macro usage that is considered problematic because better language constructs exist for the task. More...
class  MisleadingCaptureDefaultByValueCheck
 Warns when lambda specify a by-value capture default and capture this. More...
class  MissingStdForwardCheck
 Warns when a function accepting a forwarding reference does anything besides forwarding (with std::forward) the parameter in the body of the function. More...
class  NoMallocCheck
 This checker is concerned with C-style memory management and suggest modern alternatives to it. More...
class  NoSuspendWithLockCheck
 Flag coroutines that suspend while any lock guard is alive. More...
class  OwningMemoryCheck
 Checks for common use cases for gsl::owner and enforces the unique owner nature of it whenever possible. More...
class  PreferMemberInitializerCheck
 Finds member initializations in the constructor body which can be placed into the initialization list instead. More...
class  ProBoundsArrayToPointerDecayCheck
 This check flags all array to pointer decays. More...
class  ProBoundsAvoidUncheckedContainerAccess
 Flags calls to operator[] in STL containers and suggests replacing it with safe alternatives. More...
class  ProBoundsConstantArrayIndexCheck
 This checks that all array subscriptions on static arrays and std::arrays have a constant index and are within bounds. More...
class  ProBoundsPointerArithmeticCheck
 Flags all kinds of pointer arithmetic that have result of pointer type, i.e. More...
class  ProTypeConstCastCheck
 Imposes limitations on the use of const_cast within C++ code. More...
class  ProTypeCstyleCastCheck
 This check flags all use of C-style casts that perform a static_cast downcast, const_cast, or reinterpret_cast. More...
class  ProTypeMemberInitCheck
 Implements C++ Core Guidelines Type.6. More...
class  ProTypeReinterpretCastCheck
 Flags all occurrences of reinterpret_cast. More...
class  ProTypeStaticCastDowncastCheck
 Checks for usages of static_cast, where a base class is downcasted to a derived class. More...
class  ProTypeUnionAccessCheck
 This check flags all access to members of unions. More...
class  ProTypeVarargCheck
 This check flags all calls to c-style variadic functions and all use of va_arg. More...
class  RvalueReferenceParamNotMovedCheck
 Warns when an rvalue reference function parameter is never moved within the function body. More...
class  SlicingCheck
 Flags slicing (incomplete copying of an object's state) of member variables or vtable. More...
class  SpecialMemberFunctionsCheck
 Checks for classes where some, but not all, of the special member functions are defined. More...
class  UseEnumClassCheck
 Finds unscoped (non-class) enum declarations and suggests using enum class instead. More...
class  VirtualClassDestructorCheck
 Finds base classes whose destructor is neither public and virtual nor protected and non-virtual. More...

Functions

static bool isCopyConstructible (const CXXRecordDecl &Node)
static bool isMoveConstructible (const CXXRecordDecl &Node)
static bool isCopyAssignable (const CXXRecordDecl &Node)
static bool isMoveAssignable (const CXXRecordDecl &Node)
static ClangTidyModuleRegistry::Add< CppCoreGuidelinesModuleX ("cppcoreguidelines-module", "Adds checks for the C++ Core Guidelines.")
static bool isCapsOnly (StringRef Name)
static SourceLocation findDefaultCaptureEnd (const LambdaExpr *Lambda, ASTContext &Context)
static std::string createReplacementText (const LambdaExpr *Lambda)
static bool isControlStatement (const Stmt *S)
static bool isNoReturnCallStatement (const Stmt *S)
static bool canAdvanceAssignment (AssignedLevel Level)
static void updateAssignmentLevel (const FieldDecl *Field, const Expr *Init, const CXXConstructorDecl *Ctor, llvm::DenseMap< const FieldDecl *, AssignedLevel > &AssignedFields)
static std::optional< AssignmentPairisAssignmentToMemberOf (const CXXRecordDecl *Rec, const Stmt *S, const CXXConstructorDecl *Ctor)
static const CXXMethodDecl * findAlternativeAt (const CXXMethodDecl *MatchedOperator)
static bool hasConstQualifier (QualType Type)
static bool hasVolatileQualifier (QualType Type)
static bool needsConstCast (QualType SourceType, QualType DestType)
static bool isIncompleteOrZeroLengthArrayType (ASTContext &Context, QualType T)
static bool isEmpty (ASTContext &Context, const QualType &Type)
static llvm::StringLiteral getInitializer (QualType QT, bool UseAssignment)
static bool hasSingleVariadicArgumentWithValue (const CallExpr *C, uint64_t I)
static llvm::StringRef toString (SpecialMemberFunctionsCheck::SpecialMemberFunctionKind K)
static std::string join (ArrayRef< SpecialMemberFunctionsCheck::SpecialMemberFunctionKind > SMFS, llvm::StringRef AndOr)
static std::optional< CharSourceRange > getVirtualKeywordRange (const CXXDestructorDecl &Destructor, const SourceManager &SM, const LangOptions &LangOpts)
static const AccessSpecDecl * getPublicASDecl (const CXXRecordDecl &StructOrClass)
static FixItHint generateUserDeclaredDestructor (const CXXRecordDecl &StructOrClass, const SourceManager &SourceManager)
static std::string getSourceText (const CXXDestructorDecl &Destructor)
static std::string eraseKeyword (std::string &DestructorString, const std::string &Keyword)
static FixItHint changePrivateDestructorVisibilityTo (const std::string &Visibility, const CXXDestructorDecl &Destructor, const SourceManager &SM, const LangOptions &LangOpts)

Variables

static constexpr llvm::StringRef DefaultExclusionStr
const internal::VariadicDynCastAllOfMatcher< Stmt, VAArgExpr > VAArgExpr
static constexpr StringRef AllowedVariadics []
static constexpr StringRef VaArgWarningMessage

Function Documentation

◆ canAdvanceAssignment()

bool clang::tidy::cppcoreguidelines::canAdvanceAssignment ( AssignedLevel Level)
static

◆ changePrivateDestructorVisibilityTo()

FixItHint clang::tidy::cppcoreguidelines::changePrivateDestructorVisibilityTo ( const std::string & Visibility,
const CXXDestructorDecl & Destructor,
const SourceManager & SM,
const LangOptions & LangOpts )
static

Semicolons ending an explicitly defaulted destructor have to be deleted. Otherwise, the left-over semicolon trails the private: access specifier.

Definition at line 134 of file VirtualClassDestructorCheck.cpp.

References eraseKeyword(), clang::tidy::utils::lexer::findNextTerminator(), and getSourceText().

Referenced by clang::tidy::cppcoreguidelines::VirtualClassDestructorCheck::check().

◆ createReplacementText()

std::string clang::tidy::cppcoreguidelines::createReplacementText ( const LambdaExpr * Lambda)
static

◆ eraseKeyword()

std::string clang::tidy::cppcoreguidelines::eraseKeyword ( std::string & DestructorString,
const std::string & Keyword )
static

◆ findAlternativeAt()

const CXXMethodDecl * clang::tidy::cppcoreguidelines::findAlternativeAt ( const CXXMethodDecl * MatchedOperator)
static

◆ findDefaultCaptureEnd()

SourceLocation clang::tidy::cppcoreguidelines::findDefaultCaptureEnd ( const LambdaExpr * Lambda,
ASTContext & Context )
static

◆ generateUserDeclaredDestructor()

FixItHint clang::tidy::cppcoreguidelines::generateUserDeclaredDestructor ( const CXXRecordDecl & StructOrClass,
const SourceManager & SourceManager )
static

◆ getInitializer()

llvm::StringLiteral clang::tidy::cppcoreguidelines::getInitializer ( QualType QT,
bool UseAssignment )
static

Definition at line 376 of file ProTypeMemberInitCheck.cpp.

◆ getPublicASDecl()

const AccessSpecDecl * clang::tidy::cppcoreguidelines::getPublicASDecl ( const CXXRecordDecl & StructOrClass)
static

Definition at line 77 of file VirtualClassDestructorCheck.cpp.

Referenced by generateUserDeclaredDestructor().

◆ getSourceText()

std::string clang::tidy::cppcoreguidelines::getSourceText ( const CXXDestructorDecl & Destructor)
static

◆ getVirtualKeywordRange()

std::optional< CharSourceRange > clang::tidy::cppcoreguidelines::getVirtualKeywordRange ( const CXXDestructorDecl & Destructor,
const SourceManager & SM,
const LangOptions & LangOpts )
static

Range ends with StartOfNextToken so that any whitespace after virtual is included.

Definition at line 54 of file VirtualClassDestructorCheck.cpp.

Referenced by clang::tidy::cppcoreguidelines::VirtualClassDestructorCheck::check().

◆ hasConstQualifier()

bool clang::tidy::cppcoreguidelines::hasConstQualifier ( QualType Type)
static

◆ hasSingleVariadicArgumentWithValue()

bool clang::tidy::cppcoreguidelines::hasSingleVariadicArgumentWithValue ( const CallExpr * C,
uint64_t I )
static

◆ hasVolatileQualifier()

bool clang::tidy::cppcoreguidelines::hasVolatileQualifier ( QualType Type)
static

◆ isAssignmentToMemberOf()

std::optional< AssignmentPair > clang::tidy::cppcoreguidelines::isAssignmentToMemberOf ( const CXXRecordDecl * Rec,
const Stmt * S,
const CXXConstructorDecl * Ctor )
static

◆ isCapsOnly()

bool clang::tidy::cppcoreguidelines::isCapsOnly ( StringRef Name)
static

Definition at line 21 of file MacroUsageCheck.cpp.

◆ isControlStatement()

bool clang::tidy::cppcoreguidelines::isControlStatement ( const Stmt * S)
static

◆ isCopyAssignable()

bool clang::tidy::cppcoreguidelines::isCopyAssignable ( const CXXRecordDecl & Node)
static

Definition at line 53 of file AvoidConstOrRefDataMembersCheck.cpp.

References isCopyAssignable().

Referenced by isCopyAssignable().

◆ isCopyConstructible()

bool clang::tidy::cppcoreguidelines::isCopyConstructible ( const CXXRecordDecl & Node)
static

Definition at line 17 of file AvoidConstOrRefDataMembersCheck.cpp.

References isCopyConstructible().

Referenced by isCopyConstructible().

◆ isEmpty()

bool clang::tidy::cppcoreguidelines::isEmpty ( ASTContext & Context,
const QualType & Type )
static

Definition at line 369 of file ProTypeMemberInitCheck.cpp.

References isIncompleteOrZeroLengthArrayType().

◆ isIncompleteOrZeroLengthArrayType()

bool clang::tidy::cppcoreguidelines::isIncompleteOrZeroLengthArrayType ( ASTContext & Context,
QualType T )
static

Definition at line 355 of file ProTypeMemberInitCheck.cpp.

Referenced by isEmpty().

◆ isMoveAssignable()

bool clang::tidy::cppcoreguidelines::isMoveAssignable ( const CXXRecordDecl & Node)
static

Definition at line 71 of file AvoidConstOrRefDataMembersCheck.cpp.

References isMoveAssignable().

Referenced by isMoveAssignable().

◆ isMoveConstructible()

bool clang::tidy::cppcoreguidelines::isMoveConstructible ( const CXXRecordDecl & Node)
static

Definition at line 35 of file AvoidConstOrRefDataMembersCheck.cpp.

References isMoveConstructible().

Referenced by isMoveConstructible().

◆ isNoReturnCallStatement()

bool clang::tidy::cppcoreguidelines::isNoReturnCallStatement ( const Stmt * S)
static

◆ join()

std::string clang::tidy::cppcoreguidelines::join ( ArrayRef< SpecialMemberFunctionsCheck::SpecialMemberFunctionKind > SMFS,
llvm::StringRef AndOr )
static

Definition at line 103 of file SpecialMemberFunctionsCheck.cpp.

References toString().

◆ needsConstCast()

bool clang::tidy::cppcoreguidelines::needsConstCast ( QualType SourceType,
QualType DestType )
static

◆ toString()

◆ updateAssignmentLevel()

void clang::tidy::cppcoreguidelines::updateAssignmentLevel ( const FieldDecl * Field,
const Expr * Init,
const CXXConstructorDecl * Ctor,
llvm::DenseMap< const FieldDecl *, AssignedLevel > & AssignedFields )
static

◆ X()

ClangTidyModuleRegistry::Add< CppCoreGuidelinesModule > clang::tidy::cppcoreguidelines::X ( "cppcoreguidelines-module" ,
"Adds checks for the C++ Core Guidelines."  )
static

Variable Documentation

◆ AllowedVariadics

StringRef clang::tidy::cppcoreguidelines::AllowedVariadics[]
staticconstexpr

◆ DefaultExclusionStr

llvm::StringRef clang::tidy::cppcoreguidelines::DefaultExclusionStr
staticconstexpr
Initial value:
=
"::std::map;::std::unordered_map;::std::flat_map"

Definition at line 19 of file ProBoundsAvoidUncheckedContainerAccess.cpp.

Referenced by clang::tidy::cppcoreguidelines::ProBoundsAvoidUncheckedContainerAccess::ProBoundsAvoidUncheckedContainerAccess().

◆ VAArgExpr

const internal::VariadicDynCastAllOfMatcher<Stmt, VAArgExpr> clang::tidy::cppcoreguidelines::VAArgExpr

◆ VaArgWarningMessage

StringRef clang::tidy::cppcoreguidelines::VaArgWarningMessage
staticconstexpr
Initial value:
=
"do not use va_arg to define c-style vararg functions; "
"use variadic templates instead"

Definition at line 62 of file ProTypeVarargCheck.cpp.

Referenced by clang::tidy::cppcoreguidelines::ProTypeVarargCheck::check().