Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Make fml/... compatible with .clang-tidy. #48150

Merged
merged 3 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fml/memory/ref_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class RefPtr final {
// Destructor.
~RefPtr() {
if (ptr_) {
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDelete)
ptr_->Release();
}
}
Expand Down
4 changes: 2 additions & 2 deletions fml/memory/weak_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class WeakPtr {

explicit WeakPtr(T* ptr,
fml::RefPtr<fml::internal::WeakPtrFlag>&& flag,
DebugThreadChecker checker)
const DebugThreadChecker& checker)
: ptr_(ptr), flag_(std::move(flag)), checker_(checker) {}
T* ptr_;
fml::RefPtr<fml::internal::WeakPtrFlag> flag_;
Expand Down Expand Up @@ -203,7 +203,7 @@ class TaskRunnerAffineWeakPtr {
explicit TaskRunnerAffineWeakPtr(
T* ptr,
fml::RefPtr<fml::internal::WeakPtrFlag>&& flag,
DebugTaskRunnerChecker checker)
const DebugTaskRunnerChecker& checker)
: ptr_(ptr), flag_(std::move(flag)), checker_(checker) {}

T* ptr_;
Expand Down
14 changes: 10 additions & 4 deletions fml/platform/darwin/weak_nsobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#import <objc/runtime.h>

#include <stdlib.h>

#include <utility>
#include "flutter/fml/compiler_specific.h"
#include "flutter/fml/logging.h"
#include "flutter/fml/memory/ref_counted.h"
Expand Down Expand Up @@ -73,7 +75,7 @@ class WeakNSObjectFactory;
// receives nullify() from the object's sentinel.
class WeakContainer : public fml::RefCountedThreadSafe<WeakContainer> {
public:
explicit WeakContainer(id object, debug::DebugThreadChecker checker);
explicit WeakContainer(id object, const debug::DebugThreadChecker& checker);

id object() {
CheckThreadSafety();
Expand Down Expand Up @@ -154,6 +156,8 @@ class WeakNSProtocol {
return get() != that;
}

// This appears to be intentional to allow truthiness?
// NOLINTNEXTLINE(google-explicit-constructor)
operator NST() const {
CheckThreadSafety();
return get();
Expand All @@ -162,8 +166,9 @@ class WeakNSProtocol {
protected:
friend class WeakNSObjectFactory<NST>;

explicit WeakNSProtocol(RefPtr<fml::WeakContainer> container, debug::DebugThreadChecker checker)
: container_(container), checker_(checker) {}
explicit WeakNSProtocol(RefPtr<fml::WeakContainer> container,
const debug::DebugThreadChecker& checker)
: container_(std::move(container)), checker_(checker) {}

// Refecounted reference to the container tracking the ObjectiveC object this
// class encapsulates.
Expand Down Expand Up @@ -217,7 +222,8 @@ class WeakNSObject<id> : public WeakNSProtocol<id> {
private:
friend class WeakNSObjectFactory<id>;

explicit WeakNSObject(RefPtr<fml::WeakContainer> container, debug::DebugThreadChecker checker)
explicit WeakNSObject(const RefPtr<fml::WeakContainer>& container,
const debug::DebugThreadChecker& checker)
: WeakNSProtocol<id>(container, checker) {}
};

Expand Down
2 changes: 1 addition & 1 deletion fml/platform/darwin/weak_nsobject.mm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace fml {

WeakContainer::WeakContainer(id object, debug::DebugThreadChecker checker)
WeakContainer::WeakContainer(id object, const debug::DebugThreadChecker& checker)
: object_(object), checker_(checker) {}

WeakContainer::~WeakContainer() {}
Expand Down