clang-tools 22.0.0git
clang::tidy::bugprone::SmartPtrArrayMismatchCheck Class Referenceabstract

Find constructions of smart (unique or shared) pointers where the pointer is declared with non-array target type and an array (created with a new-expression) is passed to it. More...

#include <SmartPtrArrayMismatchCheck.h>

Inheritance diagram for clang::tidy::bugprone::SmartPtrArrayMismatchCheck:
[legend]

Public Member Functions

 SmartPtrArrayMismatchCheck (StringRef Name, ClangTidyContext *Context, StringRef SmartPointerName)
bool isLanguageVersionSupported (const LangOptions &LangOpts) const override
void registerMatchers (ast_matchers::MatchFinder *Finder) override
void check (const ast_matchers::MatchFinder::MatchResult &Result) override
void storeOptions (ClangTidyOptions::OptionMap &Opts) override

Protected Types

using SmartPtrClassMatcher = ast_matchers::internal::BindableMatcher<Decl>

Protected Member Functions

virtual SmartPtrClassMatcher getSmartPointerClassMatcher () const =0
 Returns matcher that match with different smart pointer classes.

Static Protected Attributes

static const char PointerTypeN [] = "pointer_type"

Detailed Description

Find constructions of smart (unique or shared) pointers where the pointer is declared with non-array target type and an array (created with a new-expression) is passed to it.

Definition at line 19 of file SmartPtrArrayMismatchCheck.h.

Member Typedef Documentation

◆ SmartPtrClassMatcher

using clang::tidy::bugprone::SmartPtrArrayMismatchCheck::SmartPtrClassMatcher = ast_matchers::internal::BindableMatcher<Decl>
protected

Definition at line 32 of file SmartPtrArrayMismatchCheck.h.

Constructor & Destructor Documentation

◆ SmartPtrArrayMismatchCheck()

clang::tidy::bugprone::SmartPtrArrayMismatchCheck::SmartPtrArrayMismatchCheck ( StringRef Name,
ClangTidyContext * Context,
StringRef SmartPointerName )

Member Function Documentation

◆ check()

void clang::tidy::bugprone::SmartPtrArrayMismatchCheck::check ( const ast_matchers::MatchFinder::MatchResult & Result)
override

◆ getSmartPointerClassMatcher()

virtual SmartPtrClassMatcher clang::tidy::bugprone::SmartPtrArrayMismatchCheck::getSmartPointerClassMatcher ( ) const
protectedpure virtual

Returns matcher that match with different smart pointer classes.

Requires to bind pointer type (qualType) with PointerTypeN string declared in this class.

Implemented in clang::tidy::bugprone::SharedPtrArrayMismatchCheck, and clang::tidy::bugprone::UniquePtrArrayMismatchCheck.

Referenced by registerMatchers().

◆ isLanguageVersionSupported()

bool clang::tidy::bugprone::SmartPtrArrayMismatchCheck::isLanguageVersionSupported ( const LangOptions & LangOpts) const
inlineoverride

Definition at line 24 of file SmartPtrArrayMismatchCheck.h.

◆ registerMatchers()

void clang::tidy::bugprone::SmartPtrArrayMismatchCheck::registerMatchers ( ast_matchers::MatchFinder * Finder)
override

Definition at line 57 of file SmartPtrArrayMismatchCheck.cpp.

References getSmartPointerClassMatcher(), and PointerTypeN.

◆ storeOptions()

void clang::tidy::bugprone::SmartPtrArrayMismatchCheck::storeOptions ( ClangTidyOptions::OptionMap & Opts)
override

Definition at line 54 of file SmartPtrArrayMismatchCheck.cpp.

Member Data Documentation

◆ PointerTypeN

const char clang::tidy::bugprone::SmartPtrArrayMismatchCheck::PointerTypeN = "pointer_type"
staticprotected

The documentation for this class was generated from the following files: