clang API Documentation
This defines IdenticalExprChecker, a check that warns about unintended use of identical expressions. More...
#include "ClangSACheckers.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
#include "clang/StaticAnalyzer/Core/Checker.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
Go to the source code of this file.
Functions | |
static bool | isIdenticalStmt (const ASTContext &Ctx, const Stmt *Stmt1, const Stmt *Stmt2, bool IgnoreSideEffects) |
Determines whether two statement trees are identical regarding operators and symbols. |
This defines IdenticalExprChecker, a check that warns about unintended use of identical expressions.
It checks for use of identical expressions with comparison operators and inside conditional expressions.
Definition in file IdenticalExprChecker.cpp.
static bool isIdenticalStmt | ( | const ASTContext & | Ctx, |
const Stmt * | Stmt1, | ||
const Stmt * | Stmt2, | ||
bool | IgnoreSideEffects | ||
) | [static] |
Determines whether two statement trees are identical regarding operators and symbols.
Exceptions: expressions containing macros or functions with possible side effects are never considered identical. Limitations: (t + u) and (u + t) are not considered identical. t*(u + t) and t*u + t*t are not considered identical.
Definition at line 286 of file IdenticalExprChecker.cpp.
References clang::CompoundStmt::body_begin(), clang::CompoundStmt::body_end(), clang::Stmt::child_begin(), clang::Stmt::child_end(), clang::WhileStmt::getBody(), clang::DoStmt::getBody(), clang::ForStmt::getBody(), clang::StringLiteral::getBytes(), clang::IfStmt::getCond(), clang::WhileStmt::getCond(), clang::DoStmt::getCond(), clang::ForStmt::getCond(), clang::DeclRefExpr::getDecl(), clang::IfStmt::getElse(), clang::Expr::getExprLoc(), clang::ForStmt::getInc(), clang::ForStmt::getInit(), clang::MemberExpr::getMemberDecl(), clang::UnaryOperator::getOpcode(), clang::BinaryOperator::getOpcode(), clang::ReturnStmt::getRetValue(), clang::Stmt::getStmtClass(), clang::IfStmt::getThen(), clang::ExplicitCastExpr::getTypeAsWritten(), clang::APIntStorage::getValue(), clang::CharacterLiteral::getValue(), clang::FloatingLiteral::getValue(), clang::Expr::HasSideEffects(), clang::SourceLocation::isMacroID(), and clang::CompoundStmt::size().