Deleted Added
full compact
GCDAntipatternChecker.cpp (344779) GCDAntipatternChecker.cpp (353358)
1//===- GCDAntipatternChecker.cpp ---------------------------------*- C++ -*-==//
2//
1//===- GCDAntipatternChecker.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 GCDAntipatternChecker which checks against a common
11// antipattern when synchronous API is emulated from asynchronous callbacks
12// using a semaphore:
13//
14// dispatch_semaphore_t sema = dispatch_semaphore_create(0);
15//

--- 176 unchanged lines hidden (view full) ---

192 OS << "Waiting on a callback using a " << Type << " creates useless threads "
193 << "and is subject to priority inversion; consider "
194 << "using a synchronous API or changing the caller to be asynchronous";
195
196 BR.EmitBasicReport(
197 ADC->getDecl(),
198 Checker,
199 /*Name=*/"GCD performance anti-pattern",
7//===----------------------------------------------------------------------===//
8//
9// This file defines GCDAntipatternChecker which checks against a common
10// antipattern when synchronous API is emulated from asynchronous callbacks
11// using a semaphore:
12//
13// dispatch_semaphore_t sema = dispatch_semaphore_create(0);
14//

--- 176 unchanged lines hidden (view full) ---

191 OS << "Waiting on a callback using a " << Type << " creates useless threads "
192 << "and is subject to priority inversion; consider "
193 << "using a synchronous API or changing the caller to be asynchronous";
194
195 BR.EmitBasicReport(
196 ADC->getDecl(),
197 Checker,
198 /*Name=*/"GCD performance anti-pattern",
200 /*Category=*/"Performance",
199 /*BugCategory=*/"Performance",
201 OS.str(),
202 PathDiagnosticLocation::createBegin(SW, BR.getSourceManager(), ADC),
203 SW->getSourceRange());
204}
205
206void GCDAntipatternChecker::checkASTCodeBody(const Decl *D,
207 AnalysisManager &AM,
208 BugReporter &BR) const {

--- 8 unchanged lines hidden (view full) ---

217 emitDiagnostics(Match, "semaphore", BR, ADC, this);
218
219 auto GroupMatcherM = findGCDAntiPatternWithGroup();
220 Matches = match(GroupMatcherM, *D->getBody(), AM.getASTContext());
221 for (BoundNodes Match : Matches)
222 emitDiagnostics(Match, "group", BR, ADC, this);
223}
224
200 OS.str(),
201 PathDiagnosticLocation::createBegin(SW, BR.getSourceManager(), ADC),
202 SW->getSourceRange());
203}
204
205void GCDAntipatternChecker::checkASTCodeBody(const Decl *D,
206 AnalysisManager &AM,
207 BugReporter &BR) const {

--- 8 unchanged lines hidden (view full) ---

216 emitDiagnostics(Match, "semaphore", BR, ADC, this);
217
218 auto GroupMatcherM = findGCDAntiPatternWithGroup();
219 Matches = match(GroupMatcherM, *D->getBody(), AM.getASTContext());
220 for (BoundNodes Match : Matches)
221 emitDiagnostics(Match, "group", BR, ADC, this);
222}
223
225}
224} // end of anonymous namespace
226
227void ento::registerGCDAntipattern(CheckerManager &Mgr) {
228 Mgr.registerChecker<GCDAntipatternChecker>();
229}
225
226void ento::registerGCDAntipattern(CheckerManager &Mgr) {
227 Mgr.registerChecker<GCDAntipatternChecker>();
228}
229
230bool ento::shouldRegisterGCDAntipattern(const LangOptions &LO) {
231 return true;
232}