clang-tools  14.0.0git
Classes | Functions | Variables
clang::tidy::cppcoreguidelines Namespace Reference

Classes

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  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  NarrowingConversionsCheck
 Checks for narrowing conversions, e.g: int i = 0; i += 0.1;. More...
 
class  NoMallocCheck
 This checker is concerned with C-style memory management and suggest modern alternatives to it. 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  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
 This check flags all instances of const_cast. 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  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  VirtualClassDestructorCheck
 Finds base classes whose destructor is neither public and virtual nor protected and non-virtual. More...
 

Functions

static ClangTidyModuleRegistry::Add< CppCoreGuidelinesModuleX ("cppcoreguidelines-module", "Adds checks for the C++ Core Guidelines.")
 
static const BuiltinType * getBuiltinType (const Expr &E)
 
static QualType getUnqualifiedType (const Expr &E)
 
static APValue getConstantExprValue (const ASTContext &Ctx, const Expr &E)
 
static bool getIntegerConstantExprValue (const ASTContext &Context, const Expr &E, llvm::APSInt &Value)
 
static bool getFloatingConstantExprValue (const ASTContext &Context, const Expr &E, llvm::APFloat &Value)
 
static IntegerRange createFromType (const ASTContext &Context, const BuiltinType &T)
 
static bool isWideEnoughToHold (const ASTContext &Context, const BuiltinType &FromType, const BuiltinType &ToType)
 
static bool isWideEnoughToHold (const ASTContext &Context, const llvm::APSInt &IntegerConstant, const BuiltinType &ToType)
 
static bool isFloatExactlyRepresentable (const ASTContext &Context, const llvm::APFloat &FloatConstant, const QualType &DestType)
 
static llvm::SmallString< 64 > getValueAsString (const llvm::APSInt &Value, uint64_t HexBits)
 
static bool isControlStatement (const Stmt *S)
 
static bool isNoReturnCallStatement (const Stmt *S)
 
static bool isLiteral (const Expr *E)
 
static bool isUnaryExprOfLiteral (const Expr *E)
 
static bool shouldBeDefaultMemberInitializer (const Expr *Value)
 
static bool isSafeAssignment (const FieldDecl *Field, const Expr *Init, const CXXConstructorDecl *Context)
 
static std::pair< const FieldDecl *, const Expr * > isAssignmentToMemberOf (const CXXRecordDecl *Rec, const Stmt *S, const CXXConstructorDecl *Ctor)
 
static bool needsConstCast (QualType SourceType, QualType DestType)
 
static bool isIncompleteOrZeroLengthArrayType (ASTContext &Context, QualType T)
 
static bool isEmpty (ASTContext &Context, const QualType &Type)
 
static const char * 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 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

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

Function Documentation

◆ changePrivateDestructorVisibilityTo()

static 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 111 of file VirtualClassDestructorCheck.cpp.

◆ createFromType()

static IntegerRange clang::tidy::cppcoreguidelines::createFromType ( const ASTContext &  Context,
const BuiltinType &  T 
)
static

Definition at line 182 of file NarrowingConversionsCheck.cpp.

◆ eraseKeyword()

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

Definition at line 103 of file VirtualClassDestructorCheck.cpp.

◆ generateUserDeclaredDestructor()

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

Definition at line 68 of file VirtualClassDestructorCheck.cpp.

References getPublicASDecl(), and Loc.

◆ getBuiltinType()

static const BuiltinType* clang::tidy::cppcoreguidelines::getBuiltinType ( const Expr &  E)
static

Definition at line 128 of file NarrowingConversionsCheck.cpp.

◆ getConstantExprValue()

static APValue clang::tidy::cppcoreguidelines::getConstantExprValue ( const ASTContext &  Ctx,
const Expr &  E 
)
static

Definition at line 136 of file NarrowingConversionsCheck.cpp.

◆ getFloatingConstantExprValue()

static bool clang::tidy::cppcoreguidelines::getFloatingConstantExprValue ( const ASTContext &  Context,
const Expr &  E,
llvm::APFloat &  Value 
)
static

Definition at line 154 of file NarrowingConversionsCheck.cpp.

◆ getInitializer()

static const char* clang::tidy::cppcoreguidelines::getInitializer ( QualType  QT,
bool  UseAssignment 
)
static

Definition at line 344 of file ProTypeMemberInitCheck.cpp.

