clang 19.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.


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


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)


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 

◆ getInnerPointerType() [1/2]

static QualType getInnerPointerType ( CheckerContext  C,
const CXXRecordDecl RD 

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 

◆ getPointerTypeFromTemplateArg()

static QualType getPointerTypeFromTemplateArg ( const CallEvent Call,
CheckerContext C 

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 

Definition at line 103 of file SmartPtrModeling.cpp.

Referenced by isStdBasicOstream(), and isStdSmartPtr().

◆ isPotentiallyComparisionOpCall()

static bool isPotentiallyComparisionOpCall ( const CallEvent Call)

◆ isStdBasicOstream()

bool isStdBasicOstream ( const Expr E)

◆ isStdFunctionCall()

static bool isStdFunctionCall ( const CallEvent Call)

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)

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)

◆ removeTrackedSubregions()

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

Definition at line 160 of file SmartPtrModeling.cpp.

◆ updateSwappedRegion()

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

Definition at line 172 of file SmartPtrModeling.cpp.

Variable Documentation


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

Definition at line 242 of file SmartPtrModeling.cpp.

Referenced by isStdBasicOstream().


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

Definition at line 112 of file SmartPtrModeling.cpp.

Referenced by isStdSmartPtr().