clang-tools 22.0.0git
clang::tidy::cppcoreguidelines::NoMallocCheck Class Reference

This checker is concerned with C-style memory management and suggest modern alternatives to it. More...

#include <NoMallocCheck.h>

Inheritance diagram for clang::tidy::cppcoreguidelines::NoMallocCheck:
[legend]

Public Member Functions

 NoMallocCheck (StringRef Name, ClangTidyContext *Context)
 Construct Checker and read in configuration for function names.
bool isLanguageVersionSupported (const LangOptions &LangOpts) const override
void storeOptions (ClangTidyOptions::OptionMap &Opts) override
 Make configuration of checker discoverable.
void registerMatchers (ast_matchers::MatchFinder *Finder) override
 Registering for malloc, calloc, realloc and free calls.
void check (const ast_matchers::MatchFinder::MatchResult &Result) override
 Checks matched function calls and gives suggestion to modernize the code.

Detailed Description

This checker is concerned with C-style memory management and suggest modern alternatives to it.

The check is only enabled in C++. For analyzing malloc calls see Clang Static Analyzer - unix.Malloc.

For the user-facing documentation see: https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/no-malloc.html

Definition at line 23 of file NoMallocCheck.h.

Constructor & Destructor Documentation

◆ NoMallocCheck()

clang::tidy::cppcoreguidelines::NoMallocCheck::NoMallocCheck ( StringRef Name,
ClangTidyContext * Context )
inline

Construct Checker and read in configuration for function names.

Definition at line 26 of file NoMallocCheck.h.

Member Function Documentation

◆ check()

void clang::tidy::cppcoreguidelines::NoMallocCheck::check ( const ast_matchers::MatchFinder::MatchResult & Result)
override

Checks matched function calls and gives suggestion to modernize the code.

Definition at line 46 of file NoMallocCheck.cpp.

◆ isLanguageVersionSupported()

bool clang::tidy::cppcoreguidelines::NoMallocCheck::isLanguageVersionSupported ( const LangOptions & LangOpts) const
inlineoverride

Definition at line 32 of file NoMallocCheck.h.

◆ registerMatchers()

void clang::tidy::cppcoreguidelines::NoMallocCheck::registerMatchers ( ast_matchers::MatchFinder * Finder)
override

Registering for malloc, calloc, realloc and free calls.

Definition at line 24 of file NoMallocCheck.cpp.

References clang::tidy::utils::options::parseStringList().

◆ storeOptions()

void clang::tidy::cppcoreguidelines::NoMallocCheck::storeOptions ( ClangTidyOptions::OptionMap & Opts)
override

Make configuration of checker discoverable.

Definition at line 18 of file NoMallocCheck.cpp.


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