From 24757a381d1c058ccb760d48e92090caebaeeb99 Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Thu, 16 Nov 2023 15:08:58 -0800 Subject: [PATCH 1/3] Make `impeller/{archivist|compiler|core|entity}/...` compatible with `.clang-tidy`. --- impeller/archivist/archive.h | 4 ++-- impeller/archivist/archive_database.h | 2 +- impeller/archivist/archive_vector.h | 2 +- impeller/compiler/compiler_backend.h | 2 +- impeller/compiler/logger.h | 2 +- impeller/core/vertex_buffer.h | 2 +- .../entity/contents/filters/inputs/texture_filter_input.h | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/impeller/archivist/archive.h b/impeller/archivist/archive.h index a232bf4c54441..52206afb0f4ac 100644 --- a/impeller/archivist/archive.h +++ b/impeller/archivist/archive.h @@ -21,7 +21,7 @@ class ArchiveDatabase; class Archive { public: - Archive(const std::string& path); + explicit Archive(const std::string& path); ~Archive(); @@ -45,7 +45,7 @@ class Archive { template ::value>> - [[nodiscard]] size_t Read(UnarchiveStep stepper) { + [[nodiscard]] size_t Read(const UnarchiveStep& stepper) { const ArchiveDef& def = T::kArchiveDefinition; return UnarchiveInstances(def, stepper); } diff --git a/impeller/archivist/archive_database.h b/impeller/archivist/archive_database.h index 57696313c7ec8..561b6d6e57b4d 100644 --- a/impeller/archivist/archive_database.h +++ b/impeller/archivist/archive_database.h @@ -22,7 +22,7 @@ struct ArchiveDef; /// class ArchiveDatabase { public: - ArchiveDatabase(const std::string& filename); + explicit ArchiveDatabase(const std::string& filename); ~ArchiveDatabase(); diff --git a/impeller/archivist/archive_vector.h b/impeller/archivist/archive_vector.h index e99e39d362098..9ea9d11884837 100644 --- a/impeller/archivist/archive_vector.h +++ b/impeller/archivist/archive_vector.h @@ -28,7 +28,7 @@ class ArchiveVector : public Archivable { ArchiveVector(); - ArchiveVector(std::vector keys); + explicit ArchiveVector(std::vector keys); ArchiveVector(const ArchiveVector&) = delete; diff --git a/impeller/compiler/compiler_backend.h b/impeller/compiler/compiler_backend.h index e06ec4ccfc461..ea278014398b1 100644 --- a/impeller/compiler/compiler_backend.h +++ b/impeller/compiler/compiler_backend.h @@ -47,7 +47,7 @@ struct CompilerBackend { spirv_cross::Compiler* GetCompiler(); - operator bool() const; + explicit operator bool() const; enum class ExtendedResourceIndex { kPrimary, diff --git a/impeller/compiler/logger.h b/impeller/compiler/logger.h index 0c478b75d0339..a0642ba1f2239 100644 --- a/impeller/compiler/logger.h +++ b/impeller/compiler/logger.h @@ -15,7 +15,7 @@ namespace compiler { class AutoLogger { public: - AutoLogger(std::stringstream& logger) : logger_(logger) {} + explicit AutoLogger(std::stringstream& logger) : logger_(logger) {} ~AutoLogger() { logger_ << std::endl; diff --git a/impeller/core/vertex_buffer.h b/impeller/core/vertex_buffer.h index 1c62fc8b3b859..5ef934f4b82bf 100644 --- a/impeller/core/vertex_buffer.h +++ b/impeller/core/vertex_buffer.h @@ -17,7 +17,7 @@ struct VertexBuffer { size_t vertex_count = 0u; IndexType index_type = IndexType::kUnknown; - constexpr operator bool() const { + constexpr explicit operator bool() const { return static_cast(vertex_buffer) && (index_type == IndexType::kNone || static_cast(index_buffer)); } diff --git a/impeller/entity/contents/filters/inputs/texture_filter_input.h b/impeller/entity/contents/filters/inputs/texture_filter_input.h index dd4443e14ac8a..757f570800d16 100644 --- a/impeller/entity/contents/filters/inputs/texture_filter_input.h +++ b/impeller/entity/contents/filters/inputs/texture_filter_input.h @@ -31,8 +31,8 @@ class TextureFilterInput final : public FilterInput { Matrix GetLocalTransform(const Entity& entity) const override; private: - TextureFilterInput(std::shared_ptr texture, - Matrix local_transform = Matrix()); + explicit TextureFilterInput(std::shared_ptr texture, + Matrix local_transform = Matrix()); std::shared_ptr texture_; Matrix local_transform_; From 9235319d521b9f773540b5f019dfdf97684ec435 Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Thu, 16 Nov 2023 15:13:18 -0800 Subject: [PATCH 2/3] Make `impeller/geometry/...` compatible with `.clang-tidy`. --- impeller/geometry/color.h | 6 +++++- impeller/geometry/path.h | 2 +- impeller/geometry/path_component.h | 4 ++-- impeller/geometry/rect.h | 7 ++++++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/impeller/geometry/color.h b/impeller/geometry/color.h index e16e87c59ea95..e31a82031b293 100644 --- a/impeller/geometry/color.h +++ b/impeller/geometry/color.h @@ -840,10 +840,14 @@ struct Color { static Color Random() { return { + // This method is not used for cryptographic purposes. + // NOLINTBEGIN(clang-analyzer-security.insecureAPI.rand) static_cast((std::rand() % 255) / 255.0f), // static_cast((std::rand() % 255) / 255.0f), // static_cast((std::rand() % 255) / 255.0f), // - 1.0f // + // NOLINTEND(clang-analyzer-security.insecureAPI.rand) + 1.0f // + }; } diff --git a/impeller/geometry/path.h b/impeller/geometry/path.h index 26f0069604d18..bbdadc230446c 100644 --- a/impeller/geometry/path.h +++ b/impeller/geometry/path.h @@ -125,7 +125,7 @@ class Path { size_t contour_index) const; private: - ReclaimPointBufferCallback reclaim_points; + ReclaimPointBufferCallback reclaim_points_; }; Path(); diff --git a/impeller/geometry/path_component.h b/impeller/geometry/path_component.h index c721afd8c0826..c47b55cbec4f0 100644 --- a/impeller/geometry/path_component.h +++ b/impeller/geometry/path_component.h @@ -102,7 +102,7 @@ struct CubicPathComponent { CubicPathComponent() {} - CubicPathComponent(const QuadraticPathComponent& q) + explicit CubicPathComponent(const QuadraticPathComponent& q) : p1(q.p1), cp1(q.p1 + (q.cp - q.p1) * (2.0 / 3.0)), cp2(q.p2 + (q.cp - q.p2) * (2.0 / 3.0)), @@ -148,7 +148,7 @@ struct ContourComponent { ContourComponent() {} - ContourComponent(Point p, bool is_closed = false) + explicit ContourComponent(Point p, bool is_closed = false) : destination(p), is_closed(is_closed) {} bool operator==(const ContourComponent& other) const { diff --git a/impeller/geometry/rect.h b/impeller/geometry/rect.h index 4c5fbcefffc12..b5daaab457da9 100644 --- a/impeller/geometry/rect.h +++ b/impeller/geometry/rect.h @@ -9,6 +9,7 @@ #include #include +#include "fml/logging.h" #include "impeller/geometry/matrix.h" #include "impeller/geometry/point.h" #include "impeller/geometry/scalar.h" @@ -211,7 +212,11 @@ struct TRect { /// rectangle. constexpr TRect TransformBounds(const Matrix& transform) const { auto points = GetTransformedPoints(transform); - return TRect::MakePointBounds(points.begin(), points.end()).value(); + auto bounds = TRect::MakePointBounds(points.begin(), points.end()); + if (bounds.has_value()) { + return bounds.value(); + } + FML_UNREACHABLE(); } /// @brief Constructs a Matrix that will map all points in the coordinate From f26ca1f3bda3c1ed4bc40bf0d2ffc9edca57ba83 Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Thu, 16 Nov 2023 15:44:36 -0800 Subject: [PATCH 3/3] ++ --- impeller/geometry/path.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/impeller/geometry/path.cc b/impeller/geometry/path.cc index 3884dc8e21af7..3f3300b08e0d7 100644 --- a/impeller/geometry/path.cc +++ b/impeller/geometry/path.cc @@ -228,20 +228,20 @@ bool Path::GetContourComponentAtIndex(size_t index, Path::Polyline::Polyline(Path::Polyline::PointBufferPtr point_buffer, Path::Polyline::ReclaimPointBufferCallback reclaim) - : points(std::move(point_buffer)), reclaim_points(std::move(reclaim)) { + : points(std::move(point_buffer)), reclaim_points_(std::move(reclaim)) { FML_DCHECK(points); } Path::Polyline::Polyline(Path::Polyline&& other) { points = std::move(other.points); - reclaim_points = std::move(other.reclaim_points); + reclaim_points_ = std::move(other.reclaim_points_); contours = std::move(other.contours); } Path::Polyline::~Polyline() { - if (reclaim_points) { + if (reclaim_points_) { points->clear(); - reclaim_points(std::move(points)); + reclaim_points_(std::move(points)); } }