Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed c style casts and enabled the lint #57162

Merged
merged 7 commits into from
Dec 12, 2024
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: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Checks: >-
-google-default-arguments,
-google-objc-global-variable-declaration,
-google-objc-avoid-throwing-exception,
-google-readability-casting,
-clang-analyzer-nullability.NullPassedToNonnull,
-clang-analyzer-nullability.NullablePassedToNonnull,
-clang-analyzer-nullability.NullReturnedFromNonnull,
Expand Down
4 changes: 2 additions & 2 deletions common/graphics/persistent_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ sk_sp<SkData> ParseBase64(const std::string& input) {
size_t output_len;
error = Base64::Decode(input.c_str(), input.length(), nullptr, &output_len);
if (error != Base64::Error::kNone) {
FML_LOG(ERROR) << "Base64 decode error: " << (int)error;
FML_LOG(ERROR) << "Base64 decode error: " << static_cast<int>(error);
FML_LOG(ERROR) << "Base64 can't decode: " << input;
return nullptr;
}
Expand All @@ -185,7 +185,7 @@ sk_sp<SkData> ParseBase64(const std::string& input) {
void* output = data->writable_data();
error = Base64::Decode(input.c_str(), input.length(), output, &output_len);
if (error != Base64::Error::kNone) {
FML_LOG(ERROR) << "Base64 decode error: " << (int)error;
FML_LOG(ERROR) << "Base64 decode error: " << static_cast<int>(error);
FML_LOG(ERROR) << "Base64 can't decode: " << input;
return nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion display_list/geometry/dl_region.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ DlRegion::SpanChunkHandle DlRegion::SpanBuffer::storeChunk(const Span* begin,
size_t min_capacity = size_ + chunk_size + 1;
if (capacity_ < min_capacity) {
size_t new_capacity = std::max(min_capacity, capacity_ * 2);
new_capacity = std::max(new_capacity, size_t(512));
new_capacity = std::max(new_capacity, static_cast<size_t>(512));
reserve(new_capacity);
}
SpanChunkHandle res = size_;
Expand Down
4 changes: 3 additions & 1 deletion engine.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@
"__std_stream": "cpp",
"*.ipp": "cpp",
"csetjmp": "cpp",
"cfenv": "cpp"
"cfenv": "cpp",
"execution": "cpp",
"print": "cpp"
},
"C_Cpp.default.includePath": [
"${default}",
Expand Down
2 changes: 1 addition & 1 deletion flow/layers/backdrop_filter_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void BackdropFilterLayer::Diff(DiffContext* context, const Layer* old_layer) {

void BackdropFilterLayer::Preroll(PrerollContext* context) {
Layer::AutoPrerollSaveLayerState save =
Layer::AutoPrerollSaveLayerState::Create(context, true, bool(filter_));
Layer::AutoPrerollSaveLayerState::Create(context, true, bool{filter_});
if (filter_ && context->view_embedder != nullptr) {
context->view_embedder->PushFilterToVisitedPlatformViews(
filter_, ToSkRect(context->state_stack.device_cull_rect()));
Expand Down
6 changes: 3 additions & 3 deletions fml/endianness.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ constexpr T ByteSwap(T n) {
if constexpr (sizeof(T) == 1) {
return n;
} else if constexpr (sizeof(T) == 2) {
return (T)FML_BYTESWAP_16((uint16_t)n);
return static_cast<T>(FML_BYTESWAP_16((uint16_t)n));
} else if constexpr (sizeof(T) == 4) {
return (T)FML_BYTESWAP_32((uint32_t)n);
return static_cast<T>(FML_BYTESWAP_32((uint32_t)n));
} else if constexpr (sizeof(T) == 8) {
return (T)FML_BYTESWAP_64((uint64_t)n);
return static_cast<T>(FML_BYTESWAP_64((uint64_t)n));
} else {
static_assert(!sizeof(T), "Unsupported size");
}
Expand Down
3 changes: 2 additions & 1 deletion impeller/display_list/canvas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,8 @@ void Canvas::SaveLayer(const Paint& paint,
subpass_size = ISize(subpass_coverage.GetSize());
} else {
did_round_out = true;
subpass_size = ISize(IRect::RoundOut(subpass_coverage).GetSize());
subpass_size =
static_cast<ISize>(IRect::RoundOut(subpass_coverage).GetSize());
}
if (subpass_size.IsEmpty()) {
return SkipUntilMatchingRestore(total_content_depth);
Expand Down
6 changes: 3 additions & 3 deletions impeller/entity/geometry/point_field_geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ GeometryResult PointFieldGeometry::GetPositionBuffer(

Point center = points_[0];
for (auto& vertex : circle_vertices) {
output[offset++] = Point(center + vertex);
output[offset++] = static_cast<Point>(center + vertex);
gaaclarke marked this conversation as resolved.
Show resolved Hide resolved
}
// For all subequent points, insert a degenerate triangle to break
// the strip. This could be optimized out if we switched to using
Expand All @@ -73,9 +73,9 @@ GeometryResult PointFieldGeometry::GetPositionBuffer(
for (size_t i = 1; i < point_count_; i++) {
Point center = points_[i];
output[offset++] = last_point;
output[offset++] = Point(center + circle_vertices[0]);
output[offset++] = static_cast<Point>(center + circle_vertices[0]);
gaaclarke marked this conversation as resolved.
Show resolved Hide resolved
for (const Point& vertex : circle_vertices) {
output[offset++] = Point(center + vertex);
output[offset++] = static_cast<Point>(center + vertex);
}
last_point = circle_vertices.back() + center;
}
Expand Down
7 changes: 4 additions & 3 deletions impeller/entity/geometry/round_superellipse_geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ constexpr Scalar kRatioStep =
Scalar LerpPrecomputedVariable(size_t column, Scalar ratio) {
Scalar steps =
std::clamp<Scalar>((ratio - kMinRatio) / kRatioStep, 0, kNumRecords - 1);
size_t left =
std::clamp<size_t>((size_t)std::floor(steps), 0, kNumRecords - 2);
size_t left = std::clamp<size_t>(static_cast<size_t>(std::floor(steps)), 0,
kNumRecords - 2);
Scalar frac = steps - left;

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

return std::min(kMinAngleStep, angleByDimension);
Expand Down
10 changes: 6 additions & 4 deletions impeller/renderer/backend/gles/handle_gles.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,16 @@ class HandleGLES {
HandleGLES(HandleType p_type, UniqueID p_name)
: type_(p_type),
name_(p_name),
hash_(fml::HashCombine(std::underlying_type_t<decltype(p_type)>(p_type),
p_name)) {}
hash_(fml::HashCombine(
static_cast<std::underlying_type_t<decltype(p_type)>>(p_type),
p_name)) {}

HandleGLES(HandleType p_type, std::optional<UniqueID> p_name)
: type_(p_type),
name_(p_name),
hash_(fml::HashCombine(std::underlying_type_t<decltype(p_type)>(p_type),
p_name)) {}
hash_(fml::HashCombine(
static_cast<std::underlying_type_t<decltype(p_type)>>(p_type),
p_name)) {}

static HandleGLES Create(HandleType type) {
return HandleGLES{type, UniqueID{}};
Expand Down
4 changes: 2 additions & 2 deletions impeller/renderer/backend/gles/shader_library_gles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ ShaderLibraryGLES::ShaderLibraryGLES(
) -> bool {
const auto stage = ToShaderStage(type);
const auto key_name = GLESShaderNameToShaderKeyName(name, stage);
functions[ShaderKey{key_name, stage}] = std::shared_ptr<ShaderFunctionGLES>(
functions[ShaderKey{key_name, stage}] = std::shared_ptr<ShaderFunctionGLES>{
new ShaderFunctionGLES(library_id, //
stage, //
key_name, //
mapping //
));
)};

return true;
};
Expand Down
4 changes: 2 additions & 2 deletions impeller/renderer/backend/vulkan/debug_report_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ static std::string JoinVKDebugUtilsObjectNameInfoEXT(
size_t count) {
std::stringstream stream;
for (size_t i = 0u; i < count; i++) {
stream << vk::to_string(vk::ObjectType(names[i].objectType)) << " ["
<< names[i].objectHandle << "] [";
stream << vk::to_string(static_cast<vk::ObjectType>(names[i].objectType))
<< " [" << names[i].objectHandle << "] [";
if (names[i].pObjectName != nullptr) {
stream << names[i].pObjectName;
} else {
Expand Down
Loading
Loading