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

Finds assert() with side effect. More...

#include <AssertSideEffectCheck.h>

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

Public Member Functions

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

Detailed Description

Finds assert() with side effect.

The condition of assert() is evaluated only in debug builds so a condition with side effect can cause different behavior in debug / release builds.

There are two options:

  • AssertMacros: A comma-separated list of the names of assert macros to be checked.
  • CheckFunctionCalls: Whether to treat non-const member and non-member functions as they produce side effects. Disabled by default because it can increase the number of false positive warnings.

Definition at line 32 of file AssertSideEffectCheck.h.

Constructor & Destructor Documentation

◆ AssertSideEffectCheck()

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

Definition at line 88 of file AssertSideEffectCheck.cpp.

Member Function Documentation

◆ check()

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

Definition at line 126 of file AssertSideEffectCheck.cpp.

◆ registerMatchers()

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

◆ storeOptions()

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

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