15 #ifndef LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_RETAINCOUNTCHECKER_H 16 #define LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_RETAINCOUNTCHECKER_H 37 #include "llvm/ADT/DenseMap.h" 38 #include "llvm/ADT/FoldingSet.h" 39 #include "llvm/ADT/ImmutableList.h" 40 #include "llvm/ADT/ImmutableMap.h" 41 #include "llvm/ADT/STLExtras.h" 42 #include "llvm/ADT/SmallString.h" 43 #include "llvm/ADT/StringExtras.h" 98 unsigned RawObjectKind : 3;
109 unsigned RawIvarAccessHistory : 2;
113 : Cnt(cnt), ACnt(acnt), T(t), RawKind(static_cast<unsigned>(k)),
114 RawObjectKind(static_cast<unsigned>(o)),
115 RawIvarAccessHistory(static_cast<unsigned>(IvarAccess)) {
116 assert(
getKind() == k &&
"not enough bits for the kind");
117 assert(
getObjKind() == o &&
"not enough bits for the object kind");
125 return static_cast<ObjKind>(RawObjectKind);
219 return getKind() == X.
getKind() && Cnt == X.Cnt && ACnt == X.ACnt &&
229 ID.AddInteger(RawKind);
232 ID.AddInteger(RawObjectKind);
233 ID.AddInteger(RawIvarAccessHistory);
236 void print(raw_ostream &Out)
const;
242 check::BeginFunction,
244 check::PostStmt<BlockExpr>,
245 check::PostStmt<CastExpr>,
246 check::PostStmt<ObjCArrayLiteral>,
247 check::PostStmt<ObjCDictionaryLiteral>,
248 check::PostStmt<ObjCBoxedExpr>,
249 check::PostStmt<ObjCIvarRefExpr>,
251 check::RegionChanges,
254 mutable std::unique_ptr<RefCountBug> useAfterRelease, releaseNotOwned;
255 mutable std::unique_ptr<RefCountBug> deallocNotOwned;
256 mutable std::unique_ptr<RefCountBug> overAutorelease, returnNotOwnedForOwned;
257 mutable std::unique_ptr<RefCountBug> leakWithinFunction, leakAtReturn;
259 mutable std::unique_ptr<RetainSummaryManager> Summaries;
261 static constexpr
const char *DeallocTagDescription =
"DeallocSent";
264 bool TrackObjCAndCFObjects =
false;
267 bool TrackOSObjects =
false;
280 Summaries.reset(
new RetainSummaryManager(
281 Ctx, ARCEnabled, TrackObjCAndCFObjects, TrackOSObjects));
283 assert(Summaries->isARCEnabled() == ARCEnabled);
293 const char *NL,
const char *Sep)
const override;
307 void checkSummary(
const RetainSummary &Summ,
const CallEvent &Call,
310 void processSummaryOfInlined(
const RetainSummary &Summ,
317 bool Assumption)
const;
382 auto Method = dyn_cast_or_null<ObjCMethodDecl>(SFC->
getDecl());
383 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
ProgramStateRef setRefBinding(ProgramStateRef State, SymbolRef Sym, RefVal Val)
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
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
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...
ProgramStateRef removeRefBinding(ProgramStateRef State, SymbolRef Sym)
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)
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...
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
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...
AnalysisDeclContext * getAnalysisDeclContext() const
const LangOptions & getLangOpts() const
ObjKind getObjKind() const
RetEffect summarizes a call's retain/release behavior with respect to its return value.