clang 20.0.0git
Public Member Functions | Static Public Member Functions | List of all members
clang::ento::ConditionBRVisitor Class Referencefinal

Visitor that tries to report interesting diagnostics from conditions. More...

#include "clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h"

Inheritance diagram for clang::ento::ConditionBRVisitor:
Inheritance graph
[legend]

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, 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 &&)
 
BugReporterVisitoroperator= (const BugReporterVisitor &)=delete
 
BugReporterVisitoroperator= (BugReporterVisitor &&)=delete
 
virtual ~BugReporterVisitor ()
 
virtual PathDiagnosticPieceRef VisitNode (const ExplodedNode *Succ, BugReporterContext &BRC, PathSensitiveBugReport &BR)=0
 Return a diagnostic piece which should be associated with the given node.
 
virtual void finalizeVisitor (BugReporterContext &BRC, const ExplodedNode *EndPathNode, PathSensitiveBugReport &BR)
 Last function called on the visitor, no further calls to VisitNode would follow.
 
virtual PathDiagnosticPieceRef getEndPath (BugReporterContext &BRC, const ExplodedNode *N, PathSensitiveBugReport &BR)
 Provide custom definition for the final diagnostic piece on the path - the piece, which is displayed before the path is expanded.
 
virtual void Profile (llvm::FoldingSetNodeID &ID) const =0
 

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.
 

Detailed Description

Visitor that tries to report interesting diagnostics from conditions.

Definition at line 447 of file BugReporterVisitors.h.

Member Function Documentation

◆ getTag()

const char * ConditionBRVisitor::getTag ( )
static

Return the tag associated with this visitor.

This tag will be used to make all PathDiagnosticPieces created by this visitor.

Definition at line 2767 of file BugReporterVisitors.cpp.

Referenced by eventsDescribeSameCondition().

◆ isPieceMessageGeneric()

bool ConditionBRVisitor::isPieceMessageGeneric ( const PathDiagnosticPiece Piece)
static

◆ patternMatch()

bool ConditionBRVisitor::patternMatch ( const Expr Ex,
const Expr ParentEx,
raw_ostream &  Out,
BugReporterContext BRC,
PathSensitiveBugReport R,
const ExplodedNode N,
std::optional< bool > &  prunable,
bool  IsSameFieldName 
)

◆ printValue()

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.

Parameters
CondVarExprThe expression to print its value.
OutThe stream to print.
NThe node where we encountered the condition.
TookTrueWhether we took the true branch of the condition.
Returns
Whether the print was successful. (The printing is successful if we model the value and we could obtain it.)

Definition at line 3263 of file BugReporterVisitors.cpp.

References getConcreteIntegerValue(), clang::Expr::getType(), clang::Type::isBooleanType(), clang::Type::isIntegralOrEnumerationType(), clang::Type::isObjCObjectPointerType(), and clang::Type::isPointerType().

◆ Profile()

void clang::ento::ConditionBRVisitor::Profile ( llvm::FoldingSetNodeID &  ID) const
inlineoverridevirtual

Implements clang::ento::BugReporterVisitor.

Definition at line 455 of file BugReporterVisitors.h.

References ID.

◆ VisitConditionVariable()

PathDiagnosticPieceRef ConditionBRVisitor::VisitConditionVariable ( StringRef  LhsString,
const Expr CondVarExpr,
BugReporterContext BRC,
PathSensitiveBugReport R,
const ExplodedNode N,
bool  TookTrue 
)

◆ VisitNode()

PathDiagnosticPieceRef ConditionBRVisitor::VisitNode ( const ExplodedNode Succ,
BugReporterContext BRC,
PathSensitiveBugReport BR 
)
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 2770 of file BugReporterVisitors.cpp.

◆ VisitNodeImpl()

PathDiagnosticPieceRef ConditionBRVisitor::VisitNodeImpl ( const ExplodedNode N,
BugReporterContext BRC,
PathSensitiveBugReport BR 
)

◆ VisitTerminator()

PathDiagnosticPieceRef ConditionBRVisitor::VisitTerminator ( const Stmt Term,
const ExplodedNode N,
const CFGBlock SrcBlk,
const CFGBlock DstBlk,
PathSensitiveBugReport R,
BugReporterContext BRC 
)

◆ VisitTrueTest() [1/4]

PathDiagnosticPieceRef ConditionBRVisitor::VisitTrueTest ( const Expr Cond,
BugReporterContext BRC,
PathSensitiveBugReport R,
const ExplodedNode N,
bool  TookTrue 
)

◆ VisitTrueTest() [2/4]

PathDiagnosticPieceRef ConditionBRVisitor::VisitTrueTest ( const Expr Cond,
const BinaryOperator BExpr,
BugReporterContext BRC,
PathSensitiveBugReport R,
const ExplodedNode N,
bool  TookTrue,
bool  IsAssuming 
)

◆ VisitTrueTest() [3/4]

PathDiagnosticPieceRef ConditionBRVisitor::VisitTrueTest ( const Expr Cond,
const DeclRefExpr DR,
BugReporterContext BRC,
PathSensitiveBugReport R,
const ExplodedNode N,
bool  TookTrue,
bool  IsAssuming 
)

◆ VisitTrueTest() [4/4]

PathDiagnosticPieceRef ConditionBRVisitor::VisitTrueTest ( const Expr Cond,
const MemberExpr ME,
BugReporterContext BRC,
PathSensitiveBugReport R,
const ExplodedNode N,
bool  TookTrue,
bool  IsAssuming 
)

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