clang-tools 22.0.0git
clang::tidy::bugprone::IncDecInConditionsCheck Class Reference

Detects when a variable is both incremented/decremented and referenced inside a complex condition and suggests moving them outside to avoid ambiguity in the variable's value. More...

#include <IncDecInConditionsCheck.h>

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

Public Member Functions

 IncDecInConditionsCheck (StringRef Name, ClangTidyContext *Context)
void registerMatchers (ast_matchers::MatchFinder *Finder) override
void check (const ast_matchers::MatchFinder::MatchResult &Result) override
std::optional< TraversalKind > getCheckTraversalKind () const override

Detailed Description

Detects when a variable is both incremented/decremented and referenced inside a complex condition and suggests moving them outside to avoid ambiguity in the variable's value.

For the user-facing documentation see: https://clang.llvm.org/extra/clang-tidy/checks/bugprone/inc-dec-in-conditions.html

Definition at line 22 of file IncDecInConditionsCheck.h.

Constructor & Destructor Documentation

◆ IncDecInConditionsCheck()

clang::tidy::bugprone::IncDecInConditionsCheck::IncDecInConditionsCheck ( StringRef Name,
ClangTidyContext * Context )
inline

Definition at line 24 of file IncDecInConditionsCheck.h.

Member Function Documentation

◆ check()

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

Definition at line 66 of file IncDecInConditionsCheck.cpp.

◆ getCheckTraversalKind()

std::optional< TraversalKind > clang::tidy::bugprone::IncDecInConditionsCheck::getCheckTraversalKind ( ) const
inlineoverride

Definition at line 28 of file IncDecInConditionsCheck.h.

◆ registerMatchers()

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

Definition at line 33 of file IncDecInConditionsCheck.cpp.


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