clang  14.0.0git
RetainCountChecker.h
Go to the documentation of this file.
1 //==--- RetainCountChecker.h - Checks for leaks and other issues -*- C++ -*--//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the methods for RetainCountChecker, which implements
10 // a reference count checker for Core Foundation and Cocoa on (Mac OS X).
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_RETAINCOUNTCHECKER_H
15 #define LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_RETAINCOUNTCHECKER_H
16 
18 #include "RetainCountDiagnostics.h"
19 #include "clang/AST/Attr.h"
20 #include "clang/AST/DeclCXX.h"
21 #include "clang/AST/DeclObjC.h"
22 #include "clang/AST/ParentMap.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"
43 #include <cstdarg>
44 #include <utility>
45 
46 namespace clang {
47 namespace ento {
48 namespace retaincountchecker {
49 
50 /// Metadata on reference.
51 class RefVal {
52 public:
53  enum Kind {
54  Owned = 0, // Owning reference.
55  NotOwned, // Reference is not owned by still valid (not freed).
56  Released, // Object has been released.
57  ReturnedOwned, // Returned object passes ownership to caller.
58  ReturnedNotOwned, // Return object does not pass ownership to caller.
60  ErrorDeallocNotOwned, // -dealloc called on non-owned object.
61  ErrorUseAfterRelease, // Object used after released.
62  ErrorReleaseNotOwned, // Release of an object that was not owned.
64  ErrorLeak, // A memory leak due to excessive reference counts.
65  ErrorLeakReturned, // A memory leak due to the returning method not having
66  // the correct naming conventions.
69  };
70 
71  /// Tracks how an object referenced by an ivar has been used.
72  ///
73  /// This accounts for us not knowing if an arbitrary ivar is supposed to be
74  /// stored at +0 or +1.
75  enum class IvarAccessHistory {
76  None,
79  };
80 
81 private:
82  /// The number of outstanding retains.
83  unsigned Cnt;
84  /// The number of outstanding autoreleases.
85  unsigned ACnt;
86  /// The (static) type of the object at the time we started tracking it.
87  QualType T;
88 
89  /// The current state of the object.
90  ///
91  /// See the RefVal::Kind enum for possible values.
92  unsigned RawKind : 5;
93 
94  /// The kind of object being tracked (CF or ObjC or OSObject), if known.
95  ///
96  /// See the ObjKind enum for possible values.
97  unsigned RawObjectKind : 3;
98 
99  /// True if the current state and/or retain count may turn out to not be the
100  /// best possible approximation of the reference counting state.
101  ///
102  /// If true, the checker may decide to throw away ("override") this state
103  /// in favor of something else when it sees the object being used in new ways.
104  ///
105  /// This setting should not be propagated to state derived from this state.
106  /// Once we start deriving new states, it would be inconsistent to override
107  /// them.
108  unsigned RawIvarAccessHistory : 2;
109 
110  RefVal(Kind k, ObjKind o, unsigned cnt, unsigned acnt, QualType t,
111  IvarAccessHistory IvarAccess)
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");
117  assert(getIvarAccessHistory() == IvarAccess && "not enough bits");
118  }
119 
120 public:
121  Kind getKind() const { return static_cast<Kind>(RawKind); }
122 
123  ObjKind getObjKind() const {
124  return static_cast<ObjKind>(RawObjectKind);
125  }
126 
127  unsigned getCount() const { return Cnt; }
128  unsigned getAutoreleaseCount() const { return ACnt; }
129  unsigned getCombinedCounts() const { return Cnt + ACnt; }
130  void clearCounts() {
131  Cnt = 0;
132  ACnt = 0;
133  }
134  void setCount(unsigned i) {
135  Cnt = i;
136  }
137  void setAutoreleaseCount(unsigned i) {
138  ACnt = i;
139  }
140 
141  QualType getType() const { return T; }
142 
143  /// Returns what the analyzer knows about direct accesses to a particular
144  /// instance variable.
145  ///
146  /// If the object with this refcount wasn't originally from an Objective-C
147  /// ivar region, this should always return IvarAccessHistory::None.
149  return static_cast<IvarAccessHistory>(RawIvarAccessHistory);
150  }
151 
152  bool isOwned() const {
153  return getKind() == Owned;
154  }
155 
156  bool isNotOwned() const {
157  return getKind() == NotOwned;
158  }
159 
160  bool isReturnedOwned() const {
161  return getKind() == ReturnedOwned;
162  }
163 
164  bool isReturnedNotOwned() const {
165  return getKind() == ReturnedNotOwned;
166  }
167 
168  /// Create a state for an object whose lifetime is the responsibility of the
169  /// current function, at least partially.
170  ///
171  /// Most commonly, this is an owned object with a retain count of +1.
173  return RefVal(Owned, o, /*Count=*/1, 0, t, IvarAccessHistory::None);
174  }
175 
176  /// Create a state for an object whose lifetime is not the responsibility of
177  /// the current function.
178  ///
179  /// Most commonly, this is an unowned object with a retain count of +0.
181  return RefVal(NotOwned, o, /*Count=*/0, 0, t, IvarAccessHistory::None);
182  }
183 
184  RefVal operator-(size_t i) const {
185  return RefVal(getKind(), getObjKind(), getCount() - i,
187  }
188 
189  RefVal operator+(size_t i) const {
190  return RefVal(getKind(), getObjKind(), getCount() + i,
192  }
193 
194  RefVal operator^(Kind k) const {
195  return RefVal(k, getObjKind(), getCount(), getAutoreleaseCount(),
197  }
198 
199  RefVal autorelease() const {
202  }
203 
208  }
209 
214  }
215 
216  // Comparison, profiling, and pretty-printing.
217  bool hasSameState(const RefVal &X) const {
218  return getKind() == X.getKind() && Cnt == X.Cnt && ACnt == X.ACnt &&
219  getIvarAccessHistory() == X.getIvarAccessHistory();
220  }
221 
222  bool operator==(const RefVal& X) const {
223  return T == X.T && hasSameState(X) && getObjKind() == X.getObjKind();
224  }
225 
226  void Profile(llvm::FoldingSetNodeID& ID) const {
227  ID.Add(T);
228  ID.AddInteger(RawKind);
229  ID.AddInteger(Cnt);
230  ID.AddInteger(ACnt);
231  ID.AddInteger(RawObjectKind);
232  ID.AddInteger(RawIvarAccessHistory);
233  }
234 
235  void print(raw_ostream &Out) const;
236 };
237 
239  : public Checker< check::Bind,
240  check::DeadSymbols,
241  check::BeginFunction,
242  check::EndFunction,
243  check::PostStmt<BlockExpr>,
244  check::PostStmt<CastExpr>,
245  check::PostStmt<ObjCArrayLiteral>,
246  check::PostStmt<ObjCDictionaryLiteral>,
247  check::PostStmt<ObjCBoxedExpr>,
248  check::PostStmt<ObjCIvarRefExpr>,
249  check::PostCall,
250  check::RegionChanges,
251  eval::Assume,
252  eval::Call > {
253 
254 public:
255  std::unique_ptr<RefCountBug> UseAfterRelease;
256  std::unique_ptr<RefCountBug> ReleaseNotOwned;
257  std::unique_ptr<RefCountBug> DeallocNotOwned;
258  std::unique_ptr<RefCountBug> FreeNotOwned;
259  std::unique_ptr<RefCountBug> OverAutorelease;
260  std::unique_ptr<RefCountBug> ReturnNotOwnedForOwned;
261  std::unique_ptr<RefCountBug> LeakWithinFunction;
262  std::unique_ptr<RefCountBug> LeakAtReturn;
263 
264  mutable std::unique_ptr<RetainSummaryManager> Summaries;
265 
266  static std::unique_ptr<CheckerProgramPointTag> DeallocSentTag;
267  static std::unique_ptr<CheckerProgramPointTag> CastFailTag;
268 
269  /// Track Objective-C and CoreFoundation objects.
270  bool TrackObjCAndCFObjects = false;
271 
272  /// Track sublcasses of OSObject.
273  bool TrackOSObjects = false;
274 
275  /// Track initial parameters (for the entry point) for NS/CF objects.
276  bool TrackNSCFStartParam = false;
277 
279 
281  if (!Summaries)
282  Summaries.reset(
284  return *Summaries;
285  }
286 
288  return getSummaryManager(C.getASTContext());
289  }
290 
291  void printState(raw_ostream &Out, ProgramStateRef State,
292  const char *NL, const char *Sep) const override;
293 
294  void checkBind(SVal loc, SVal val, const Stmt *S, CheckerContext &C) const;
295  void checkPostStmt(const BlockExpr *BE, CheckerContext &C) const;
296  void checkPostStmt(const CastExpr *CE, CheckerContext &C) const;
297 
298  void checkPostStmt(const ObjCArrayLiteral *AL, CheckerContext &C) const;
299  void checkPostStmt(const ObjCDictionaryLiteral *DL, CheckerContext &C) const;
300  void checkPostStmt(const ObjCBoxedExpr *BE, CheckerContext &C) const;
301 
302  void checkPostStmt(const ObjCIvarRefExpr *IRE, CheckerContext &C) const;
303 
304  void checkPostCall(const CallEvent &Call, CheckerContext &C) const;
305 
306  void checkSummary(const RetainSummary &Summ, const CallEvent &Call,
307  CheckerContext &C) const;
308 
309  void processSummaryOfInlined(const RetainSummary &Summ,
310  const CallEvent &Call,
311  CheckerContext &C) const;
312 
313  bool evalCall(const CallEvent &Call, CheckerContext &C) const;
314 
316  bool Assumption) const;
317 
320  const InvalidatedSymbols *invalidated,
321  ArrayRef<const MemRegion *> ExplicitRegions,
323  const LocationContext* LCtx,
324  const CallEvent *Call) const;
325 
327  ExplodedNode *Pred, RetEffect RE, RefVal X,
328  SymbolRef Sym, ProgramStateRef state) const;
329 
330  void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const;
331  void checkBeginFunction(CheckerContext &C) const;
332  void checkEndFunction(const ReturnStmt *RS, CheckerContext &C) const;
333 
335  RefVal V, ArgEffect E, RefVal::Kind &hasErr,
336  CheckerContext &C) const;
337 
339  SymbolRef Sym) const;
340 
341  void processNonLeakError(ProgramStateRef St, SourceRange ErrorRange,
342  RefVal::Kind ErrorKind, SymbolRef Sym,
343  CheckerContext &C) const;
344 
345  void processObjCLiterals(CheckerContext &C, const Expr *Ex) const;
346 
348  SymbolRef sid, RefVal V,
349  SmallVectorImpl<SymbolRef> &Leaked) const;
350 
353  const ProgramPointTag *Tag, CheckerContext &Ctx,
354  SymbolRef Sym,
355  RefVal V,
356  const ReturnStmt *S=nullptr) const;
357 
360  CheckerContext &Ctx,
361  ExplodedNode *Pred = nullptr) const;
362 
364  return *DeallocSentTag;
365  }
366 
367  static const CheckerProgramPointTag &getCastFailTag() { return *CastFailTag; }
368 
369 private:
370  /// Perform the necessary checks and state adjustments at the end of the
371  /// function.
372  /// \p S Return statement, may be null.
373  ExplodedNode * processReturn(const ReturnStmt *S, CheckerContext &C) const;
374 };
375 
376 //===----------------------------------------------------------------------===//
377 // RefBindings - State used to track object reference counts.
378 //===----------------------------------------------------------------------===//
379 
380 const RefVal *getRefBinding(ProgramStateRef State, SymbolRef Sym);
381 
382 /// Returns true if this stack frame is for an Objective-C method that is a
383 /// property getter or setter whose body has been synthesized by the analyzer.
384 inline bool isSynthesizedAccessor(const StackFrameContext *SFC) {
385  auto Method = dyn_cast_or_null<ObjCMethodDecl>(SFC->getDecl());
386  if (!Method || !Method->isPropertyAccessor())
387  return false;
388 
390 }
391 
392 } // end namespace retaincountchecker
393 } // end namespace ento
394 } // end namespace clang
395 
396 #endif
clang::ento::retaincountchecker::RetainCountChecker::processNonLeakError
void processNonLeakError(ProgramStateRef St, SourceRange ErrorRange, RefVal::Kind ErrorKind, SymbolRef Sym, CheckerContext &C) const
Definition: RetainCountChecker.cpp:859
clang::ento::retaincountchecker::RefVal::operator-
RefVal operator-(size_t i) const
Definition: RetainCountChecker.h:184
clang::ObjCBoxedExpr
ObjCBoxedExpr - used for generalized expression boxing.
Definition: ExprObjC.h:128
clang::ento::retaincountchecker::RetainCountChecker::DeallocSentTag
static std::unique_ptr< CheckerProgramPointTag > DeallocSentTag
Definition: RetainCountChecker.h:266
clang::LocationContext
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
Definition: AnalysisDeclContext.h:215
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:212
clang::AnalysisDeclContext::isBodyAutosynthesized
bool isBodyAutosynthesized() const
Definition: AnalysisDeclContext.cpp:131
clang::ento::retaincountchecker::RefVal::getCombinedCounts
unsigned getCombinedCounts() const
Definition: RetainCountChecker.h:129
clang::ento::retaincountchecker::RetainCountChecker::getDeallocSentTag
static const CheckerProgramPointTag & getDeallocSentTag()
Definition: RetainCountChecker.h:363
clang::ento::ObjKind
ObjKind
Determines the object kind of a tracked object.
Definition: RetainSummaryManager.h:35
clang::ento::retaincountchecker::RefVal::getAutoreleaseCount
unsigned getAutoreleaseCount() const
Definition: RetainCountChecker.h:128
clang::ProgramPointTag
ProgramPoints can be "tagged" as representing points specific to a given analysis entity.
Definition: ProgramPoint.h:39
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:673
Attr.h
clang::ento::retaincountchecker::RetainCountChecker::checkSummary
void checkSummary(const RetainSummary &Summ, const CallEvent &Call, CheckerContext &C) const
Definition: RetainCountChecker.cpp:605
clang::ento::ExplodedNode
Definition: ExplodedGraph.h:65
DeclCXX.h
clang::ento::retaincountchecker::RefVal::IvarAccessHistory
IvarAccessHistory
Tracks how an object referenced by an ivar has been used.
Definition: RetainCountChecker.h:75
clang::ento::retaincountchecker::RefVal::operator^
RefVal operator^(Kind k) const
Definition: RetainCountChecker.h:194
SymbolManager.h
clang::ento::retaincountchecker::RefVal::makeNotOwned
static RefVal makeNotOwned(ObjKind o, QualType t)
Create a state for an object whose lifetime is not the responsibility of the current function.
Definition: RetainCountChecker.h:180
clang::StackFrameContext
It represents a stack frame of the call stack (based on CallEvent).
Definition: AnalysisDeclContext.h:295
SourceManager.h
clang::ento::retaincountchecker::RefVal::isOwned
bool isOwned() const
Definition: RetainCountChecker.h:152
clang::ento::retaincountchecker::RetainCountChecker::OverAutorelease
std::unique_ptr< RefCountBug > OverAutorelease
Definition: RetainCountChecker.h:259
clang::ento::retaincountchecker::RefVal::ErrorLeakReturned
@ ErrorLeakReturned
Definition: RetainCountChecker.h:65
clang::tooling::X
static ToolExecutorPluginRegistry::Add< AllTUsToolExecutorPlugin > X("all-TUs", "Runs FrontendActions on all TUs in the compilation database. " "Tool results are stored in memory.")
RetainCountDiagnostics.h
clang::ento::retaincountchecker::RetainCountChecker::checkPostStmt
void checkPostStmt(const BlockExpr *BE, CheckerContext &C) const
Definition: RetainCountChecker.cpp:146
clang::ento::retaincountchecker::RetainCountChecker::printState
void printState(raw_ostream &Out, ProgramStateRef State, const char *NL, const char *Sep) const override
See CheckerManager::runCheckersForPrintState.
Definition: RetainCountChecker.cpp:1455
clang::ento::retaincountchecker::RefVal::ErrorUseAfterRelease
@ ErrorUseAfterRelease
Definition: RetainCountChecker.h:61
clang::ento::retaincountchecker::getRefBinding
const RefVal * getRefBinding(ProgramStateRef State, SymbolRef Sym)
Definition: RetainCountChecker.cpp:28
clang::ento::retaincountchecker::RefVal::ErrorLeak
@ ErrorLeak
Definition: RetainCountChecker.h:64
CallEvent.h
clang::ObjCArrayLiteral
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp,...
Definition: ExprObjC.h:190
DeclObjC.h
clang::ento::retaincountchecker::RetainCountChecker::checkEndFunction
void checkEndFunction(const ReturnStmt *RS, CheckerContext &C) const
Definition: RetainCountChecker.cpp:1367
clang::ento::retaincountchecker::RetainCountChecker::processObjCLiterals
void processObjCLiterals(CheckerContext &C, const Expr *Ex) const
Definition: RetainCountChecker.cpp:229
V
#define V(N, I)
Definition: ASTContext.h:3121
BuiltinCheckerRegistration.h
clang::ento::retaincountchecker::RetainCountChecker::processSummaryOfInlined
void processSummaryOfInlined(const RetainSummary &Summ, const CallEvent &Call, CheckerContext &C) const
Definition: RetainCountChecker.cpp:448
clang::ento::retaincountchecker::RefVal::operator+
RefVal operator+(size_t i) const
Definition: RetainCountChecker.h:189
clang::ento::retaincountchecker::RetainCountChecker::checkBind
void checkBind(SVal loc, SVal val, const Stmt *S, CheckerContext &C) const
Definition: RetainCountChecker.cpp:1137
clang::LocationContext::getAnalysisDeclContext
AnalysisDeclContext * getAnalysisDeclContext() const
Definition: AnalysisDeclContext.h:241
clang::ento::retaincountchecker::RefVal::hasSameState
bool hasSameState(const RefVal &X) const
Definition: RetainCountChecker.h:217
clang::ento::retaincountchecker::RefVal::clearCounts
void clearCounts()
Definition: RetainCountChecker.h:130
clang::ento::retaincountchecker::RefVal::getCount
unsigned getCount() const
Definition: RetainCountChecker.h:127
CheckerManager.h
clang::ento::retaincountchecker::RetainCountChecker::errorKindToBugKind
const RefCountBug & errorKindToBugKind(RefVal::Kind ErrorKind, SymbolRef Sym) const
Definition: RetainCountChecker.cpp:843
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:212
clang::ObjCDictionaryLiteral
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition: ExprObjC.h:306
clang::ento::SymExpr
Symbolic value.
Definition: SymExpr.h:29
LangOptions.h
clang::ento::retaincountchecker::RefVal::getIvarAccessHistory
IvarAccessHistory getIvarAccessHistory() const
Returns what the analyzer knows about direct accesses to a particular instance variable.
Definition: RetainCountChecker.h:148
clang::ento::retaincountchecker::RefVal::ERROR_LEAK_START
@ ERROR_LEAK_START
Definition: RetainCountChecker.h:63
clang::ento::retaincountchecker::RefVal::Owned
@ Owned
Definition: RetainCountChecker.h:54
clang::ento::retaincountchecker::RetainCountChecker::getSummaryManager
RetainSummaryManager & getSummaryManager(ASTContext &Ctx) const
Definition: RetainCountChecker.h:280
clang::ento::retaincountchecker::RefVal::IvarAccessHistory::AccessedDirectly
@ AccessedDirectly
clang::ento::retaincountchecker::RetainCountChecker::evalAssume
ProgramStateRef evalAssume(ProgramStateRef state, SVal Cond, bool Assumption) const
Definition: RetainCountChecker.cpp:1150
clang::ento::retaincountchecker::RefVal::getKind
Kind getKind() const
Definition: RetainCountChecker.h:121
clang::ento::retaincountchecker::RefVal::ERROR_START
@ ERROR_START
Definition: RetainCountChecker.h:59
clang::ento::retaincountchecker::RefVal::ErrorOverAutorelease
@ ErrorOverAutorelease
Definition: RetainCountChecker.h:67
clang::ento::retaincountchecker::RetainCountChecker::evalCall
bool evalCall(const CallEvent &Call, CheckerContext &C) const
Definition: RetainCountChecker.cpp:889
clang::ento::retaincountchecker::RetainCountChecker::DeallocNotOwned
std::unique_ptr< RefCountBug > DeallocNotOwned
Definition: RetainCountChecker.h:257
clang::ento::retaincountchecker::RefVal::setAutoreleaseCount
void setAutoreleaseCount(unsigned i)
Definition: RetainCountChecker.h:137
clang::ento::SymbolReaper
A class responsible for cleaning up unused symbols.
Definition: SymbolManager.h:505
llvm::DenseSet< SymbolRef >
PathDiagnostic.h
clang::ento::retaincountchecker::RefVal::IvarAccessHistory::None
@ None
clang::ento::retaincountchecker::RefVal::autorelease
RefVal autorelease() const
Definition: RetainCountChecker.h:199
state
and static some checkers Checker The latter are built on top of the former via the Checker and CheckerVisitor and attempts to isolate them from much of the gore of the internal analysis the analyzer is basically a source code simulator that traces out possible paths of execution The state of the and the combination of state and program point is a node in an exploded which has the entry program point and initial state
Definition: README.txt:30
clang::ento::retaincountchecker::RefVal::makeOwned
static RefVal makeOwned(ObjKind o, QualType t)
Create a state for an object whose lifetime is the responsibility of the current function,...
Definition: RetainCountChecker.h:172
clang::ento::retaincountchecker::RefVal::Kind
Kind
Definition: RetainCountChecker.h:53
clang::ento::retaincountchecker::RetainCountChecker
Definition: RetainCountChecker.h:238
clang::ento::retaincountchecker::RetainCountChecker::UseAfterRelease
std::unique_ptr< RefCountBug > UseAfterRelease
Definition: RetainCountChecker.h:255
clang::ento::retaincountchecker::isSynthesizedAccessor
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...
Definition: RetainCountChecker.h:384
clang::ento::retaincountchecker::RefVal::IvarAccessHistory::ReleasedAfterDirectAccess
@ ReleasedAfterDirectAccess
clang::ento::retaincountchecker::RetainCountChecker::LeakWithinFunction
std::unique_ptr< RefCountBug > LeakWithinFunction
Definition: RetainCountChecker.h:261
clang::ento::retaincountchecker::RetainCountChecker::CastFailTag
static std::unique_ptr< CheckerProgramPointTag > CastFailTag
Definition: RetainCountChecker.h:267
clang::ento::retaincountchecker::RefVal::Profile
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: RetainCountChecker.h:226
BugType.h
clang::ento::retaincountchecker::RefVal::setCount
void setCount(unsigned i)
Definition: RetainCountChecker.h:134
clang::BlockExpr
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:5965
llvm::ArrayRef
Definition: LLVM.h:34
CocoaConventions.h
SelectorExtras.h
clang::ento::retaincountchecker::RefVal::releaseViaIvar
RefVal releaseViaIvar() const
Definition: RetainCountChecker.h:210
State
LineState State
Definition: UnwrappedLineFormatter.cpp:986
clang::ento::retaincountchecker::RefVal
Metadata on reference.
Definition: RetainCountChecker.h:51
clang::ento::retaincountchecker::RefVal::ReturnedNotOwned
@ ReturnedNotOwned
Definition: RetainCountChecker.h:58
clang::ento::RetainSummary
Summary for a function with respect to ownership changes.
Definition: RetainSummaryManager.h:282
clang::ento::retaincountchecker::RefVal::NotOwned
@ NotOwned
Definition: RetainCountChecker.h:55
clang::ento::retaincountchecker::RetainCountChecker::checkReturnWithRetEffect
ExplodedNode * checkReturnWithRetEffect(const ReturnStmt *S, CheckerContext &C, ExplodedNode *Pred, RetEffect RE, RefVal X, SymbolRef Sym, ProgramStateRef state) const
Definition: RetainCountChecker.cpp:1066
CheckerContext.h
Checker.h
clang::ento::retaincountchecker::RetainCountChecker::ReturnNotOwnedForOwned
std::unique_ptr< RefCountBug > ReturnNotOwnedForOwned
Definition: RetainCountChecker.h:260
clang::ento::retaincountchecker::RetainCountChecker::Summaries
std::unique_ptr< RetainSummaryManager > Summaries
Definition: RetainCountChecker.h:264
ParentMap.h
clang::ento::retaincountchecker::RetainCountChecker::LeakAtReturn
std::unique_ptr< RefCountBug > LeakAtReturn
Definition: RetainCountChecker.h:262
clang::Builtin::ID
ID
Definition: Builtins.h:48
clang
Definition: CalledOnceCheck.h:17
clang::ento::CheckerProgramPointTag
Tag that can use a checker name as a message provider (see SimpleProgramPointTag).
Definition: Checker.h:510
clang::ento::retaincountchecker::RetainCountChecker::getSummaryManager
RetainSummaryManager & getSummaryManager(CheckerContext &C) const
Definition: RetainCountChecker.h:287
clang::ento::RetainSummaryManager
Definition: RetainSummaryManager.h:449
clang::ento::retaincountchecker::RefVal::ErrorDeallocNotOwned
@ ErrorDeallocNotOwned
Definition: RetainCountChecker.h:60
clang::ento::retaincountchecker::RetainCountChecker::checkBeginFunction
void checkBeginFunction(CheckerContext &C) const
Definition: RetainCountChecker.cpp:1331
clang::ento::ArgEffect
An ArgEffect summarizes the retain count behavior on an argument or receiver to a function or method.
Definition: RetainSummaryManager.h:118
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:69
clang::ento::retaincountchecker::RefVal::ErrorReleaseNotOwned
@ ErrorReleaseNotOwned
Definition: RetainCountChecker.h:62
clang::ento::CallEvent
Represents an abstract call to a function or method along a particular path.
Definition: CallEvent.h:143
clang::ento::retaincountchecker::RetainCountChecker::TrackOSObjects
bool TrackOSObjects
Track sublcasses of OSObject.
Definition: RetainCountChecker.h:273
clang::ento::retaincountchecker::RefVal::getObjKind
ObjKind getObjKind() const
Definition: RetainCountChecker.h:123
clang::ento::retaincountchecker::RefCountBug
Definition: RetainCountDiagnostics.h:27
unsigned
clang::ento::retaincountchecker::RefVal::print
void print(raw_ostream &Out) const
Definition: RetainCountChecker.cpp:46
clang::ento::retaincountchecker::RefVal::isReturnedOwned
bool isReturnedOwned() const
Definition: RetainCountChecker.h:160
clang::ento::retaincountchecker::RetainCountChecker::RetainCountChecker
RetainCountChecker()
Definition: RetainCountChecker.h:278
clang::ento::RetEffect
RetEffect summarizes a call's retain/release behavior with respect to its return value.
Definition: RetainSummaryManager.h:139
clang::ento::retaincountchecker::RefVal::isNotOwned
bool isNotOwned() const
Definition: RetainCountChecker.h:156
clang::ento::retaincountchecker::RetainCountChecker::checkDeadSymbols
void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const
Definition: RetainCountChecker.cpp:1409
clang::ento::CheckerContext
Definition: CheckerContext.h:23
clang::ento::Checker
Definition: Checker.h:517
clang::ento::SVal
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
Definition: SVals.h:75
clang::ento::retaincountchecker::RefVal::ErrorReturnedNotOwned
@ ErrorReturnedNotOwned
Definition: RetainCountChecker.h:68
clang::ento::retaincountchecker::RefVal::ReturnedOwned
@ ReturnedOwned
Definition: RetainCountChecker.h:57
clang::ento::retaincountchecker::RefVal::withIvarAccess
RefVal withIvarAccess() const
Definition: RetainCountChecker.h:204
clang::ento::retaincountchecker::RetainCountChecker::handleSymbolDeath
ProgramStateRef handleSymbolDeath(ProgramStateRef state, SymbolRef sid, RefVal V, SmallVectorImpl< SymbolRef > &Leaked) const
Definition: RetainCountChecker.cpp:1285
llvm::SmallVectorImpl
Definition: LLVM.h:39
clang::ento::retaincountchecker::RetainCountChecker::updateSymbol
ProgramStateRef updateSymbol(ProgramStateRef state, SymbolRef sym, RefVal V, ArgEffect E, RefVal::Kind &hasErr, CheckerContext &C) const
Definition: RetainCountChecker.cpp:711
ProgramStateTrait.h
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::ento::retaincountchecker::RetainCountChecker::checkRegionChanges
ProgramStateRef checkRegionChanges(ProgramStateRef state, const InvalidatedSymbols *invalidated, ArrayRef< const MemRegion * > ExplicitRegions, ArrayRef< const MemRegion * > Regions, const LocationContext *LCtx, const CallEvent *Call) const
Definition: RetainCountChecker.cpp:1183
clang::ento::retaincountchecker::RetainCountChecker::processLeaks
ExplodedNode * processLeaks(ProgramStateRef state, SmallVectorImpl< SymbolRef > &Leaked, CheckerContext &Ctx, ExplodedNode *Pred=nullptr) const
Definition: RetainCountChecker.cpp:1313
clang::ento::retaincountchecker::RetainCountChecker::TrackNSCFStartParam
bool TrackNSCFStartParam
Track initial parameters (for the entry point) for NS/CF objects.
Definition: RetainCountChecker.h:276
clang::CastExpr
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:3473
RetainSummaryManager.h
clang::ento::retaincountchecker::RetainCountChecker::handleAutoreleaseCounts
ProgramStateRef handleAutoreleaseCounts(ProgramStateRef state, ExplodedNode *Pred, const ProgramPointTag *Tag, CheckerContext &Ctx, SymbolRef Sym, RefVal V, const ReturnStmt *S=nullptr) const
Definition: RetainCountChecker.cpp:1207
clang::ento::retaincountchecker::RetainCountChecker::checkPostCall
void checkPostCall(const CallEvent &Call, CheckerContext &C) const
Definition: RetainCountChecker.cpp:363
clang::LocationContext::getDecl
const Decl * getDecl() const
Definition: AnalysisDeclContext.h:247
clang::ento::retaincountchecker::RefVal::operator==
bool operator==(const RefVal &X) const
Definition: RetainCountChecker.h:222
clang::ento::retaincountchecker::RetainCountChecker::ReleaseNotOwned
std::unique_ptr< RefCountBug > ReleaseNotOwned
Definition: RetainCountChecker.h:256
clang::ento::retaincountchecker::RetainCountChecker::getCastFailTag
static const CheckerProgramPointTag & getCastFailTag()
Definition: RetainCountChecker.h:367
clang::ObjCIvarRefExpr
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition: ExprObjC.h:548
llvm::IntrusiveRefCntPtr< const ProgramState >
clang::ento::retaincountchecker::RetainCountChecker::FreeNotOwned
std::unique_ptr< RefCountBug > FreeNotOwned
Definition: RetainCountChecker.h:258
clang::ReturnStmt
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Definition: Stmt.h:2760
clang::ento::retaincountchecker::RetainCountChecker::TrackObjCAndCFObjects
bool TrackObjCAndCFObjects
Track Objective-C and CoreFoundation objects.
Definition: RetainCountChecker.h:270
clang::ento::retaincountchecker::RefVal::getType
QualType getType() const
Definition: RetainCountChecker.h:141
clang::ento::retaincountchecker::RefVal::Released
@ Released
Definition: RetainCountChecker.h:56
clang::ento::retaincountchecker::RefVal::isReturnedNotOwned
bool isReturnedNotOwned() const
Definition: RetainCountChecker.h:164