14 #ifndef LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_RETAINCOUNTCHECKER_H 15 #define LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_RETAINCOUNTCHECKER_H 36 #include "llvm/ADT/DenseMap.h" 37 #include "llvm/ADT/FoldingSet.h" 38 #include "llvm/ADT/ImmutableList.h" 39 #include "llvm/ADT/ImmutableMap.h" 40 #include "llvm/ADT/STLExtras.h" 41 #include "llvm/ADT/SmallString.h" 42 #include "llvm/ADT/StringExtras.h" 97 unsigned RawObjectKind : 3;
108 unsigned RawIvarAccessHistory : 2;
112 : Cnt(cnt), ACnt(acnt), T(t), RawKind(static_cast<unsigned>(k)),
113 RawObjectKind(static_cast<unsigned>(o)),
114 RawIvarAccessHistory(static_cast<unsigned>(IvarAccess)) {
115 assert(
getKind() == k &&
"not enough bits for the kind");
116 assert(
getObjKind() == o &&
"not enough bits for the object kind");
124 return static_cast<ObjKind>(RawObjectKind);
218 return getKind() == X.
getKind() && Cnt == X.Cnt && ACnt == X.ACnt &&
228 ID.AddInteger(RawKind);
231 ID.AddInteger(RawObjectKind);
232 ID.AddInteger(RawIvarAccessHistory);
235 void print(raw_ostream &Out)
const;
241 check::BeginFunction,
243 check::PostStmt<BlockExpr>,
244 check::PostStmt<CastExpr>,
245 check::PostStmt<ObjCArrayLiteral>,
246 check::PostStmt<ObjCDictionaryLiteral>,
247 check::PostStmt<ObjCBoxedExpr>,
248 check::PostStmt<ObjCIvarRefExpr>,
250 check::RegionChanges,
266 mutable std::unique_ptr<RetainSummaryManager> Summaries;
270 bool TrackObjCAndCFObjects =
false;
273 bool TrackOSObjects =
false;
276 bool TrackNSCFStartParam =
false;
283 new RetainSummaryManager(Ctx, TrackObjCAndCFObjects, TrackOSObjects));
292 const char *NL,
const char *Sep)
const override;
306 void checkSummary(
const RetainSummary &Summ,
const CallEvent &Call,
309 void processSummaryOfInlined(
const RetainSummary &Summ,
316 bool Assumption)
const;
364 return DeallocSentTag;
387 auto Method = dyn_cast_or_null<ObjCMethodDecl>(SFC->
getDecl());
388 if (!Method || !Method->isPropertyAccessor())
RefVal operator+(size_t i) const
RefVal operator^(Kind k) const
RetainSummaryManager & getSummaryManager(CheckerContext &C) const
ObjKind
Determines the object kind of a tracked object.
A (possibly-)qualified type.
bool isReturnedOwned() const
Stmt - This represents one statement.
bool hasSameState(const RefVal &X) const
Defines the SourceManager interface.
unsigned getCombinedCounts() const
RetainSummaryManager & getSummaryManager(ASTContext &Ctx) const
RefVal withIvarAccess() const
unsigned getCount() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
RefVal releaseViaIvar() const
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp, [NSNumber numberWithInt:42]];.
i32 captured_struct **param SharedsTy A type which contains references the shared variables *param Shareds Context with the list of shared variables from the p *TaskFunction *param Data Additional data for task generation like final * state
void setCount(unsigned i)
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
IvarAccessHistory
Tracks how an object referenced by an ivar has been used.
bool isSynthesizedAccessor(const StackFrameContext *SFC)
Returns true if this stack frame is for an Objective-C method that is a property getter or setter who...
IvarAccessHistory getIvarAccessHistory() const
Returns what the analyzer knows about direct accesses to a particular instance variable.
This represents one expression.
Defines the clang::LangOptions interface.
void setAutoreleaseCount(unsigned i)
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
bool isReturnedNotOwned() const
bool isBodyAutosynthesized() const
Checks if the body of the Decl is generated by the BodyFarm.
void Profile(llvm::FoldingSetNodeID &ID) const
void print(raw_ostream &Out) const
ProgramPoints can be "tagged" as representing points specific to a given analysis entity...
unsigned getAutoreleaseCount() const
SVal - This represents a symbolic expression, which can be either an L-value or an R-value...
A class responsible for cleaning up unused symbols.
ObjCBoxedExpr - used for generalized expression boxing.
bool operator==(const RefVal &X) const
Dataflow Directional Tag Classes.
ASTContext & getASTContext()
RefVal autorelease() const
static RefVal makeOwned(ObjKind o, QualType t)
Create a state for an object whose lifetime is the responsibility of the current function, at least partially.
Represents an abstract call to a function or method along a particular path.
const Decl * getDecl() const
RefVal operator-(size_t i) const
const RefVal * getRefBinding(ProgramStateRef State, SymbolRef Sym)
const CheckerProgramPointTag & getDeallocSentTag() const
ObjCIvarRefExpr - A reference to an ObjC instance variable.
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
static RefVal makeNotOwned(ObjKind o, QualType t)
Create a state for an object whose lifetime is not the responsibility of the current function...
A trivial tuple used to represent a source range.
An ArgEffect summarizes the retain count behavior on an argument or receiver to a function or method...
Tag that can use a checker name as a message provider (see SimpleProgramPointTag).
const CheckerProgramPointTag & getCastFailTag() const
AnalysisDeclContext * getAnalysisDeclContext() const
ObjKind getObjKind() const
RetEffect summarizes a call's retain/release behavior with respect to its return value.