Enable bugprone-unchecked-optional-access, disable in files with warnings (flutter/engine#42359)

First part of https://github.com/flutter/flutter/issues/127701
This commit is contained in:
Zachary Anderson
2023-05-26 14:58:46 -07:00
committed by GitHub
parent 9a5ec10306
commit 5633d0d833
37 changed files with 177 additions and 0 deletions

View File

@@ -278,6 +278,7 @@ targets:
runIf:
- DEPS
- .ci.yaml
- .clang-tidy
- tools/**
- ci/**
- "**.h"
@@ -298,6 +299,7 @@ targets:
runIf:
- DEPS
- .ci.yaml
- .clang-tidy
- tools/**
- ci/**
- "**.h"
@@ -541,6 +543,7 @@ targets:
runIf:
- DEPS
- .ci.yaml
- .clang-tidy
- tools/**
- ci/**
- "**.h"
@@ -563,6 +566,7 @@ targets:
runIf:
- DEPS
- .ci.yaml
- .clang-tidy
- tools/**
- ci/**
- "**.h"

View File

@@ -2,6 +2,7 @@
# Note: Some of the checks here are used as errors selectively, see
# //ci/lint.sh
Checks: "bugprone-use-after-move,\
bugprone-unchecked-optional-access,\
clang-analyzer-*,\
clang-diagnostic-*,\
darwin-*,\

View File

@@ -14,6 +14,9 @@
#include "flutter/fml/macros.h"
#include "gtest/gtest.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace flutter {
namespace testing {
@@ -569,3 +572,5 @@ TEST_F(ClipPathLayerTest, EmptyClipDoesNotCullPlatformView) {
} // namespace testing
} // namespace flutter
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -12,6 +12,9 @@
#include "flutter/flow/testing/mock_layer.h"
#include "flutter/fml/macros.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace flutter {
namespace testing {
@@ -545,3 +548,5 @@ TEST_F(ClipRectLayerTest, EmptyClipDoesNotCullPlatformView) {
} // namespace testing
} // namespace flutter
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -12,6 +12,9 @@
#include "flutter/flow/testing/mock_layer.h"
#include "flutter/fml/macros.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace flutter {
namespace testing {
@@ -594,3 +597,5 @@ TEST_F(ClipRRectLayerTest, EmptyClipDoesNotCullPlatformView) {
} // namespace testing
} // namespace flutter
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -17,6 +17,9 @@
#include "flutter/flow/testing/mock_layer.h"
#include "flutter/fml/macros.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace flutter {
namespace testing {
@@ -454,3 +457,5 @@ TEST_F(ColorFilterLayerTest, OpacityInheritance) {
} // namespace testing
} // namespace flutter
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -13,6 +13,9 @@
#include "gtest/gtest.h"
#include "include/core/SkMatrix.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace flutter {
namespace testing {
@@ -762,3 +765,5 @@ TEST_F(ContainerLayerDiffTest, ReplaceLayer) {
} // namespace testing
} // namespace flutter
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -11,6 +11,9 @@
#include "flutter/flow/testing/diff_context_test.h"
#include "flutter/fml/macros.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace flutter {
namespace testing {
@@ -570,3 +573,5 @@ TEST_F(DisplayListLayerTest, OverflowCachedDisplayListOpacityInheritance) {
} // namespace testing
} // namespace flutter
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -16,6 +16,9 @@
#include "flutter/flow/raster_cache_util.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace flutter {
static bool IsDisplayListWorthRasterizing(
@@ -170,3 +173,5 @@ bool DisplayListRasterCacheItem::TryToPrepareRasterCache(
});
}
} // namespace flutter
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -15,6 +15,9 @@
#include "include/core/SkPath.h"
#include "third_party/skia/include/effects/SkImageFilters.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace flutter {
namespace testing {
@@ -710,3 +713,5 @@ TEST_F(ImageFilterLayerDiffTest, ImageFilterLayerInflatestChildSize) {
} // namespace testing
} // namespace flutter
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -7,6 +7,9 @@
#include "flutter/flow/raster_cache_item.h"
#include "flutter/flow/raster_cache_util.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace flutter {
LayerRasterCacheItem::LayerRasterCacheItem(Layer* layer,
@@ -190,3 +193,5 @@ bool LayerRasterCacheItem::Draw(const PaintContext& context,
}
} // namespace flutter
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -18,6 +18,9 @@
#include "flutter/testing/display_list_testing.h"
#include "gtest/gtest.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace flutter {
namespace testing {
@@ -742,3 +745,5 @@ TEST_F(OpacityLayerTest, FullyTransparentDoesNotCullPlatformView) {
} // namespace testing
} // namespace flutter
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -13,6 +13,9 @@
#include "flutter/fml/macros.h"
#include "gtest/gtest.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace flutter {
namespace testing {
@@ -463,3 +466,5 @@ TEST_F(ShaderMaskLayerTest, SimpleFilterWithRasterCacheLayerNotCached) {
} // namespace testing
} // namespace flutter
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -24,6 +24,9 @@
#include "third_party/skia/include/core/SkPicture.h"
#include "third_party/skia/include/core/SkPictureRecorder.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace flutter {
namespace testing {
@@ -885,3 +888,5 @@ TEST_F(RasterCacheTest, RasterCacheKeyIDLayerChildrenIds) {
} // namespace testing
} // namespace flutter
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -15,6 +15,9 @@
#include "flutter/fml/task_source.h"
#include "flutter/fml/thread_local.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace fml {
const size_t TaskQueueId::kUnmerged = ULONG_MAX;
@@ -397,3 +400,5 @@ TaskSource::TopTask MessageLoopTaskQueues::PeekNextTaskUnlocked(
}
} // namespace fml
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -20,6 +20,9 @@
#include "impeller/entity/geometry/geometry.h"
#include "impeller/geometry/path_builder.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace impeller {
Canvas::Canvas() {
@@ -658,3 +661,5 @@ void Canvas::DrawAtlas(const std::shared_ptr<Image>& atlas,
}
} // namespace impeller
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -6,6 +6,9 @@
#include "impeller/aiks/canvas.h"
#include "impeller/geometry/path_builder.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace impeller {
namespace testing {
@@ -335,3 +338,5 @@ TEST(AiksCanvasTest, PathClipDiffAgainstFullyCoveredCullRect) {
} // namespace testing
} // namespace impeller
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -11,6 +11,9 @@
#include "impeller/archivist/archive_location.h"
#include "impeller/archivist/archivist_fixture.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace impeller {
namespace testing {
@@ -198,3 +201,5 @@ TEST_F(ArchiveTest, CanReadWriteVectorOfArchivables) {
} // namespace testing
} // namespace impeller
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -9,6 +9,8 @@ namespace impeller {
size_t RuntimeUniformDescription::GetSize() const {
size_t size = dimensions.rows * dimensions.cols * bit_width / 8u;
if (array_elements.value_or(0) > 0) {
// Covered by check on the line above.
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
size *= array_elements.value();
}
return size;

View File

@@ -7,6 +7,9 @@
#include "impeller/aiks/aiks_context.h"
#include "impeller/entity/contents/filters/filter_contents.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace impeller {
sk_sp<DlImageImpeller> DlImageImpeller::Make(std::shared_ptr<Texture> texture,
@@ -91,3 +94,5 @@ size_t DlImageImpeller::GetApproximateByteSize() const {
}
} // namespace impeller
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -4,6 +4,9 @@
#include "impeller/display_list/skia_conversions.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace impeller {
namespace skia_conversions {
@@ -177,3 +180,5 @@ std::optional<impeller::PixelFormat> ToPixelFormat(SkColorType type) {
} // namespace skia_conversions
} // namespace impeller
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -16,6 +16,9 @@
#include "impeller/renderer/render_target.h"
#include "impeller/tessellator/tessellator.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace impeller {
void ContentContextOptions::ApplyToPipelineDescriptor(
@@ -409,3 +412,5 @@ void ContentContext::SetWireframe(bool wireframe) {
}
} // namespace impeller
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -15,6 +15,9 @@
#include "impeller/renderer/command_buffer.h"
#include "impeller/renderer/render_pass.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace impeller {
ContentContextOptions OptionsFromPass(const RenderPass& pass) {
@@ -148,3 +151,5 @@ void Contents::SetColorSourceSize(Size size) {
}
} // namespace impeller
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -28,6 +28,9 @@
#include "impeller/renderer/command_buffer.h"
#include "impeller/renderer/render_pass.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace impeller {
std::shared_ptr<FilterContents> FilterContents::MakeDirectionalGaussianBlur(
@@ -269,3 +272,5 @@ Matrix FilterContents::GetTransform(const Matrix& parent_transform) const {
}
} // namespace impeller
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -14,6 +14,9 @@
#include "impeller/renderer/render_pass.h"
#include "impeller/renderer/sampler_library.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace impeller {
static std::optional<SamplerAddressMode> TileModeToAddressMode(
@@ -195,3 +198,5 @@ bool TiledTextureContents::Render(const ContentContext& renderer,
}
} // namespace impeller
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -34,6 +34,9 @@
#include "impeller/entity/contents/checkerboard_contents.h"
#endif // IMPELLER_DEBUG
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace impeller {
EntityPass::EntityPass() = default;
@@ -910,3 +913,5 @@ void EntityPass::SetEnableOffscreenCheckerboard(bool enabled) {
}
} // namespace impeller
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -54,6 +54,9 @@
#include "third_party/imgui/imgui.h"
#include "third_party/skia/include/core/SkTextBlob.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace impeller {
namespace testing {
@@ -2637,3 +2640,5 @@ TEST_P(EntityTest, PointFieldGeometryDivisions) {
} // namespace testing
} // namespace impeller
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -20,6 +20,9 @@
#include "impeller/geometry/scalar.h"
#include "impeller/geometry/size.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace impeller {
namespace testing {
@@ -2203,3 +2206,5 @@ TEST(GeometryTest, HalfConversions) {
} // namespace testing
} // namespace impeller
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -34,6 +34,9 @@
#include "impeller/renderer/render_pass.h"
#include "impeller/renderer/sampler_library.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
struct ImGui_ImplImpeller_Data {
std::shared_ptr<impeller::Context> context;
std::shared_ptr<impeller::Texture> font_texture;
@@ -269,3 +272,5 @@ void ImGui_ImplImpeller_RenderDrawData(ImDrawData* draw_data,
index_buffer_offset += draw_list_idx_bytes;
}
}
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -4,6 +4,9 @@
#include "impeller/renderer/capabilities.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace impeller {
Capabilities::Capabilities() = default;
@@ -221,3 +224,5 @@ std::unique_ptr<Capabilities> CapabilitiesBuilder::Build() {
}
} // namespace impeller
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -39,6 +39,9 @@
#include "impeller/tessellator/tessellator.h"
#include "third_party/imgui/imgui.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace impeller {
namespace testing {
@@ -1043,3 +1046,5 @@ TEST_P(RendererTest, VertexBufferBuilder) {
} // namespace testing
} // namespace impeller
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -11,6 +11,9 @@
#include "third_party/skia/include/core/SkData.h"
#include "third_party/skia/include/core/SkTextBlob.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace impeller {
namespace testing {
@@ -289,3 +292,5 @@ TEST_P(TypographerTest, MaybeHasOverlapping) {
} // namespace testing
} // namespace impeller
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -25,6 +25,9 @@
#include "third_party/skia/include/gpu/ganesh/SkSurfaceGanesh.h"
#include "third_party/skia/include/utils/SkBase64.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace flutter {
// The rasterizer will tell Skia to purge cached resources that have not been
@@ -867,3 +870,5 @@ Rasterizer::Screenshot::Screenshot(const Screenshot& other) = default;
Rasterizer::Screenshot::~Screenshot() = default;
} // namespace flutter
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -33,6 +33,9 @@
#include "third_party/skia/include/utils/SkBase64.h"
#include "third_party/tonic/common/log.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace flutter {
constexpr char kSkiaChannel[] = "flutter/skia";
@@ -2121,3 +2124,5 @@ Shell::GetConcurrentWorkerTaskRunner() const {
}
} // namespace flutter
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -10,6 +10,9 @@
#include "gtest/gtest.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace flutter {
namespace testing {
@@ -114,3 +117,5 @@ TEST(SwitchesTest, NoEnableImpeller) {
} // namespace testing
} // namespace flutter
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -11,6 +11,9 @@
#include "flutter/shell/platform/embedder/embedder_render_target.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace flutter {
EmbedderExternalViewEmbedder::EmbedderExternalViewEmbedder(
@@ -264,3 +267,5 @@ void EmbedderExternalViewEmbedder::SubmitFrame(
}
} // namespace flutter
// NOLINTEND(bugprone-unchecked-optional-access)

View File

@@ -17,6 +17,9 @@
#include <memory>
#include <utility>
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)
namespace flutter {
namespace testing {
@@ -380,3 +383,5 @@ bool EmbedderTestBackingStoreProducer::CreateVulkanImage(
} // namespace testing
} // namespace flutter
// NOLINTEND(bugprone-unchecked-optional-access)