43const char * RunLoopBind = 
"NSRunLoopM";
 
   44const char * RunLoopRunBind = 
"RunLoopRunM";
 
   45const char * OtherMsgBind = 
"OtherMessageSentM";
 
   46const char * AutoreleasePoolBind = 
"AutoreleasePoolM";
 
   47const char * OtherStmtAutoreleasePoolBind = 
"OtherAutoreleasePoolM";
 
   49class RunLoopAutoreleaseLeakChecker : 
public Checker<check::ASTCodeBody> {
 
   52  void checkASTCodeBody(
const Decl *D,
 
   54                        BugReporter &BR) 
const;
 
   84                            const RunLoopAutoreleaseLeakChecker *
Checker) {
 
   98  bool HasAutoreleasePool = (AP != 
nullptr);
 
  101  const auto *RLR = 
Match.getNodeAs<
Stmt>(RunLoopRunBind);
 
  102  assert(RLR && 
"Run loop launch not found");
 
  109  if (HasAutoreleasePool && (OAP != AP))
 
  117                     "Memory leak inside autorelease pool",
 
  120                     (Twine(
"Temporary objects allocated in the") +
 
  121                      " autorelease pool " +
 
  122                      (HasAutoreleasePool ? 
"" : 
"of last resort ") +
 
  123                      "followed by the launch of " +
 
  124                      (RL ? 
"main run loop " : 
"xpc_main ") +
 
  125                      "may never get released; consider moving them to a " 
  126                      "separate autorelease pool")
 
 
  134                      hasReceiverType(asString(
"NSRunLoop")),
 
  139                         hasReceiver(MainRunLoopM),
 
  140                         Extra).bind(RunLoopRunBind);
 
  144  return anyOf(MainRunLoopRunM, XPCRunM);
 
 
  149                                      equalsBoundNode(RunLoopRunBind))),
 
 
  156                           const RunLoopAutoreleaseLeakChecker *Chkr) {
 
 
  175                         const RunLoopAutoreleaseLeakChecker *Chkr) {
 
 
  195void RunLoopAutoreleaseLeakChecker::checkASTCodeBody(
const Decl *D,
 
  202void ento::registerRunLoopAutoreleaseLeakChecker(CheckerManager &mgr) {
 
  206bool ento::shouldRegisterRunLoopAutoreleaseLeakChecker(
const CheckerManager &mgr) {
 
static void emitDiagnostics(BoundNodes &Match, const Decl *D, BugReporter &BR, AnalysisManager &AM, const RunLoopAutoreleaseLeakChecker *Checker)
static bool seenBefore(const Stmt *Parent, const Stmt *A, const Stmt *B)
static void checkTempObjectsInSamePool(const Decl *D, AnalysisManager &AM, BugReporter &BR, const RunLoopAutoreleaseLeakChecker *Chkr)
static StatementMatcher getRunLoopRunM(StatementMatcher Extra=anything())
static StatementMatcher getOtherMessageSentM(StatementMatcher Extra=anything())
static void checkTempObjectsInNoPool(const Decl *D, AnalysisManager &AM, BugReporter &BR, const RunLoopAutoreleaseLeakChecker *Chkr)
AnalysisDeclContext contains the context data for the function, method or block under analysis.
const Decl * getDecl() const
Decl - This represents one declaration (or definition), e.g.
virtual Stmt * getBody() const
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
virtual bool hasBody() const
Returns true if this Decl represents a declaration for a body of code, such as a function or method d...
Represents Objective-C's @autoreleasepool Statement.
An expression that sends a message to the given Objective-C object or class.
A trivial tuple used to represent a source range.
Stmt - This represents one statement.
Maps string IDs to AST nodes matched by parts of a matcher.
ASTContext & getASTContext() override
AnalysisDeclContext * getAnalysisDeclContext(const Decl *D)
BugReporter is a utility class for generating PathDiagnostics for analysis.
const SourceManager & getSourceManager()
void EmitBasicReport(const Decl *DeclWithIssue, const CheckerFrontend *Checker, StringRef BugName, StringRef BugCategory, StringRef BugStr, PathDiagnosticLocation Loc, ArrayRef< SourceRange > Ranges={}, ArrayRef< FixItHint > Fixits={})
CHECKER * registerChecker(AT &&...Args)
Register a single-part checker (derived from Checker): construct its singleton instance,...
Simple checker classes that implement one frontend (i.e.
static PathDiagnosticLocation createBegin(const Decl *D, const SourceManager &SM)
Create a location for the beginning of the declaration.
A Range represents the closed range [from, to].
const internal::VariadicOperatorMatcherFunc< 1, 1 > unless
Matches if the provided matcher does not match.
internal::Matcher< Decl > DeclarationMatcher
Types of matchers for the top-level classes in the AST class hierarchy.
const internal::ArgumentAdaptingMatcherFunc< internal::HasDescendantMatcher > hasDescendant
Matches AST nodes that have descendant AST nodes that match the provided matcher.
internal::Matcher< NamedDecl > hasName(StringRef Name)
Matches NamedDecl nodes that have the specified name.
const internal::VariadicDynCastAllOfMatcher< Stmt, CallExpr > callExpr
Matches call expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAutoreleasePoolStmt > autoreleasePoolStmt
Matches an Objective-C autorelease pool statement.
SmallVector< BoundNodes, 1 > match(MatcherT Matcher, const NodeT &Node, ASTContext &Context)
Returns the results of matching Matcher on Node.
internal::TrueMatcher anything()
Matches any node.
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCMessageExpr > objcMessageExpr
Matches ObjectiveC Message invocation expressions.
internal::Matcher< Stmt > StatementMatcher
const internal::VariadicDynCastAllOfMatcher< Decl, FunctionDecl > functionDecl
Matches function declarations.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
const internal::VariadicOperatorMatcherFunc< 2, std::numeric_limits< unsigned >::max()> anyOf
Matches if any of the given matchers matches.
const internal::ArgumentAdaptingMatcherFunc< internal::HasAncestorMatcher, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr >, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr > > hasAncestor
Matches AST nodes that have an ancestor that matches the provided matcher.
The JSON file list parser is used to communicate input to InstallAPI.
@ Match
This is not an overload because the signature exactly matches an existing declaration.