ObjCAutoreleaseWriteChecker.cpp (344779) | ObjCAutoreleaseWriteChecker.cpp (353358) |
---|---|
1//===- ObjCAutoreleaseWriteChecker.cpp ----------------------------*- C++ -*-==// 2// | 1//===- ObjCAutoreleaseWriteChecker.cpp ----------------------------*- C++ -*-==// 2// |
3// The LLVM Compiler Infrastructure | 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 |
4// | 6// |
5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// | |
8//===----------------------------------------------------------------------===// 9// 10// This file defines ObjCAutoreleaseWriteChecker which warns against writes 11// into autoreleased out parameters which cause crashes. 12// An example of a problematic write is a write to {@code error} in the example 13// below: 14// 15// - (BOOL) mymethod:(NSError *__autoreleasing *)error list:(NSArray*) list { --- 116 unchanged lines hidden (view full) --- 132 MarkedStmt, BR.getSourceManager(), ADC); 133 bool IsMethod = Match.getNodeAs<ObjCMethodDecl>(IsMethodBind) != nullptr; 134 const char *Name = IsMethod ? "method" : "function"; 135 136 BR.EmitBasicReport( 137 ADC->getDecl(), Checker, 138 /*Name=*/(llvm::Twine(ActionMsg) 139 + " autoreleasing out parameter inside autorelease pool").str(), | 7//===----------------------------------------------------------------------===// 8// 9// This file defines ObjCAutoreleaseWriteChecker which warns against writes 10// into autoreleased out parameters which cause crashes. 11// An example of a problematic write is a write to {@code error} in the example 12// below: 13// 14// - (BOOL) mymethod:(NSError *__autoreleasing *)error list:(NSArray*) list { --- 116 unchanged lines hidden (view full) --- 131 MarkedStmt, BR.getSourceManager(), ADC); 132 bool IsMethod = Match.getNodeAs<ObjCMethodDecl>(IsMethodBind) != nullptr; 133 const char *Name = IsMethod ? "method" : "function"; 134 135 BR.EmitBasicReport( 136 ADC->getDecl(), Checker, 137 /*Name=*/(llvm::Twine(ActionMsg) 138 + " autoreleasing out parameter inside autorelease pool").str(), |
140 /*Category=*/"Memory", | 139 /*BugCategory=*/"Memory", |
141 (llvm::Twine(ActionMsg) + " autoreleasing out parameter " + 142 (IsCapture ? "'" + PVD->getName() + "'" + " " : "") + "inside " + 143 "autorelease pool that may exit before " + Name + " returns; consider " 144 "writing first to a strong local variable declared outside of the block") 145 .str(), 146 Location, 147 Range); 148} --- 53 unchanged lines hidden (view full) --- 202 auto Matches = match(MatcherM, *D, AM.getASTContext()); 203 for (BoundNodes Match : Matches) 204 emitDiagnostics(Match, D, BR, AM, this); 205} 206 207void ento::registerAutoreleaseWriteChecker(CheckerManager &Mgr) { 208 Mgr.registerChecker<ObjCAutoreleaseWriteChecker>(); 209} | 140 (llvm::Twine(ActionMsg) + " autoreleasing out parameter " + 141 (IsCapture ? "'" + PVD->getName() + "'" + " " : "") + "inside " + 142 "autorelease pool that may exit before " + Name + " returns; consider " 143 "writing first to a strong local variable declared outside of the block") 144 .str(), 145 Location, 146 Range); 147} --- 53 unchanged lines hidden (view full) --- 201 auto Matches = match(MatcherM, *D, AM.getASTContext()); 202 for (BoundNodes Match : Matches) 203 emitDiagnostics(Match, D, BR, AM, this); 204} 205 206void ento::registerAutoreleaseWriteChecker(CheckerManager &Mgr) { 207 Mgr.registerChecker<ObjCAutoreleaseWriteChecker>(); 208} |
209 210bool ento::shouldRegisterAutoreleaseWriteChecker(const LangOptions &LO) { 211 return true; 212} |
|