[go: nahoru, domu]

Skip to content

Commit

Permalink
Enable bugprone-unchecked-optional-access, disable in files with warn…
Browse files Browse the repository at this point in the history
…ings (flutter#42359)

First part of flutter/flutter#127701
  • Loading branch information
zanderso committed May 26, 2023
1 parent 24889bc commit 5293864
Show file tree
Hide file tree
Showing 37 changed files with 177 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ targets:
runIf:
- DEPS
- .ci.yaml
- .clang-tidy
- tools/**
- ci/**
- "**.h"
Expand All @@ -298,6 +299,7 @@ targets:
runIf:
- DEPS
- .ci.yaml
- .clang-tidy
- tools/**
- ci/**
- "**.h"
Expand Down Expand Up @@ -541,6 +543,7 @@ targets:
runIf:
- DEPS
- .ci.yaml
- .clang-tidy
- tools/**
- ci/**
- "**.h"
Expand All @@ -563,6 +566,7 @@ targets:
runIf:
- DEPS
- .ci.yaml
- .clang-tidy
- tools/**
- ci/**
- "**.h"
Expand Down
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -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-*,\
Expand Down
5 changes: 5 additions & 0 deletions flow/layers/clip_path_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -569,3 +572,5 @@ TEST_F(ClipPathLayerTest, EmptyClipDoesNotCullPlatformView) {

} // namespace testing
} // namespace flutter

// NOLINTEND(bugprone-unchecked-optional-access)
5 changes: 5 additions & 0 deletions flow/layers/clip_rect_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -545,3 +548,5 @@ TEST_F(ClipRectLayerTest, EmptyClipDoesNotCullPlatformView) {

} // namespace testing
} // namespace flutter

// NOLINTEND(bugprone-unchecked-optional-access)
5 changes: 5 additions & 0 deletions flow/layers/clip_rrect_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -594,3 +597,5 @@ TEST_F(ClipRRectLayerTest, EmptyClipDoesNotCullPlatformView) {

} // namespace testing
} // namespace flutter

// NOLINTEND(bugprone-unchecked-optional-access)
5 changes: 5 additions & 0 deletions flow/layers/color_filter_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -454,3 +457,5 @@ TEST_F(ColorFilterLayerTest, OpacityInheritance) {

} // namespace testing
} // namespace flutter

// NOLINTEND(bugprone-unchecked-optional-access)
5 changes: 5 additions & 0 deletions flow/layers/container_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -762,3 +765,5 @@ TEST_F(ContainerLayerDiffTest, ReplaceLayer) {

} // namespace testing
} // namespace flutter

// NOLINTEND(bugprone-unchecked-optional-access)
5 changes: 5 additions & 0 deletions flow/layers/display_list_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -570,3 +573,5 @@ TEST_F(DisplayListLayerTest, OverflowCachedDisplayListOpacityInheritance) {

} // namespace testing
} // namespace flutter

// NOLINTEND(bugprone-unchecked-optional-access)
5 changes: 5 additions & 0 deletions flow/layers/display_list_raster_cache_item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -170,3 +173,5 @@ bool DisplayListRasterCacheItem::TryToPrepareRasterCache(
});
}
} // namespace flutter

// NOLINTEND(bugprone-unchecked-optional-access)
5 changes: 5 additions & 0 deletions flow/layers/image_filter_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -710,3 +713,5 @@ TEST_F(ImageFilterLayerDiffTest, ImageFilterLayerInflatestChildSize) {

} // namespace testing
} // namespace flutter

// NOLINTEND(bugprone-unchecked-optional-access)
5 changes: 5 additions & 0 deletions flow/layers/layer_raster_cache_item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -190,3 +193,5 @@ bool LayerRasterCacheItem::Draw(const PaintContext& context,
}

} // namespace flutter

// NOLINTEND(bugprone-unchecked-optional-access)
5 changes: 5 additions & 0 deletions flow/layers/opacity_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -742,3 +745,5 @@ TEST_F(OpacityLayerTest, FullyTransparentDoesNotCullPlatformView) {

} // namespace testing
} // namespace flutter

// NOLINTEND(bugprone-unchecked-optional-access)
5 changes: 5 additions & 0 deletions flow/layers/shader_mask_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -463,3 +466,5 @@ TEST_F(ShaderMaskLayerTest, SimpleFilterWithRasterCacheLayerNotCached) {

} // namespace testing
} // namespace flutter

// NOLINTEND(bugprone-unchecked-optional-access)
5 changes: 5 additions & 0 deletions flow/raster_cache_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -885,3 +888,5 @@ TEST_F(RasterCacheTest, RasterCacheKeyIDLayerChildrenIds) {

} // namespace testing
} // namespace flutter

// NOLINTEND(bugprone-unchecked-optional-access)
5 changes: 5 additions & 0 deletions fml/message_loop_task_queues.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -397,3 +400,5 @@ TaskSource::TopTask MessageLoopTaskQueues::PeekNextTaskUnlocked(
}

} // namespace fml

// NOLINTEND(bugprone-unchecked-optional-access)
5 changes: 5 additions & 0 deletions impeller/aiks/canvas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -658,3 +661,5 @@ void Canvas::DrawAtlas(const std::shared_ptr<Image>& atlas,
}

} // namespace impeller

// NOLINTEND(bugprone-unchecked-optional-access)
5 changes: 5 additions & 0 deletions impeller/aiks/canvas_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -335,3 +338,5 @@ TEST(AiksCanvasTest, PathClipDiffAgainstFullyCoveredCullRect) {

} // namespace testing
} // namespace impeller

// NOLINTEND(bugprone-unchecked-optional-access)
5 changes: 5 additions & 0 deletions impeller/archivist/archivist_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -198,3 +201,5 @@ TEST_F(ArchiveTest, CanReadWriteVectorOfArchivables) {

} // namespace testing
} // namespace impeller

// NOLINTEND(bugprone-unchecked-optional-access)
2 changes: 2 additions & 0 deletions impeller/core/runtime_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions impeller/display_list/dl_image_impeller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -91,3 +94,5 @@ size_t DlImageImpeller::GetApproximateByteSize() const {
}

} // namespace impeller

// NOLINTEND(bugprone-unchecked-optional-access)
5 changes: 5 additions & 0 deletions impeller/display_list/skia_conversions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -177,3 +180,5 @@ std::optional<impeller::PixelFormat> ToPixelFormat(SkColorType type) {

} // namespace skia_conversions
} // namespace impeller

// NOLINTEND(bugprone-unchecked-optional-access)
5 changes: 5 additions & 0 deletions impeller/entity/contents/content_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -409,3 +412,5 @@ void ContentContext::SetWireframe(bool wireframe) {
}

} // namespace impeller

// NOLINTEND(bugprone-unchecked-optional-access)
5 changes: 5 additions & 0 deletions impeller/entity/contents/contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -148,3 +151,5 @@ void Contents::SetColorSourceSize(Size size) {
}

} // namespace impeller

// NOLINTEND(bugprone-unchecked-optional-access)
5 changes: 5 additions & 0 deletions impeller/entity/contents/filters/filter_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -269,3 +272,5 @@ Matrix FilterContents::GetTransform(const Matrix& parent_transform) const {
}

} // namespace impeller

// NOLINTEND(bugprone-unchecked-optional-access)
Loading

0 comments on commit 5293864

Please sign in to comment.