clang-tools 22.0.0git
clang::tidy::misc::ConstCorrectnessCheck Class Reference

This check warns on variables which could be declared const but are not. More...

#include <ConstCorrectnessCheck.h>

Inheritance diagram for clang::tidy::misc::ConstCorrectnessCheck:
[legend]

Public Member Functions

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

Detailed Description

This check warns on variables which could be declared const but are not.

For the user-facing documentation see: https://clang.llvm.org/extra/clang-tidy/checks/misc/const-correctness.html

Definition at line 22 of file ConstCorrectnessCheck.h.

Constructor & Destructor Documentation

◆ ConstCorrectnessCheck()

clang::tidy::misc::ConstCorrectnessCheck::ConstCorrectnessCheck ( StringRef Name,
ClangTidyContext * Context )

Definition at line 38 of file ConstCorrectnessCheck.cpp.

Member Function Documentation

◆ check()

void clang::tidy::misc::ConstCorrectnessCheck::check ( const ast_matchers::MatchFinder::MatchResult & Result)
override

If the variable was declared in a template it might be analyzed multiple times. Only one of those instantiations shall emit a warning. NOTE: This shall only deduplicate warnings for variables that are not instantiation dependent. Variables like 'int x = 42;' in a template that can become const emit multiple warnings otherwise.

Definition at line 143 of file ConstCorrectnessCheck.cpp.

References clang::tidy::misc::Pointer, clang::tidy::misc::Reference, and clang::tidy::misc::Value.

◆ isLanguageVersionSupported()

bool clang::tidy::misc::ConstCorrectnessCheck::isLanguageVersionSupported ( const LangOptions & LangOpts) const
inlineoverride

Definition at line 27 of file ConstCorrectnessCheck.h.

◆ registerMatchers()

void clang::tidy::misc::ConstCorrectnessCheck::registerMatchers ( ast_matchers::MatchFinder * Finder)
override

◆ storeOptions()

void clang::tidy::misc::ConstCorrectnessCheck::storeOptions ( ClangTidyOptions::OptionMap & Opts)
override

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