class ConditionBRVisitor

Declaration

class ConditionBRVisitor : public BugReporterVisitor { /* full declaration omitted */ };

Description

Visitor that tries to report interesting diagnostics from conditions.

Declared at: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h:436

Inherits from: BugReporterVisitor

Member Variables

private static const llvm::StringLiteral GenericTrueMessage = "Assuming the condition is true"
private static const llvm::StringLiteral GenericFalseMessage = "Assuming the condition is false"

Method Overview

  • public void Profile(llvm::FoldingSetNodeID & ID) const
  • public clang::ento::PathDiagnosticPieceRef VisitConditionVariable(llvm::StringRef LhsString, const clang::Expr * CondVarExpr, clang::ento::BugReporterContext & BRC, clang::ento::PathSensitiveBugReport & R, const clang::ento::ExplodedNode * N, bool TookTrue)
  • public clang::ento::PathDiagnosticPieceRef VisitNode(const clang::ento::ExplodedNode * N, clang::ento::BugReporterContext & BRC, clang::ento::PathSensitiveBugReport & BR)
  • public clang::ento::PathDiagnosticPieceRef VisitNodeImpl(const clang::ento::ExplodedNode * N, clang::ento::BugReporterContext & BRC, clang::ento::PathSensitiveBugReport & BR)
  • public clang::ento::PathDiagnosticPieceRef VisitTerminator(const clang::Stmt * Term, const clang::ento::ExplodedNode * N, const clang::CFGBlock * SrcBlk, const clang::CFGBlock * DstBlk, clang::ento::PathSensitiveBugReport & R, clang::ento::BugReporterContext & BRC)
  • public clang::ento::PathDiagnosticPieceRef VisitTrueTest(const clang::Expr * Cond, clang::ento::BugReporterContext & BRC, clang::ento::PathSensitiveBugReport & R, const clang::ento::ExplodedNode * N, bool TookTrue)
  • public clang::ento::PathDiagnosticPieceRef VisitTrueTest(const clang::Expr * Cond, const clang::DeclRefExpr * DR, clang::ento::BugReporterContext & BRC, clang::ento::PathSensitiveBugReport & R, const clang::ento::ExplodedNode * N, bool TookTrue, bool IsAssuming)
  • public clang::ento::PathDiagnosticPieceRef VisitTrueTest(const clang::Expr * Cond, const clang::BinaryOperator * BExpr, clang::ento::BugReporterContext & BRC, clang::ento::PathSensitiveBugReport & R, const clang::ento::ExplodedNode * N, bool TookTrue, bool IsAssuming)
  • public clang::ento::PathDiagnosticPieceRef VisitTrueTest(const clang::Expr * Cond, const clang::MemberExpr * ME, clang::ento::BugReporterContext & BRC, clang::ento::PathSensitiveBugReport & R, const clang::ento::ExplodedNode * N, bool TookTrue, bool IsAssuming)
  • public static const char * getTag()
  • public static bool isPieceMessageGeneric(const clang::ento::PathDiagnosticPiece * Piece)
  • public bool patternMatch(const clang::Expr * Ex, const clang::Expr * ParentEx, llvm::raw_ostream & Out, clang::ento::BugReporterContext & BRC, clang::ento::PathSensitiveBugReport & R, const clang::ento::ExplodedNode * N, Optional<bool> & prunable, bool IsSameFieldName)
  • public bool printValue(const clang::Expr * CondVarExpr, llvm::raw_ostream & Out, const clang::ento::ExplodedNode * N, bool TookTrue, bool IsAssuming)

Inherited from BugReporterVisitor:

Inherited from FoldingSetBase::Node:

Methods

void Profile(llvm::FoldingSetNodeID& ID) const

Declared at: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h:444

Parameters

llvm::FoldingSetNodeID& ID

clang::ento::PathDiagnosticPieceRef
VisitConditionVariable(
    llvm::StringRef LhsString,
    const clang::Expr* CondVarExpr,
    clang::ento::BugReporterContext& BRC,
    clang::ento::PathSensitiveBugReport& R,
    const clang::ento::ExplodedNode* N,
    bool TookTrue)

Declared at: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h:489

Parameters

llvm::StringRef LhsString
const clang::Expr* CondVarExpr
clang::ento::BugReporterContext& BRC
clang::ento::PathSensitiveBugReport& R
const clang::ento::ExplodedNode* N
bool TookTrue

