|
clang 24.0.0git
|
Visitor that tries to report interesting diagnostics from conditions. More...
#include "clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h"
Public Member Functions | |
| void | Profile (llvm::FoldingSetNodeID &ID) const override |
| PathDiagnosticPieceRef | VisitNode (const ExplodedNode *N, BugReporterContext &BRC, PathSensitiveBugReport &BR) override |
| Return a diagnostic piece which should be associated with the given node. | |
| PathDiagnosticPieceRef | VisitNodeImpl (const ExplodedNode *N, BugReporterContext &BRC, PathSensitiveBugReport &BR) |
| PathDiagnosticPieceRef | VisitTerminator (const Stmt *Term, const ExplodedNode *N, const CFGBlock *SrcBlk, const CFGBlock *DstBlk, PathSensitiveBugReport &R, BugReporterContext &BRC) |
| PathDiagnosticPieceRef | VisitTrueTest (const Expr *Cond, BugReporterContext &BRC, PathSensitiveBugReport &R, const ExplodedNode *N, bool TookTrue) |
| PathDiagnosticPieceRef | VisitTrueTest (const Expr *Cond, const DeclRefExpr *DR, BugReporterContext &BRC, PathSensitiveBugReport &R, const ExplodedNode *N, bool TookTrue, bool IsAssuming) |
| PathDiagnosticPieceRef | VisitTrueTest (const Expr *Cond, const BinaryOperator *BExpr, BugReporterContext &BRC, PathSensitiveBugReport &R, const ExplodedNode *N, bool TookTrue, bool IsAssuming) |
| PathDiagnosticPieceRef | VisitTrueTest (const Expr *Cond, const MemberExpr *ME, BugReporterContext &BRC, PathSensitiveBugReport &R, const ExplodedNode *N, bool TookTrue, bool IsAssuming) |
| PathDiagnosticPieceRef | VisitConditionVariable (StringRef LhsString, const Expr *CondVarExpr, BugReporterContext &BRC, PathSensitiveBugReport &R, const ExplodedNode *N, bool TookTrue) |
| bool | printValue (const Expr *CondVarExpr, raw_ostream &Out, const ExplodedNode *N, bool TookTrue, bool IsAssuming) |
| Tries to print the value of the given expression. | |
| bool | patternMatch (const Expr *Ex, const Expr *ParentEx, const Expr *OtherEx, raw_ostream &Out, BugReporterContext &BRC, PathSensitiveBugReport &R, const ExplodedNode *N, std::optional< bool > &prunable, bool IsSameFieldName) |
| Public Member Functions inherited from clang::ento::BugReporterVisitor | |
| BugReporterVisitor ()=default | |
| BugReporterVisitor (const BugReporterVisitor &)=default | |
| BugReporterVisitor (BugReporterVisitor &&) | |
| BugReporterVisitor & | operator= (const BugReporterVisitor &)=delete |
| BugReporterVisitor & | operator= (BugReporterVisitor &&)=delete |
| virtual | ~BugReporterVisitor () |
| virtual void | finalizeVisitor (const ExplodedNode *EndPathNode, BugReporterContext &BRC, PathSensitiveBugReport &BR) |
| Last function called on the visitor, no further calls to VisitNode would follow. | |
| virtual PathDiagnosticPieceRef | getEndPath (const ExplodedNode *N, BugReporterContext &BRC, PathSensitiveBugReport &BR) |
| Provide custom definition for the final diagnostic piece on the path - the piece, which is displayed before the path is expanded. | |
Static Public Member Functions | |
| static const char * | getTag () |
| Return the tag associated with this visitor. | |
| static bool | isPieceMessageGeneric (const PathDiagnosticPiece *Piece) |
| Static Public Member Functions inherited from clang::ento::BugReporterVisitor | |
| static PathDiagnosticPieceRef | getDefaultEndPath (const BugReporterContext &BRC, const ExplodedNode *N, const PathSensitiveBugReport &BR) |
| Generates the default final diagnostic piece. | |
Visitor that tries to report interesting diagnostics from conditions.
Definition at line 448 of file BugReporterVisitors.h.
|
static |
Return the tag associated with this visitor.
This tag will be used to make all PathDiagnosticPieces created by this visitor.
Definition at line 2705 of file BugReporterVisitors.cpp.
Referenced by eventsDescribeSameCondition(), and VisitNode().
|
static |
Definition at line 3249 of file BugReporterVisitors.cpp.
References clang::ento::PathDiagnosticPiece::getString().
Referenced by eventsDescribeSameCondition().
| bool ConditionBRVisitor::patternMatch | ( | const Expr * | Ex, |
| const Expr * | ParentEx, | ||
| const Expr * | OtherEx, | ||
| raw_ostream & | Out, | ||
| BugReporterContext & | BRC, | ||
| PathSensitiveBugReport & | R, | ||
| const ExplodedNode * | N, | ||
| std::optional< bool > & | prunable, | ||
| bool | IsSameFieldName ) |
Definition at line 2900 of file BugReporterVisitors.cpp.
References clang::cast(), clang::Lexer::getAsCharRange(), clang::ento::SVal::getAsRegion(), clang::ento::BugReporterContext::getASTContext(), clang::Stmt::getBeginLoc(), clang::Stmt::getEndLoc(), clang::ASTContext::getLangOpts(), clang::ento::ProgramState::getLValue(), clang::ento::BugReporterContext::getSourceManager(), clang::Stmt::getSourceRange(), clang::Lexer::getSourceText(), clang::ento::ExplodedNode::getStackFrame(), clang::ento::ExplodedNode::getState(), clang::ento::ProgramState::getSVal(), clang::CharSourceRange::getTokenRange(), clang::Expr::getType(), clang::Expr::IgnoreParenCasts(), clang::isa(), clang::Lexer::isAtEndOfMacroExpansion(), clang::Lexer::isAtStartOfMacroExpansion(), clang::SourceLocation::isMacroID(), clang::Type::isObjCObjectPointerType(), clang::Type::isPointerType(), clang::Type::isSignedIntegerOrEnumerationType(), clang::sema::Report, and V.
Referenced by VisitTrueTest().
| bool ConditionBRVisitor::printValue | ( | const Expr * | CondVarExpr, |
| raw_ostream & | Out, | ||
| const ExplodedNode * | N, | ||
| bool | TookTrue, | ||
| bool | IsAssuming ) |
Tries to print the value of the given expression.
| CondVarExpr | The expression to print its value. |
| Out | The stream to print. |
| N | The node where we encountered the condition. |
| TookTrue | Whether we took the true branch of the condition. |
Definition at line 3212 of file BugReporterVisitors.cpp.
References getConcreteIntegerValue(), clang::Expr::getType(), clang::Type::isBooleanType(), clang::Type::isIntegralOrEnumerationType(), clang::Type::isObjCObjectPointerType(), and clang::Type::isPointerType().
Referenced by VisitConditionVariable(), VisitTrueTest(), and VisitTrueTest().
|
inlineoverridevirtual |
Implements clang::ento::BugReporterVisitor.
Definition at line 456 of file BugReporterVisitors.h.
| PathDiagnosticPieceRef ConditionBRVisitor::VisitConditionVariable | ( | StringRef | LhsString, |
| const Expr * | CondVarExpr, | ||
| BugReporterContext & | BRC, | ||
| PathSensitiveBugReport & | R, | ||
| const ExplodedNode * | N, | ||
| bool | TookTrue ) |
Definition at line 3111 of file BugReporterVisitors.cpp.
References clang::ento::BugReporterContext::getSourceManager(), clang::ento::ExplodedNode::getStackFrame(), isInterestingExpr(), isVarAnInterestingCondition(), printValue(), and WillBeUsedForACondition.
Referenced by VisitTrueTest().
|
overridevirtual |
Return a diagnostic piece which should be associated with the given node.
Note that this function does not get run on the very last node of the report, as the PathDiagnosticPiece associated with the last node should be unique. Use getEndPath to customize the note associated with the report end instead.
The last parameter can be used to register a new visitor with the given BugReport while processing a node.
Implements clang::ento::BugReporterVisitor.
Definition at line 2708 of file BugReporterVisitors.cpp.
References getTag(), and VisitNodeImpl().
| PathDiagnosticPieceRef ConditionBRVisitor::VisitNodeImpl | ( | const ExplodedNode * | N, |
| BugReporterContext & | BRC, | ||
| PathSensitiveBugReport & | BR ) |
Definition at line 2720 of file BugReporterVisitors.cpp.
References clang::cast(), clang::ProgramPoint::getAs(), clang::ento::ExprEngine::getEagerlyAssumeBifurcationTags(), clang::ento::ExplodedNode::getFirstPred(), clang::ento::ExplodedNode::getLocation(), clang::ProgramPoint::getTag(), clang::CFGBlock::getTerminatorStmt(), VisitTerminator(), and VisitTrueTest().
Referenced by VisitNode().
| PathDiagnosticPieceRef ConditionBRVisitor::VisitTerminator | ( | const Stmt * | Term, |
| const ExplodedNode * | N, | ||
| const CFGBlock * | SrcBlk, | ||
| const CFGBlock * | DstBlk, | ||
| PathSensitiveBugReport & | R, | ||
| BugReporterContext & | BRC ) |
Definition at line 2758 of file BugReporterVisitors.cpp.
References clang::cast(), clang::Stmt::getStmtClass(), clang::Expr::IgnoreParens(), clang::CFGBlock::succ_begin(), clang::CFGBlock::succ_size(), and VisitTrueTest().
Referenced by VisitNodeImpl().
| PathDiagnosticPieceRef ConditionBRVisitor::VisitTrueTest | ( | const Expr * | Cond, |
| BugReporterContext & | BRC, | ||
| PathSensitiveBugReport & | R, | ||
| const ExplodedNode * | N, | ||
| bool | TookTrue ) |
Definition at line 2822 of file BugReporterVisitors.cpp.
References clang::cast(), clang::ento::ExplodedNode::getFirstPred(), clang::ento::BugReporterContext::getSourceManager(), clang::ento::ExplodedNode::getStackFrame(), clang::ento::ExplodedNode::getState(), clang::ento::BugReporterContext::getStateManager(), clang::Stmt::getStmtClass(), clang::ento::ProgramStateManager::haveEqualConstraints(), clang::Expr::IgnoreParenCasts(), clang::ento::DefinedSVal::isValid(), and VisitTrueTest().
Referenced by VisitNodeImpl(), VisitTerminator(), and VisitTrueTest().
| PathDiagnosticPieceRef ConditionBRVisitor::VisitTrueTest | ( | const Expr * | Cond, |
| const BinaryOperator * | BExpr, | ||
| BugReporterContext & | BRC, | ||
| PathSensitiveBugReport & | R, | ||
| const ExplodedNode * | N, | ||
| bool | TookTrue, | ||
| bool | IsAssuming ) |
Definition at line 2989 of file BugReporterVisitors.cpp.
References clang::BinaryOperator::getLHS(), clang::BinaryOperator::getOpcode(), clang::BinaryOperator::getOpcodeStr(), clang::BinaryOperator::getRHS(), clang::ento::BugReporterContext::getSourceManager(), clang::ento::ExplodedNode::getStackFrame(), clang::Expr::IgnoreParenCasts(), clang::BinaryOperator::isAssignmentOp(), clang::BinaryOperator::isComparisonOp(), isVarAnInterestingCondition(), patternMatch(), VisitConditionVariable(), and WillBeUsedForACondition.
| PathDiagnosticPieceRef ConditionBRVisitor::VisitTrueTest | ( | const Expr * | Cond, |
| const DeclRefExpr * | DR, | ||
| BugReporterContext & | BRC, | ||
| PathSensitiveBugReport & | R, | ||
| const ExplodedNode * | N, | ||
| bool | TookTrue, | ||
| bool | IsAssuming ) |
Definition at line 3138 of file BugReporterVisitors.cpp.
References clang::DeclRefExpr::getDecl(), clang::ento::BugReporterContext::getSourceManager(), clang::ento::ExplodedNode::getStackFrame(), isInterestingExpr(), isVarAnInterestingCondition(), printValue(), and WillBeUsedForACondition.
| PathDiagnosticPieceRef ConditionBRVisitor::VisitTrueTest | ( | const Expr * | Cond, |
| const MemberExpr * | ME, | ||
| BugReporterContext & | BRC, | ||
| PathSensitiveBugReport & | R, | ||
| const ExplodedNode * | N, | ||
| bool | TookTrue, | ||
| bool | IsAssuming ) |
Definition at line 3174 of file BugReporterVisitors.cpp.
References clang::MemberExpr::getMemberDecl(), clang::MemberExpr::getMemberLoc(), clang::NamedDecl::getName(), clang::ento::BugReporterContext::getSourceManager(), clang::ento::ExplodedNode::getStackFrame(), isInterestingExpr(), clang::ento::DefinedSVal::isValid(), clang::SourceLocation::isValid(), isVarAnInterestingCondition(), printValue(), and WillBeUsedForACondition.