clang 20.0.0git
|
#include "RetainCountDiagnostics.h"
#include "RetainCountChecker.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include <optional>
Go to the source code of this file.
Classes | |
class | clang::ento::retaincountchecker::RefCountReportVisitor |
class | clang::ento::retaincountchecker::RefLeakReportVisitor |
Namespaces | |
namespace | clang |
The JSON file list parser is used to communicate input to InstallAPI. | |
namespace | clang::ento |
namespace | clang::ento::retaincountchecker |
Typedefs | |
using | Bindings = llvm::SmallVector< std::pair< const MemRegion *, SVal >, 4 > |
Functions | |
static bool | isNumericLiteralExpression (const Expr *E) |
static std::string | getPrettyTypeName (QualType QT) |
If type represents a pointer to CXXRecordDecl, and is not a typedef, return the decl name. | |
static bool | shouldGenerateNote (llvm::raw_string_ostream &os, const RefVal *PrevT, const RefVal &CurrV, bool DeallocSent) |
Write information about the type state change to os , return whether the note should be generated. | |
static std::optional< unsigned > | findArgIdxOfSymbol (ProgramStateRef CurrSt, const LocationContext *LCtx, SymbolRef &Sym, std::optional< CallEventRef<> > CE) |
Finds argument index of the out paramter in the call S corresponding to the symbol Sym . | |
static std::optional< std::string > | findMetaClassAlloc (const Expr *Callee) |
static std::string | findAllocatedObjectName (const Stmt *S, QualType QT) |
static void | generateDiagnosticsForCallLike (ProgramStateRef CurrSt, const LocationContext *LCtx, const RefVal &CurrV, SymbolRef &Sym, const Stmt *S, llvm::raw_string_ostream &os) |
static const ExplodedNode * | getCalleeNode (const ExplodedNode *Pred) |
Find the first node with the parent stack frame. | |
static std::shared_ptr< PathDiagnosticEventPiece > | annotateConsumedSummaryMismatch (const ExplodedNode *N, CallExitBegin &CallExitLoc, const SourceManager &SM, CallEventManager &CEMgr) |
Insert a diagnostic piece at function exit if a function parameter is annotated as "os_consumed", but it does not actually consume the reference. | |
static std::shared_ptr< PathDiagnosticEventPiece > | annotateStartParameter (const ExplodedNode *N, SymbolRef Sym, const SourceManager &SM) |
Annotate the parameter at the analysis entry point. | |
static std::optional< std::string > | describeRegion (const MemRegion *MR) |
Bindings | getAllVarBindingsForSymbol (ProgramStateManager &Manager, const ExplodedNode *Node, SymbolRef Sym) |
static AllocationInfo | GetAllocationSite (ProgramStateManager &StateMgr, const ExplodedNode *N, SymbolRef Sym) |
using Bindings = llvm::SmallVector<std::pair<const MemRegion *, SVal>, 4> |
Definition at line 613 of file RetainCountDiagnostics.cpp.
|
static |
Insert a diagnostic piece at function exit if a function parameter is annotated as "os_consumed", but it does not actually consume the reference.
Definition at line 373 of file RetainCountDiagnostics.cpp.
References clang::Call, clang::ento::PathDiagnosticLocation::create(), clang::Decl::getASTContext(), getCalleeNode(), clang::ento::CallEventManager::getCaller(), clang::ento::retaincountchecker::RefVal::getCount(), clang::NamedDecl::getNameForDiagnostic(), clang::ASTContext::getPrintingPolicy(), clang::ento::retaincountchecker::getRefBinding(), clang::ento::ExplodedNode::getStackFrame(), clang::ento::ExplodedNode::getState(), clang::Decl::hasAttr(), and SM.
Referenced by clang::ento::retaincountchecker::RefCountReportVisitor::VisitNode().
|
static |
Annotate the parameter at the analysis entry point.
Definition at line 423 of file RetainCountDiagnostics.cpp.
References clang::ento::retaincountchecker::RefVal::getCount(), clang::CFG::getEntry(), clang::ento::ExplodedNode::getFirstPred(), clang::ento::ExplodedNode::getLocationAs(), clang::CFGBlock::getParent(), clang::ento::retaincountchecker::getRefBinding(), getRegion(), clang::ento::ExplodedNode::getState(), s, and SM.
Referenced by clang::ento::retaincountchecker::RefCountReportVisitor::VisitNode().
|
static |
Definition at line 605 of file RetainCountDiagnostics.cpp.
Referenced by clang::ento::retaincountchecker::RefLeakReportVisitor::getEndPath().
Definition at line 203 of file RetainCountDiagnostics.cpp.
References findMetaClassAlloc(), and getPrettyTypeName().
Referenced by generateDiagnosticsForCallLike().
|
static |
Finds argument index of the out paramter in the call S
corresponding to the symbol Sym
.
If none found, returns std::nullopt.
Definition at line 171 of file RetainCountDiagnostics.cpp.
Referenced by generateDiagnosticsForCallLike().
|
static |
Definition at line 185 of file RetainCountDiagnostics.cpp.
References clang::Decl::getDeclContext(), and clang::NamedDecl::getNameAsString().
Referenced by findAllocatedObjectName().
|
static |
Definition at line 210 of file RetainCountDiagnostics.cpp.
References clang::Call, clang::ento::CF, findAllocatedObjectName(), findArgIdxOfSymbol(), clang::ento::Generalized, clang::Decl::getASTContext(), clang::ento::CallEventManager::getCall(), clang::NamedDecl::getNameForDiagnostic(), clang::ento::CallEventManager::getObjCMethodCall(), clang::ento::retaincountchecker::RefVal::getObjKind(), clang::ObjCObjectPointerType::getPointeeType(), clang::ASTContext::getPrintingPolicy(), clang::NamedDecl::getQualifiedNameAsString(), clang::ento::SymExpr::getType(), clang::ento::retaincountchecker::RefVal::isNotOwned(), clang::QualType::isNull(), clang::ento::retaincountchecker::RefVal::isOwned(), clang::Type::isVoidType(), clang::ento::ObjC, clang::ento::OCM_Message, clang::ento::OCM_PropertyAccess, clang::ento::OCM_Subscript, clang::ento::OS, clang::T, and X.
Referenced by clang::ento::retaincountchecker::RefCountReportVisitor::VisitNode().
|
static |
Definition at line 667 of file RetainCountDiagnostics.cpp.
References clang::ProgramPoint::getAs(), clang::ento::SVal::getAsSymbol(), clang::ento::ExplodedNode::getFirstPred(), clang::ento::ExplodedNode::getLocation(), clang::ento::ExplodedNode::getLocationContext(), clang::ento::MemRegion::getMemorySpace(), clang::ento::retaincountchecker::getRefBinding(), clang::ento::StoreManager::FindUniqueBinding::getRegion(), clang::LocationContext::getStackFrame(), clang::ento::ExplodedNode::getState(), clang::LocationContext::isParentOf(), clang::ento::ProgramStateManager::iterBindings(), clang::OMF_alloc, and clang::OMF_init.
Bindings getAllVarBindingsForSymbol | ( | ProgramStateManager & | Manager, |
const ExplodedNode * | Node, | ||
SymbolRef | Sym | ||
) |
Definition at line 638 of file RetainCountDiagnostics.cpp.
References clang::ento::ProgramStateManager::iterBindings(), Node, and clang::Result.
|
static |
Find the first node with the parent stack frame.
Definition at line 353 of file RetainCountDiagnostics.cpp.
References clang::ento::ExplodedNode::getFirstPred(), clang::LocationContext::getParent(), clang::LocationContext::getStackFrame(), clang::ento::ExplodedNode::getStackFrame(), and clang::StackFrameContext::inTopFrame().
Referenced by annotateConsumedSummaryMismatch().
|
static |
If type represents a pointer to CXXRecordDecl, and is not a typedef, return the decl name.
Otherwise, return the serialization of type.
Definition at line 84 of file RetainCountDiagnostics.cpp.
References clang::Type::getAs(), clang::Type::getAsCXXRecordDecl(), clang::QualType::getAsString(), clang::Type::getPointeeType(), and clang::QualType::isNull().
Referenced by findAllocatedObjectName(), and clang::ento::retaincountchecker::RefLeakReportVisitor::getEndPath().
Definition at line 75 of file RetainCountDiagnostics.cpp.
References E, and clang::isa().
Referenced by clang::ento::retaincountchecker::RefCountReportVisitor::VisitNode().
|
static |
Write information about the type state change to os
, return whether the note should be generated.
Definition at line 94 of file RetainCountDiagnostics.cpp.
References clang::ento::retaincountchecker::RefVal::getAutoreleaseCount(), clang::ento::retaincountchecker::RefVal::getCombinedCounts(), clang::ento::retaincountchecker::RefVal::getCount(), clang::ento::retaincountchecker::RefVal::getIvarAccessHistory(), clang::ento::retaincountchecker::RefVal::getKind(), clang::ento::retaincountchecker::RefVal::hasSameState(), clang::ento::retaincountchecker::RefVal::NotOwned, clang::ento::retaincountchecker::RefVal::Owned, clang::ento::retaincountchecker::RefVal::Released, clang::ento::retaincountchecker::RefVal::ReleasedAfterDirectAccess, clang::ento::retaincountchecker::RefVal::ReturnedNotOwned, and clang::ento::retaincountchecker::RefVal::ReturnedOwned.
Referenced by clang::ento::retaincountchecker::RefCountReportVisitor::VisitNode().