clang::ento::PathDiagnosticPieceRef VisitNode(
    const clang::ento::ExplodedNode* N,
    clang::ento::BugReporterContext& BRC,
    clang::ento::PathSensitiveBugReport& BR)

Description

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 \ref 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.

Declared at: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h:453

Parameters

const clang::ento::ExplodedNode* N
clang::ento::BugReporterContext& BRC
clang::ento::PathSensitiveBugReport& BR

clang::ento::PathDiagnosticPieceRef VisitNodeImpl(
    const clang::ento::ExplodedNode* N,
    clang::ento::BugReporterContext& BRC,
    clang::ento::PathSensitiveBugReport& BR)

Declared at: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h:457

Parameters

const clang::ento::ExplodedNode* N
clang::ento::BugReporterContext& BRC
clang::ento::PathSensitiveBugReport& BR

clang::ento::PathDiagnosticPieceRef
VisitTerminator(
    const clang::Stmt* Term,
    const clang::ento::ExplodedNode* N,
    const clang::CFGBlock* SrcBlk,
    const clang::CFGBlock* DstBlk,
    clang::ento::PathSensitiveBugReport& R,
    clang::ento::BugReporterContext& BRC)

Declared at: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h:462

Parameters

const clang::Stmt* Term
const clang::ento::ExplodedNode* N
const clang::CFGBlock* SrcBlk
const clang::CFGBlock* DstBlk
clang::ento::PathSensitiveBugReport& R
clang::ento::BugReporterContext& BRC

clang::ento::PathDiagnosticPieceRef VisitTrueTest(
    const clang::Expr* Cond,
    clang::ento::BugReporterContext& BRC,
    clang::ento::PathSensitiveBugReport& R,
    const clang::ento::ExplodedNode* N,
    bool TookTrue)

Declared at: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h:466

Parameters

const clang::Expr* Cond
clang::ento::BugReporterContext& BRC
clang::ento::PathSensitiveBugReport& R
const clang::ento::ExplodedNode* N
bool TookTrue

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

Declared at: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h:471

Parameters

const clang::Expr* Cond
const clang::DeclRefExpr* DR
clang::ento::BugReporterContext& BRC
clang::ento::PathSensitiveBugReport& R
const clang::ento::ExplodedNode* N
bool TookTrue
bool IsAssuming

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

Declared at: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h:478

Parameters

const clang::Expr* Cond
const clang::BinaryOperator* BExpr
clang::ento::BugReporterContext& BRC
clang::ento::PathSensitiveBugReport& R
const clang::ento::ExplodedNode* N
bool TookTrue
bool IsAssuming

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

Declared at: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h:482

Parameters

const clang::Expr* Cond
const clang::MemberExpr* ME
clang::ento::BugReporterContext& BRC
clang::ento::PathSensitiveBugReport& R
const clang::ento::ExplodedNode* N
bool TookTrue
bool IsAssuming

static const char* getTag()

Description

Return the tag associated with this visitor. This tag will be used to make all PathDiagnosticPieces created by this visitor.

Declared at: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h:451

static bool isPieceMessageGeneric(
    const clang::ento::PathDiagnosticPiece* Piece)

Declared at: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h:514

Parameters

const clang::ento::PathDiagnosticPiece* Piece

bool patternMatch(
    const clang::Expr* Ex,
    const clang::Expr* ParentEx,
    llvm::raw_ostream& Out,
    clang::ento::BugReporterContext& BRC,
    clang::ento::PathSensitiveBugReport& R,
    const clang::ento::ExplodedNode* N,
    Optional<bool>& prunable,
    bool IsSameFieldName)

Declared at: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h:505

Parameters

const clang::Expr* Ex
const clang::Expr* ParentEx
llvm::raw_ostream& Out
clang::ento::BugReporterContext& BRC
clang::ento::PathSensitiveBugReport& R
const clang::ento::ExplodedNode* N
Optional<bool>& prunable
bool IsSameFieldName

bool printValue(
    const clang::Expr* CondVarExpr,
    llvm::raw_ostream& Out,
    const clang::ento::ExplodedNode* N,
    bool TookTrue,
    bool IsAssuming)

Description

Tries to print the value of the given expression.

Declared at: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h:502

Parameters

const clang::Expr* CondVarExpr
The expression to print its value.
llvm::raw_ostream& Out
The stream to print.
const clang::ento::ExplodedNode* N
The node where we encountered the condition.
bool TookTrue
Whether we took the \c true branch of the condition.
bool IsAssuming

Returns

Whether the print was successful. (The printing is successful if we model the value and we could obtain it.)