Skip to content

Commit 1d24671

Browse files
committed
Fix formatting.
1 parent b4001f9 commit 1d24671

File tree

1 file changed

+44
-45
lines changed

1 file changed

+44
-45
lines changed

clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//=======- RefCntblBaseVirtualDtor.cpp ---------------------------*- C++ -*-==//
1+
//=======- RetainPtrCtorAdoptChecker.cpp -------------------------*- C++ -*-==//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -12,12 +12,12 @@
1212
#include "clang/AST/CXXInheritance.h"
1313
#include "clang/AST/RecursiveASTVisitor.h"
1414
#include "clang/AST/StmtVisitor.h"
15+
#include "clang/Analysis/RetainSummaryManager.h"
1516
#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
1617
#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
1718
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
1819
#include "clang/StaticAnalyzer/Core/Checker.h"
1920
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
20-
#include "clang/Analysis/RetainSummaryManager.h"
2121
#include "llvm/ADT/DenseSet.h"
2222
#include "llvm/ADT/SetVector.h"
2323
#include <optional>
@@ -37,8 +37,7 @@ class RetainPtrCtorAdoptChecker
3737

3838
public:
3939
RetainPtrCtorAdoptChecker()
40-
: Bug(this,
41-
"Correct use of RetainPtr, adoptNS, and adoptCF",
40+
: Bug(this, "Correct use of RetainPtr, adoptNS, and adoptCF",
4241
"WebKit coding guidelines") {}
4342

4443
void checkASTDecl(const TranslationUnitDecl *TUD, AnalysisManager &MGR,
@@ -68,7 +67,7 @@ class RetainPtrCtorAdoptChecker
6867
DeclWithIssue = D;
6968
return Base::TraverseDecl(D);
7069
}
71-
70+
7271
bool TraverseClassTemplateDecl(ClassTemplateDecl *CTD) {
7372
if (safeGetName(CTD) == "RetainPtr")
7473
return true; // Skip the contents of RetainPtr.
@@ -95,8 +94,9 @@ class RetainPtrCtorAdoptChecker
9594
};
9695

9796
LocalVisitor visitor(this);
98-
Summaries = std::make_unique<RetainSummaryManager>(TUD->getASTContext(),
99-
true /* trackObjCAndCFObjects */, false /* trackOSObjects */);
97+
Summaries = std::make_unique<RetainSummaryManager>(
98+
TUD->getASTContext(), true /* trackObjCAndCFObjects */,
99+
false /* trackOSObjects */);
100100
RTC.visitTranslationUnitDecl(TUD);
101101
visitor.TraverseDecl(const_cast<TranslationUnitDecl *>(TUD));
102102
}
@@ -112,7 +112,7 @@ class RetainPtrCtorAdoptChecker
112112
return Name == "adoptNS" || Name == "adoptNSArc";
113113
}
114114