◆ getIntegerConstantExprValue()

static bool clang::tidy::cppcoreguidelines::getIntegerConstantExprValue ( const ASTContext &  Context,
const Expr &  E,
llvm::APSInt &  Value 
)
static

Definition at line 145 of file NarrowingConversionsCheck.cpp.

◆ getPublicASDecl()

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

Definition at line 54 of file VirtualClassDestructorCheck.cpp.

Referenced by generateUserDeclaredDestructor().

◆ getSourceText()

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

◆ getUnqualifiedType()

static QualType clang::tidy::cppcoreguidelines::getUnqualifiedType ( const Expr &  E)
static

Definition at line 132 of file NarrowingConversionsCheck.cpp.

◆ getValueAsString()

static llvm::SmallString<64> clang::tidy::cppcoreguidelines::getValueAsString ( const llvm::APSInt &  Value,
uint64_t  HexBits 
)
static

Definition at line 241 of file NarrowingConversionsCheck.cpp.

◆ getVirtualKeywordRange()

static 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 37 of file VirtualClassDestructorCheck.cpp.

◆ hasSingleVariadicArgumentWithValue()

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

Definition at line 128 of file ProTypeVarargCheck.cpp.

References C.

◆ isAssignmentToMemberOf()

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

Definition at line 87 of file PreferMemberInitializerCheck.cpp.

◆ isControlStatement()

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

Definition at line 20 of file PreferMemberInitializerCheck.cpp.

◆ isEmpty()

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

Definition at line 337 of file ProTypeMemberInitCheck.cpp.

◆ isFloatExactlyRepresentable()

static bool clang::tidy::cppcoreguidelines::isFloatExactlyRepresentable ( const ASTContext &  Context,
const llvm::APFloat &  FloatConstant,
const QualType &  DestType 
)
static

Definition at line 228 of file NarrowingConversionsCheck.cpp.

◆ isIncompleteOrZeroLengthArrayType()

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

Definition at line 323 of file ProTypeMemberInitCheck.cpp.

◆ isLiteral()

static bool clang::tidy::cppcoreguidelines::isLiteral ( const Expr *  E)
static

Definition at line 37 of file PreferMemberInitializerCheck.cpp.

◆ isNoReturnCallStatement()

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

Definition at line 25 of file PreferMemberInitializerCheck.cpp.

◆ isSafeAssignment()

static bool clang::tidy::cppcoreguidelines::isSafeAssignment ( const FieldDecl *  Field,
const Expr *  Init,
const CXXConstructorDecl *  Context 
)
static

Definition at line 69 of file PreferMemberInitializerCheck.cpp.

◆ isUnaryExprOfLiteral()

static bool clang::tidy::cppcoreguidelines::isUnaryExprOfLiteral ( const Expr *  E)
static

Definition at line 42 of file PreferMemberInitializerCheck.cpp.

◆ isWideEnoughToHold() [1/2]

static bool clang::tidy::cppcoreguidelines::isWideEnoughToHold ( const ASTContext &  Context,
const BuiltinType &  FromType,
const BuiltinType &  ToType 
)
static

Definition at line 210 of file NarrowingConversionsCheck.cpp.

◆ isWideEnoughToHold() [2/2]

static bool clang::tidy::cppcoreguidelines::isWideEnoughToHold ( const ASTContext &  Context,
const llvm::APSInt &  IntegerConstant,
const BuiltinType &  ToType 
)
static

Definition at line 218 of file NarrowingConversionsCheck.cpp.

◆ join()

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

◆ needsConstCast()

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

Definition at line 20 of file ProTypeCstyleCastCheck.cpp.

◆ shouldBeDefaultMemberInitializer()

static bool clang::tidy::cppcoreguidelines::shouldBeDefaultMemberInitializer ( const Expr *  Value)
static

Definition at line 48 of file PreferMemberInitializerCheck.cpp.

◆ toString()

static llvm::StringRef clang::tidy::cppcoreguidelines::toString ( SpecialMemberFunctionsCheck::SpecialMemberFunctionKind  K)
static

◆ X()

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

Variable Documentation

◆ AllowedVariadics

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

Definition at line 23 of file ProTypeVarargCheck.cpp.

◆ VAArgExpr

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

Definition at line 21 of file ProTypeVarargCheck.cpp.