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

Commit 31afa38

Browse files
authored
[lint] Merge impeller .clang-tidy into main config (#33692)
Merges most (but not all) of the impeller .clang-tidy rules into the main .clang-tidy config. Merges: readability-identifier-naming.PrivateMemberSuffix (_) readability-identifier-naming.EnumConstantPrefix (k) modernize-use-default-member-init.UseAssignment Does not merge: readability-identifier-naming.PublicMethodCase (CamelCase) readability-identifier-naming.PrivateMethodCase (CamelCase) These last two are not merged due to the non-trivial number of existing field accessors that use field_name() methods to directly return field_name_. While these are permitted by the C++ style guide, we may want to move to a single, simple rule and name everything in CamelCase. These can be enabled in a followup patch. No new tests added, since this change is style-only.
1 parent 47988c1 commit 31afa38

31 files changed

+170
-172
lines changed

.clang-tidy

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Checks: "google-*,\
33
clang-analyzer-*,\
44
clang-diagnostic-*,\
5+
modernize-use-default-member-init,\
56
readability-identifier-naming,\
67
-google-objc-global-variable-declaration,\
78
-google-objc-avoid-throwing-exception,\
@@ -22,5 +23,15 @@ google-objc-*,\
2223
google-explicit-constructor"
2324

2425
CheckOptions:
25-
- key: readability-identifier-naming.GlobalConstantPrefix
26-
value: k
26+
- key: modernize-use-default-member-init.UseAssignment
27+
value: true
28+
- key: readability-identifier-naming.EnumConstantCase
29+
value: 'CamelCase'
30+
- key: readability-identifier-naming.EnumConstantPrefix
31+
value: 'k'
32+
- key: readability-identifier-naming.GlobalConstantPrefix
33+
value: 'k'
34+
- key: readability-identifier-naming.PrivateMemberCase
35+
value: 'lower_case'
36+
- key: readability-identifier-naming.PrivateMemberSuffix
37+
value: '_'

ci/licenses_golden/licenses_flutter

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,6 @@ FILE: ../../../flutter/fml/unique_fd.cc
397397
FILE: ../../../flutter/fml/unique_fd.h
398398
FILE: ../../../flutter/fml/unique_object.h
399399
FILE: ../../../flutter/fml/wakeable.h
400-
FILE: ../../../flutter/impeller/.clang-tidy
401400
FILE: ../../../flutter/impeller/aiks/aiks_context.cc
402401
FILE: ../../../flutter/impeller/aiks/aiks_context.h
403402
FILE: ../../../flutter/impeller/aiks/aiks_playground.cc

display_list/display_list_unittests.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,15 +1360,15 @@ TEST(DisplayList, DisplayListBlenderRefHandling) {
13601360
class BlenderRefTester : public virtual AttributeRefTester {
13611361
public:
13621362
void setRefToPaint(SkPaint& paint) const override {
1363-
paint.setBlender(blender);
1363+
paint.setBlender(blender_);
13641364
}
13651365
void setRefToDisplayList(DisplayListBuilder& builder) const override {
1366-
builder.setBlender(blender);
1366+
builder.setBlender(blender_);
13671367
}
1368-
bool ref_is_unique() const override { return blender->unique(); }
1368+
bool ref_is_unique() const override { return blender_->unique(); }
13691369

13701370
private:
1371-
sk_sp<SkBlender> blender =
1371+
sk_sp<SkBlender> blender_ =
13721372
SkBlenders::Arithmetic(0.25, 0.25, 0.25, 0.25, true);
13731373
};
13741374

flow/surface_frame.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ SurfaceFrame::SurfaceFrame(sk_sp<SkSurface> surface,
1717
const SubmitCallback& submit_callback,
1818
std::unique_ptr<GLContextResult> context_result,
1919
bool display_list_fallback)
20-
: submitted_(false),
21-
surface_(surface),
20+
: surface_(surface),
2221
framebuffer_info_(std::move(framebuffer_info)),
2322
submit_callback_(submit_callback),
2423
context_result_(std::move(context_result)) {

fml/platform/posix/mapping_posix.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ Mapping::Mapping() = default;
5151
Mapping::~Mapping() = default;
5252

5353
FileMapping::FileMapping(const fml::UniqueFD& handle,
54-
std::initializer_list<Protection> protection)
55-
: size_(0), mapping_(nullptr) {
54+
std::initializer_list<Protection> protection) {
5655
if (!handle.is_valid()) {
5756
return;
5857
}

fml/synchronization/semaphore.cc

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,44 +15,44 @@ namespace fml {
1515
class PlatformSemaphore {
1616
public:
1717
explicit PlatformSemaphore(uint32_t count)
18-
: _sem(dispatch_semaphore_create(count)), _initial(count) {}
18+
: sem_(dispatch_semaphore_create(count)), initial_(count) {}
1919

2020
~PlatformSemaphore() {
21-
for (uint32_t i = 0; i < _initial; ++i) {
21+
for (uint32_t i = 0; i < initial_; ++i) {
2222
Signal();
2323
}
24-
if (_sem != nullptr) {
25-
dispatch_release(reinterpret_cast<dispatch_object_t>(_sem));
26-
_sem = nullptr;
24+
if (sem_ != nullptr) {
25+
dispatch_release(reinterpret_cast<dispatch_object_t>(sem_));
26+
sem_ = nullptr;
2727
}
2828
}
2929

30-
bool IsValid() const { return _sem != nullptr; }
30+
bool IsValid() const { return sem_ != nullptr; }
3131

3232
bool Wait() {
33-
if (_sem == nullptr) {
33+
if (sem_ == nullptr) {
3434
return false;
3535
}
36-
return dispatch_semaphore_wait(_sem, DISPATCH_TIME_FOREVER) == 0;
36+
return dispatch_semaphore_wait(sem_, DISPATCH_TIME_FOREVER) == 0;
3737
}
3838

3939
bool TryWait() {
40-
if (_sem == nullptr) {
40+
if (sem_ == nullptr) {
4141
return false;
4242
}
4343

44-
return dispatch_semaphore_wait(_sem, DISPATCH_TIME_NOW) == 0;
44+
return dispatch_semaphore_wait(sem_, DISPATCH_TIME_NOW) == 0;
4545
}
4646

4747
void Signal() {
48-
if (_sem != nullptr) {
49-
dispatch_semaphore_signal(_sem);
48+
if (sem_ != nullptr) {
49+
dispatch_semaphore_signal(sem_);
5050
}
5151
}
5252

5353
private:
54-
dispatch_semaphore_t _sem;
55-
const uint32_t _initial;
54+
dispatch_semaphore_t sem_;
55+
const uint32_t initial_;
5656

5757
FML_DISALLOW_COPY_AND_ASSIGN(PlatformSemaphore);
5858
};

impeller/.clang-tidy

Lines changed: 0 additions & 30 deletions
This file was deleted.

impeller/archivist/archive_database.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
namespace impeller {
1818

1919
struct ArchiveDatabase::Handle {
20-
Handle(const std::string& filename) {
20+
explicit Handle(const std::string& filename) {
2121
if (::sqlite3_initialize() != SQLITE_OK) {
2222
VALIDATION_LOG << "Could not initialize sqlite.";
2323
return;

impeller/archivist/archivist_unittests.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static int64_t LastSample = 0;
1818

1919
class Sample : public Archivable {
2020
public:
21-
Sample(uint64_t count = 42) : some_data_(count) {}
21+
explicit Sample(uint64_t count = 42) : some_data_(count) {}
2222

2323
Sample(Sample&&) = default;
2424

impeller/base/base_unittests.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ TEST(ThreadTest, CanCreateRWMutex) {
4444
f.mtx.UnlockWriter();
4545
// int b = f.a; <--- Static analysis error.
4646
f.mtx.LockReader();
47-
int b = f.a;
47+
int b = f.a; // NOLINT(clang-analyzer-deadcode.DeadStores)
4848
FML_ALLOW_UNUSED_LOCAL(b);
4949
f.mtx.UnlockReader();
5050
}
@@ -61,7 +61,7 @@ TEST(ThreadTest, CanCreateRWMutexLock) {
6161
// int b = f.a; <--- Static analysis error.
6262
{
6363
auto read_lock = ReaderLock(f.mtx);
64-
int b = f.a;
64+
int b = f.a; // NOLINT(clang-analyzer-deadcode.DeadStores)
6565
FML_ALLOW_UNUSED_LOCAL(b);
6666
}
6767

0 commit comments

Comments
 (0)