115-
void visitCallExpr(const CallExpr *CE, const Decl* DeclWithIssue) const {
115+
void visitCallExpr(const CallExpr *CE, const Decl *DeclWithIssue) const {
116116
if (BR->getSourceManager().isInSystemHeader(CE->getExprLoc()))
117117
return;
118118

@@ -138,7 +138,7 @@ class RetainPtrCtorAdoptChecker
138138
}
139139

140140
void visitConstructExpr(const CXXConstructExpr *CE,
141-
const Decl* DeclWithIssue) const {
141+
const Decl *DeclWithIssue) const {
142142
if (BR->getSourceManager().isInSystemHeader(CE->getExprLoc()))
143143
return;
144144

@@ -215,20 +215,20 @@ class RetainPtrCtorAdoptChecker
215215
auto Summary = Summaries->getSummary(AnyCall(ObjCMsgExpr));
216216
auto RetEffect = Summary->getRetEffect();
217217
switch (RetEffect.getKind()) {
218-
case RetEffect::NoRet:
219-
return IsOwnedResult::Unknown;
220-
case RetEffect::OwnedSymbol:
221-
return IsOwnedResult::Owned;
222-
case RetEffect::NotOwnedSymbol:
223-
return IsOwnedResult::NotOwned;
224-
case RetEffect::OwnedWhenTrackedReceiver:
225-
if (auto *Receiver = ObjCMsgExpr->getInstanceReceiver()) {
226-
E = Receiver->IgnoreParenCasts();
227-
continue;
228-
}
229-
return IsOwnedResult::Unknown;
230-
case RetEffect::NoRetHard:
231-
return IsOwnedResult::Unknown;
218+
case RetEffect::NoRet:
219+
return IsOwnedResult::Unknown;
220+
case RetEffect::OwnedSymbol:
221+
return IsOwnedResult::Owned;
222+
case RetEffect::NotOwnedSymbol:
223+
return IsOwnedResult::NotOwned;
224+
case RetEffect::OwnedWhenTrackedReceiver:
225+
if (auto *Receiver = ObjCMsgExpr->getInstanceReceiver()) {
226+
E = Receiver->IgnoreParenCasts();
227+
continue;
228+
}
229+
return IsOwnedResult::Unknown;
230+
case RetEffect::NoRetHard:
231+
return IsOwnedResult::Unknown;
232232
}
233233
}
234234
if (auto *CXXCE = dyn_cast<CXXMemberCallExpr>(E)) {
@@ -262,16 +262,16 @@ class RetainPtrCtorAdoptChecker
262262
auto Summary = Summaries->getSummary(AnyCall(CE));
263263
auto RetEffect = Summary->getRetEffect();
264264
switch (RetEffect.getKind()) {
265-
case RetEffect::NoRet:
266-
return IsOwnedResult::Unknown;
267-
case RetEffect::OwnedSymbol:
268-
return IsOwnedResult::Owned;
269-
case RetEffect::NotOwnedSymbol:
270-
return IsOwnedResult::NotOwned;
271-
case RetEffect::OwnedWhenTrackedReceiver:
272-
return IsOwnedResult::Unknown;
273-
case RetEffect::NoRetHard:
274-
return IsOwnedResult::Unknown;
265+
case RetEffect::NoRet:
266+
return IsOwnedResult::Unknown;
267+
case RetEffect::OwnedSymbol:
268+
return IsOwnedResult::Owned;
269+
case RetEffect::NotOwnedSymbol:
270+
return IsOwnedResult::NotOwned;
271+
case RetEffect::OwnedWhenTrackedReceiver:
272+
return IsOwnedResult::Unknown;
273+
case RetEffect::NoRetHard:
274+
return IsOwnedResult::Unknown;
275275
}
276276
}
277277
break;
@@ -280,8 +280,8 @@ class RetainPtrCtorAdoptChecker
280280
}
281281

282282
template <typename ExprType>
283-
void reportUnknown(std::string& Name, const ExprType *CE,
284-
const Decl* DeclWithIssue) const {
283+
void reportUnknown(std::string &Name, const ExprType *CE,
284+
const Decl *DeclWithIssue) const {
285285
SmallString<100> Buf;
286286
llvm::raw_svector_ostream Os(Buf);
287287

@@ -295,9 +295,9 @@ class RetainPtrCtorAdoptChecker
295295
BR->emitReport(std::move(Report));
296296
}
297297

298-
void reportUseAfterFree(std::string& Name, const CallExpr *CE,
299-
const Decl* DeclWithIssue,
300-
const char* condition = nullptr) const {
298+
void reportUseAfterFree(std::string &Name, const CallExpr *CE,
299+
const Decl *DeclWithIssue,
300+
const char *condition = nullptr) const {
301301
SmallString<100> Buf;
302302
llvm::raw_svector_ostream Os(Buf);
303303

@@ -315,14 +315,14 @@ class RetainPtrCtorAdoptChecker
315315
BR->emitReport(std::move(Report));
316316
}
317317

318-
void reportLeak(std::string& Name, const CXXConstructExpr *CE,
319-
const Decl* DeclWithIssue,
320-
const char* condition = nullptr) const {
318+
void reportLeak(std::string &Name, const CXXConstructExpr *CE,
319+
const Decl *DeclWithIssue,
320+
const char *condition = nullptr) const {
321321
SmallString<100> Buf;
322322
llvm::raw_svector_ostream Os(Buf);
323323

324-
Os << "Incorrect use of " << Name <<
325-
". The argument is +1 and results in a memory leak";
324+
Os << "Incorrect use of " << Name
325+
<< ". The argument is +1 and results in a memory leak";
326326
if (condition)
327327
Os << " " << condition;
328328
Os << ".";
@@ -341,7 +341,6 @@ void ento::registerRetainPtrCtorAdoptChecker(CheckerManager &Mgr) {
341341
Mgr.registerChecker<RetainPtrCtorAdoptChecker>();
342342
}
343343

344-
bool ento::shouldRegisterRetainPtrCtorAdoptChecker(
345-
const CheckerManager &mgr) {
344+
bool ento::shouldRegisterRetainPtrCtorAdoptChecker(const CheckerManager &mgr) {
346345
return true;
347346
}

0 commit comments

Comments
 (0)