clang 20.0.0git
Namespaces | Functions | Variables
SmartPtrModeling.cpp File Reference
#include "Move.h"
#include "SmartPtr.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclarationName.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/Type.h"
#include "clang/Basic/LLVM.h"
#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.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/CallDescription.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/ErrorHandling.h"
#include <optional>
#include <string>

Go to the source code of this file.

Namespaces

namespace  clang
 The JSON file list parser is used to communicate input to InstallAPI.
 
namespace  clang::ento
 
namespace  clang::ento::smartptr
 

Functions

static bool hasStdClassWithName (const CXXRecordDecl *RD, ArrayRef< llvm::StringLiteral > Names)
 
static bool isStdSmartPtr (const CXXRecordDecl *RD)
 
static bool isStdSmartPtr (const Expr *E)
 
bool clang::ento::smartptr::isStdSmartPtrCall (const CallEvent &Call)
 Returns true if the event call is on smart pointer.
 
bool clang::ento::smartptr::isStdSmartPtr (const CXXRecordDecl *RD)
 
bool clang::ento::smartptr::isStdSmartPtr (const Expr *E)
 
bool clang::ento::smartptr::isNullSmartPtr (const ProgramStateRef State, const MemRegion *ThisRegion)
 Returns whether the smart pointer is null or not.
 
static TrackedRegionMapTy removeTrackedSubregions (TrackedRegionMapTy RegionMap, TrackedRegionMapTy::Factory &RegionMapFactory, const MemRegion *Region)
 
static ProgramStateRef updateSwappedRegion (ProgramStateRef State, const MemRegion *Region, const SVal *RegionInnerPointerVal)
 
static QualType getInnerPointerType (CheckerContext C, const CXXRecordDecl *RD)
 
static QualType getPointerTypeFromTemplateArg (const CallEvent &Call, CheckerContext &C)
 
static QualType getInnerPointerType (const CallEvent &Call, CheckerContext &C)
 
static void checkAndPrettyPrintRegion (llvm::raw_ostream &OS, const MemRegion *Region)
 
bool isStdBasicOstream (const Expr *E)
 
static bool isStdFunctionCall (const CallEvent &Call)
 
bool isStdOstreamOperatorCall (const CallEvent &Call)
 
static bool isPotentiallyComparisionOpCall (const CallEvent &Call)
 

Variables

constexpr llvm::StringLiteral STD_PTR_NAMES []
 
constexpr llvm::StringLiteral BASIC_OSTREAM_NAMES [] = {"basic_ostream"}
 

Function Documentation

◆ checkAndPrettyPrintRegion()

static void checkAndPrettyPrintRegion ( llvm::raw_ostream &  OS,
const MemRegion Region 
)
static

◆ getInnerPointerType() [1/2]

static QualType getInnerPointerType ( CheckerContext  C,
const CXXRecordDecl RD 
)
static

Definition at line 183 of file SmartPtrModeling.cpp.

References clang::C, and clang::Decl::isInStdNamespace().

Referenced by getInnerPointerType().

◆ getInnerPointerType() [2/2]

static QualType getInnerPointerType ( const CallEvent Call,
CheckerContext C 
)
static

◆ getPointerTypeFromTemplateArg()

static QualType getPointerTypeFromTemplateArg ( const CallEvent Call,
CheckerContext C 
)
static

Definition at line 201 of file SmartPtrModeling.cpp.

References clang::C, and clang::Call.

◆ hasStdClassWithName()

static bool hasStdClassWithName ( const CXXRecordDecl RD,
ArrayRef< llvm::StringLiteral >  Names 
)
static

Definition at line 103 of file SmartPtrModeling.cpp.

Referenced by isStdBasicOstream(), and isStdSmartPtr().

◆ isPotentiallyComparisionOpCall()

static bool isPotentiallyComparisionOpCall ( const CallEvent Call)
static

◆ isStdBasicOstream()

bool isStdBasicOstream ( const Expr E)

◆ isStdFunctionCall()

static bool isStdFunctionCall ( const CallEvent Call)
static

Definition at line 249 of file SmartPtrModeling.cpp.

References clang::Call.

Referenced by isPotentiallyComparisionOpCall(), and isStdOstreamOperatorCall().

◆ isStdOstreamOperatorCall()

bool isStdOstreamOperatorCall ( const CallEvent Call)

◆ isStdSmartPtr() [1/2]

static bool isStdSmartPtr ( const CXXRecordDecl RD)
static

Definition at line 115 of file SmartPtrModeling.cpp.

References hasStdClassWithName(), and STD_PTR_NAMES.

Referenced by isStdOstreamOperatorCall(), and isStdSmartPtr().

◆ isStdSmartPtr() [2/2]

static bool isStdSmartPtr ( const Expr E)
static

◆ removeTrackedSubregions()

static TrackedRegionMapTy removeTrackedSubregions ( TrackedRegionMapTy  RegionMap,
TrackedRegionMapTy::Factory &  RegionMapFactory,
const MemRegion Region 
)
static

Definition at line 160 of file SmartPtrModeling.cpp.

References E.

◆ updateSwappedRegion()

static ProgramStateRef updateSwappedRegion ( ProgramStateRef  State,
const MemRegion Region,
const SVal RegionInnerPointerVal 
)
static

Definition at line 172 of file SmartPtrModeling.cpp.

Variable Documentation

◆ BASIC_OSTREAM_NAMES

constexpr llvm::StringLiteral BASIC_OSTREAM_NAMES[] = {"basic_ostream"}
constexpr

Definition at line 242 of file SmartPtrModeling.cpp.

Referenced by isStdBasicOstream().

◆ STD_PTR_NAMES

constexpr llvm::StringLiteral STD_PTR_NAMES[]
constexpr
Initial value:
= {"shared_ptr", "unique_ptr",
"weak_ptr"}

Definition at line 112 of file SmartPtrModeling.cpp.

Referenced by isStdSmartPtr().