clang  14.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/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/StringMap.h"
#include "llvm/Support/ErrorHandling.h"
#include <string>
Include dependency graph for SmartPtrModeling.cpp:

Go to the source code of this file.

Namespaces

 clang
 
 clang::ento
 
 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. More...
 
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. More...
 
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

Definition at line 223 of file SmartPtrModeling.cpp.

◆ getInnerPointerType() [1/2]

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

Definition at line 181 of file SmartPtrModeling.cpp.

References clang::Decl::isInStdNamespace().

Referenced by getInnerPointerType().

◆ getInnerPointerType() [2/2]

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

Definition at line 213 of file SmartPtrModeling.cpp.

References getInnerPointerType(), and clang::DeclContext::getParent().

◆ getPointerTypeFromTemplateArg()

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

Definition at line 199 of file SmartPtrModeling.cpp.

◆ hasStdClassWithName()

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

Definition at line 101 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

◆ isStdOstreamOperatorCall()

bool isStdOstreamOperatorCall ( const CallEvent &  Call)

◆ isStdSmartPtr() [1/2]

static bool isStdSmartPtr ( const CXXRecordDecl RD)
static

◆ 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 158 of file SmartPtrModeling.cpp.

◆ updateSwappedRegion()

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

Definition at line 170 of file SmartPtrModeling.cpp.

References State.

Variable Documentation

◆ BASIC_OSTREAM_NAMES

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

Definition at line 240 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 110 of file SmartPtrModeling.cpp.

Referenced by isStdSmartPtr().