clang-tools 23.0.0git
clang::tidy::modernize::UseNullptrCheck Class Reference

#include <UseNullptrCheck.h>

Inheritance diagram for clang::tidy::modernize::UseNullptrCheck:
[legend]

Public Member Functions

 UseNullptrCheck (StringRef Name, ClangTidyContext *Context)
bool isLanguageVersionSupported (const LangOptions &LangOpts) const override
void storeOptions (ClangTidyOptions::OptionMap &Opts) override
void registerMatchers (ast_matchers::MatchFinder *Finder) override
 Create a matcher that finds implicit casts as well as the head of a sequence of zero or more nested explicit casts that have an implicit cast to null within.
void check (const ast_matchers::MatchFinder::MatchResult &Result) override

Detailed Description

Definition at line 16 of file UseNullptrCheck.h.

Constructor & Destructor Documentation

◆ UseNullptrCheck()

clang::tidy::modernize::UseNullptrCheck::UseNullptrCheck ( StringRef Name,
ClangTidyContext * Context )

Definition at line 495 of file UseNullptrCheck.cpp.

Member Function Documentation

◆ check()

void clang::tidy::modernize::UseNullptrCheck::check ( const ast_matchers::MatchFinder::MatchResult & Result)
override

Definition at line 509 of file UseNullptrCheck.cpp.

References clang::tidy::modernize::CastSequence.

◆ isLanguageVersionSupported()

bool clang::tidy::modernize::UseNullptrCheck::isLanguageVersionSupported ( const LangOptions & LangOpts) const
inlineoverride

Definition at line 19 of file UseNullptrCheck.h.

◆ registerMatchers()

void clang::tidy::modernize::UseNullptrCheck::registerMatchers ( ast_matchers::MatchFinder * Finder)
override

Create a matcher that finds implicit casts as well as the head of a sequence of zero or more nested explicit casts that have an implicit cast to null within.

Finding sequences of explicit casts is necessary so that an entire sequence can be replaced instead of just the inner-most implicit cast.

TODO/NOTE: The second "anyOf" below discards matches on a substituted type, since we don't know if that would always be a pointer type for all other specializations, unless the expression was "__null", in which case we assume that all specializations are expected to be for pointer types. Ideally this would check for the "NULL" macro instead, but that'd be harder to express. In practice, "NULL" is often defined as "__null", and this is a useful condition.

Definition at line 48 of file UseNullptrCheck.cpp.

References clang::tidy::modernize::CastSequence, and clang::tidy::matchers::matchesAnyListedTypeName().

◆ storeOptions()

void clang::tidy::modernize::UseNullptrCheck::storeOptions ( ClangTidyOptions::OptionMap & Opts)
override

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