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

Commit 93b7c61

Browse files
authored
removed c style casts and enabled the lint (#57162)
test exempt: should have no functional change ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I added new tests to check the change I am making or feature I am adding, or the PR is [test-exempt]. See [testing the engine] for instructions on writing and running engine tests. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I signed the [CLA]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style [testing the engine]: https://github.com/flutter/engine/blob/main/docs/testing/Testing-the-engine.md [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/master/docs/contributing/Chat.md
1 parent ff8dfad commit 93b7c61

33 files changed

+177
-149
lines changed

.clang-tidy

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Checks: >-
1717
-google-default-arguments,
1818
-google-objc-global-variable-declaration,
1919
-google-objc-avoid-throwing-exception,
20-
-google-readability-casting,
2120
-clang-analyzer-nullability.NullPassedToNonnull,
2221
-clang-analyzer-nullability.NullablePassedToNonnull,
2322
-clang-analyzer-nullability.NullReturnedFromNonnull,

common/graphics/persistent_cache.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ sk_sp<SkData> ParseBase64(const std::string& input) {
176176
size_t output_len;
177177
error = Base64::Decode(input.c_str(), input.length(), nullptr, &output_len);
178178
if (error != Base64::Error::kNone) {
179-
FML_LOG(ERROR) << "Base64 decode error: " << (int)error;
179+
FML_LOG(ERROR) << "Base64 decode error: " << static_cast<int>(error);
180180
FML_LOG(ERROR) << "Base64 can't decode: " << input;
181181
return nullptr;
182182
}
@@ -185,7 +185,7 @@ sk_sp<SkData> ParseBase64(const std::string& input) {
185185
void* output = data->writable_data();
186186
error = Base64::Decode(input.c_str(), input.length(), output, &output_len);
187187
if (error != Base64::Error::kNone) {
188-
FML_LOG(ERROR) << "Base64 decode error: " << (int)error;
188+
FML_LOG(ERROR) << "Base64 decode error: " << static_cast<int>(error);
189189
FML_LOG(ERROR) << "Base64 can't decode: " << input;
190190
return nullptr;
191191
}

display_list/geometry/dl_region.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ DlRegion::SpanChunkHandle DlRegion::SpanBuffer::storeChunk(const Span* begin,
6161
size_t min_capacity = size_ + chunk_size + 1;
6262
if (capacity_ < min_capacity) {
6363
size_t new_capacity = std::max(min_capacity, capacity_ * 2);
64-
new_capacity = std::max(new_capacity, size_t(512));
64+
new_capacity = std::max(new_capacity, static_cast<size_t>(512));
6565
reserve(new_capacity);
6666
}
6767
SpanChunkHandle res = size_;

engine.code-workspace

+3-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@
123123
"__std_stream": "cpp",
124124
"*.ipp": "cpp",
125125
"csetjmp": "cpp",
126-
"cfenv": "cpp"
126+
"cfenv": "cpp",
127+
"execution": "cpp",
128+
"print": "cpp"
127129
},
128130
"C_Cpp.default.includePath": [
129131
"${default}",

flow/layers/backdrop_filter_layer.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void BackdropFilterLayer::Diff(DiffContext* context, const Layer* old_layer) {
4242

4343
void BackdropFilterLayer::Preroll(PrerollContext* context) {
4444
Layer::AutoPrerollSaveLayerState save =
45-
Layer::AutoPrerollSaveLayerState::Create(context, true, bool(filter_));
45+
Layer::AutoPrerollSaveLayerState::Create(context, true, bool{filter_});
4646
if (filter_ && context->view_embedder != nullptr) {
4747
context->view_embedder->PushFilterToVisitedPlatformViews(
4848
filter_, ToSkRect(context->state_stack.device_cull_rect()));

fml/endianness.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ constexpr T ByteSwap(T n) {
4141
if constexpr (sizeof(T) == 1) {
4242
return n;
4343
} else if constexpr (sizeof(T) == 2) {
44-
return (T)FML_BYTESWAP_16((uint16_t)n);
44+
return static_cast<T>(FML_BYTESWAP_16((uint16_t)n));
4545
} else if constexpr (sizeof(T) == 4) {
46-
return (T)FML_BYTESWAP_32((uint32_t)n);
46+
return static_cast<T>(FML_BYTESWAP_32((uint32_t)n));
4747
} else if constexpr (sizeof(T) == 8) {
48-
return (T)FML_BYTESWAP_64((uint64_t)n);
48+
return static_cast<T>(FML_BYTESWAP_64((uint64_t)n));
4949
} else {
5050
static_assert(!sizeof(T), "Unsupported size");
5151
}

impeller/display_list/canvas.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,8 @@ void Canvas::SaveLayer(const Paint& paint,
10141014
subpass_size = ISize(subpass_coverage.GetSize());
10151015
} else {
10161016
did_round_out = true;
1017-
subpass_size = ISize(IRect::RoundOut(subpass_coverage).GetSize());
1017+
subpass_size =
1018+
static_cast<ISize>(IRect::RoundOut(subpass_coverage).GetSize());
10181019
}
10191020
if (subpass_size.IsEmpty()) {
10201021
return SkipUntilMatchingRestore(total_content_depth);

impeller/entity/geometry/point_field_geometry.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ GeometryResult PointFieldGeometry::GetPositionBuffer(
6464

6565
Point center = points_[0];
6666
for (auto& vertex : circle_vertices) {
67-
output[offset++] = Point(center + vertex);
67+
output[offset++] = static_cast<Point>(center + vertex);
6868
}
6969
// For all subequent points, insert a degenerate triangle to break
7070
// the strip. This could be optimized out if we switched to using
@@ -73,9 +73,9 @@ GeometryResult PointFieldGeometry::GetPositionBuffer(
7373
for (size_t i = 1; i < point_count_; i++) {
7474
Point center = points_[i];
7575
output[offset++] = last_point;
76-
output[offset++] = Point(center + circle_vertices[0]);
76+
output[offset++] = static_cast<Point>(center + circle_vertices[0]);
7777
for (const Point& vertex : circle_vertices) {
78-
output[offset++] = Point(center + vertex);
78+
output[offset++] = static_cast<Point>(center + vertex);
7979
}
8080
last_point = circle_vertices.back() + center;
8181
}

impeller/entity/geometry/round_superellipse_geometry.cc

+4-3
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ constexpr Scalar kRatioStep =
5656
Scalar LerpPrecomputedVariable(size_t column, Scalar ratio) {
5757
Scalar steps =
5858
std::clamp<Scalar>((ratio - kMinRatio) / kRatioStep, 0, kNumRecords - 1);
59-
size_t left =
60-
std::clamp<size_t>((size_t)std::floor(steps), 0, kNumRecords - 2);
59+
size_t left = std::clamp<size_t>(static_cast<size_t>(std::floor(steps)), 0,
60+
kNumRecords - 2);
6161
Scalar frac = steps - left;
6262

6363
return (1 - frac) * kPrecomputedVariables[left][column] +
@@ -95,7 +95,8 @@ Scalar CalculateStep(Scalar minDimension, Scalar fullAngle) {
9595
// Assumes at least 1 point is needed per pixel to achieve sufficient
9696
// smoothness.
9797
constexpr Scalar pointsPerPixel = 1.0;
98-
size_t pointsByDimension = (size_t)std::ceil(minDimension * pointsPerPixel);
98+
size_t pointsByDimension =
99+
static_cast<size_t>(std::ceil(minDimension * pointsPerPixel));
99100
Scalar angleByDimension = fullAngle / pointsByDimension;
100101

101102
return std::min(kMinAngleStep, angleByDimension);

impeller/renderer/backend/gles/handle_gles.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,16 @@ class HandleGLES {
8686
HandleGLES(HandleType p_type, UniqueID p_name)
8787
: type_(p_type),
8888
name_(p_name),
89-
hash_(fml::HashCombine(std::underlying_type_t<decltype(p_type)>(p_type),
90-
p_name)) {}
89+
hash_(fml::HashCombine(
90+
static_cast<std::underlying_type_t<decltype(p_type)>>(p_type),
91+
p_name)) {}
9192

9293
HandleGLES(HandleType p_type, std::optional<UniqueID> p_name)
9394
: type_(p_type),
9495
name_(p_name),
95-
hash_(fml::HashCombine(std::underlying_type_t<decltype(p_type)>(p_type),
96-
p_name)) {}
96+
hash_(fml::HashCombine(
97+
static_cast<std::underlying_type_t<decltype(p_type)>>(p_type),
98+
p_name)) {}
9799

98100
static HandleGLES Create(HandleType type) {
99101
return HandleGLES{type, UniqueID{}};

impeller/renderer/backend/gles/shader_library_gles.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ ShaderLibraryGLES::ShaderLibraryGLES(
5757
) -> bool {
5858
const auto stage = ToShaderStage(type);
5959
const auto key_name = GLESShaderNameToShaderKeyName(name, stage);
60-
functions[ShaderKey{key_name, stage}] = std::shared_ptr<ShaderFunctionGLES>(
60+
functions[ShaderKey{key_name, stage}] = std::shared_ptr<ShaderFunctionGLES>{
6161
new ShaderFunctionGLES(library_id, //
6262
stage, //
6363
key_name, //
6464
mapping //
65-
));
65+
)};
6666

6767
return true;
6868
};

impeller/renderer/backend/vulkan/debug_report_vk.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ static std::string JoinVKDebugUtilsObjectNameInfoEXT(
6262
size_t count) {
6363
std::stringstream stream;
6464
for (size_t i = 0u; i < count; i++) {
65-
stream << vk::to_string(vk::ObjectType(names[i].objectType)) << " ["
66-
<< names[i].objectHandle << "] [";
65+
stream << vk::to_string(static_cast<vk::ObjectType>(names[i].objectType))
66+
<< " [" << names[i].objectHandle << "] [";
6767
if (names[i].pObjectName != nullptr) {
6868
stream << names[i].pObjectName;
6969
} else {

0 commit comments

Comments
 (0)