Skip to content

Commit e9643fa

Browse files
committed
Fix formatting.
1 parent d6c4e1a commit e9643fa

File tree

4 files changed

+32
-39
lines changed

4 files changed

+32
-39
lines changed

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ bool isRefType(const std::string &Name) {
118118
Name == "RefPtr" || Name == "RefPtrAllowingPartiallyDestroyed";
119119
}
120120

121-
bool isRetainPtr(const std::string &Name) {
122-
return Name == "RetainPtr";
123-
}
121+
bool isRetainPtr(const std::string &Name) { return Name == "RetainPtr"; }
124122

125123
bool isCheckedPtr(const std::string &Name) {
126124
return Name == "CheckedPtr" || Name == "CheckedRef";
@@ -152,8 +150,7 @@ bool isCtorOfRetainPtr(const clang::FunctionDecl *F) {
152150
}
153151

154152
bool isCtorOfSafePtr(const clang::FunctionDecl *F) {
155-
return isCtorOfRefCounted(F) || isCtorOfCheckedPtr(F) ||
156-
isCtorOfRetainPtr(F);
153+
return isCtorOfRefCounted(F) || isCtorOfCheckedPtr(F) || isCtorOfRetainPtr(F);
157154
}
158155

159156
template <typename Predicate>
@@ -181,8 +178,7 @@ bool isRefOrCheckedPtrType(const clang::QualType T) {
181178
}
182179

183180
bool isRetainPtrType(const clang::QualType T) {
184-
return isPtrOfType(
185-
T, [](auto Name) { return Name == "RetainPtr"; });
181+
return isPtrOfType(T, [](auto Name) { return Name == "RetainPtr"; });
186182
}
187183

188184
bool isOwnerPtrType(const clang::QualType T) {

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

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -142,31 +142,28 @@ class RawPtrRefCallArgsChecker
142142
}
143143

144144
bool isPtrOriginSafe(const Expr *Arg) const {
145-
return tryToFindPtrOrigin(Arg, /*StopAtFirstRefCountedObj=*/true,
146-
[&](const clang::CXXRecordDecl *Record) {
147-
return isSafePtr(Record);
148-
},
149-
[&](const clang::QualType T) {
150-
return isSafePtrType(T);
151-
},
152-
[&](const clang::Expr *ArgOrigin, bool IsSafe) {
153-
if (IsSafe)
154-
return true;
155-
if (isa<CXXNullPtrLiteralExpr>(ArgOrigin)) {
156-
// foo(nullptr)
157-
return true;
158-
}
159-
if (isa<IntegerLiteral>(ArgOrigin)) {
160-
// FIXME: Check the value.
161-
// foo(NULL)
162-
return true;
163-
}
164-
if (isASafeCallArg(ArgOrigin))
165-
return true;
166-
if (EFA.isACallToEnsureFn(ArgOrigin))
167-
return true;
168-
return false;
169-
});
145+
return tryToFindPtrOrigin(
146+
Arg, /*StopAtFirstRefCountedObj=*/true,
147+
[&](const clang::CXXRecordDecl *Record) { return isSafePtr(Record); },
148+
[&](const clang::QualType T) { return isSafePtrType(T); },
149+
[&](const clang::Expr *ArgOrigin, bool IsSafe) {
150+
if (IsSafe)
151+
return true;
152+
if (isa<CXXNullPtrLiteralExpr>(ArgOrigin)) {
153+
// foo(nullptr)
154+
return true;
155+
}
156+
if (isa<IntegerLiteral>(ArgOrigin)) {
157+
// FIXME: Check the value.
158+
// foo(NULL)
159+
return true;
160+
}
161+
if (isASafeCallArg(ArgOrigin))
162+
return true;
163+
if (EFA.isACallToEnsureFn(ArgOrigin))
164+
return true;
165+
return false;
166+
});
170167
}
171168

172169
bool shouldSkipCall(const CallExpr *CE) const {

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
#include "clang/AST/DeclCXX.h"
1515
#include "clang/AST/DynamicRecursiveASTVisitor.h"
1616
#include "clang/AST/ParentMapContext.h"
17-
#include "clang/Basic/SourceLocation.h"
1817
#include "clang/Analysis/DomainSpecific/CocoaConventions.h"
18+
#include "clang/Basic/SourceLocation.h"
1919
#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
2020
#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
2121
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
@@ -269,9 +269,7 @@ class RawPtrRefLocalVarsChecker
269269
[&](const clang::CXXRecordDecl *Record) {
270270
return isSafePtr(Record);
271271
},
272-
[&](const clang::QualType Type) {
273-
return isSafePtrType(Type);
274-
},
272+
[&](const clang::QualType Type) { return isSafePtrType(Type); },
275273
[&](const clang::Expr *InitArgOrigin, bool IsSafe) {
276274
if (!InitArgOrigin || IsSafe)
277275
return true;
@@ -401,6 +399,7 @@ class UncheckedLocalVarsChecker final : public RawPtrRefLocalVarsChecker {
401399

402400
class UnretainedLocalVarsChecker final : public RawPtrRefLocalVarsChecker {
403401
mutable bool IsARCEnabled{false};
402+
404403
public:
405404
UnretainedLocalVarsChecker()
406405
: RawPtrRefLocalVarsChecker("Unretained raw pointer or reference not "
@@ -416,8 +415,8 @@ class UnretainedLocalVarsChecker final : public RawPtrRefLocalVarsChecker {
416415
}
417416
const char *ptrKind() const final { return "unretained"; }
418417

419-
void checkASTDecl(const TranslationUnitDecl *TUD,
420-
AnalysisManager &MGR, BugReporter &BRArg) const final {
418+
void checkASTDecl(const TranslationUnitDecl *TUD, AnalysisManager &MGR,
419+
BugReporter &BRArg) const final {
421420
IsARCEnabled = TUD->getLangOpts().ObjCAutoRefCount;
422421
RawPtrRefLocalVarsChecker::checkASTDecl(TUD, MGR, BRArg);
423422
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ class UncountedLambdaCapturesChecker
6161
}
6262

6363
bool shouldCheckThis() {
64-
auto result = !ClsType.isNull() ? isUnsafePtr(ClsType, false) : std::nullopt;
64+
auto result =
65+
!ClsType.isNull() ? isUnsafePtr(ClsType, false) : std::nullopt;
6566
return result && *result;
6667
}
6768

0 commit comments

Comments
 (0)