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

Commit f78a891

Browse files
authored
Turned "unnecessary value" and "move of const" lints to errors on mac (#36910)
1 parent e35f850 commit f78a891

29 files changed

+124
-69
lines changed

.clang-tidy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Prefix check with "-" to ignore.
2+
# Note: Some of the checks here are used as errors selectively, see
3+
# //ci/lint.sh
24
Checks: "bugprone-use-after-move,\
35
clang-analyzer-*,\
46
clang-diagnostic-*,\
@@ -19,6 +21,8 @@ performance-unnecessary-value-param"
1921
# Add checks when all warnings are fixed
2022
# to prevent new warnings being introduced.
2123
# https://github.com/flutter/flutter/issues/93279
24+
# Note: There are platform specific warnings as errors in
25+
# //ci/lint.sh
2226
WarningsAsErrors: "bugprone-use-after-move,\
2327
clang-analyzer-*,\
2428
readability-identifier-naming,\

ci/lint.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ SRC_DIR="$(cd "$SCRIPT_DIR/../.."; pwd -P)"
3232
FLUTTER_DIR="$(cd "$SCRIPT_DIR/.."; pwd -P)"
3333
DART_BIN="${SRC_DIR}/third_party/dart/tools/sdks/dart-sdk/bin"
3434
DART="${DART_BIN}/dart"
35+
# TODO(https://github.com/flutter/flutter/issues/113848): Migrate all platforms
36+
# to have this as an error.
37+
MAC_HOST_WARNINGS_AS_ERRORS="performance-move-const-arg,performance-unnecessary-value-param"
3538

3639
COMPILE_COMMANDS="$SRC_DIR/out/host_debug/compile_commands.json"
3740
if [ ! -f "$COMPILE_COMMANDS" ]; then
@@ -43,6 +46,7 @@ cd "$SCRIPT_DIR"
4346
--disable-dart-dev \
4447
"$SRC_DIR/flutter/tools/clang_tidy/bin/main.dart" \
4548
--src-dir="$SRC_DIR" \
49+
--mac-host-warnings-as-errors="$MAC_HOST_WARNINGS_AS_ERRORS" \
4650
"$@"
4751

4852
cd "$FLUTTER_DIR"

impeller/renderer/render_target.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ const std::optional<StencilAttachment>& RenderTarget::GetStencilAttachment()
179179

180180
RenderTarget RenderTarget::CreateOffscreen(const Context& context,
181181
ISize size,
182-
std::string label,
182+
const std::string& label,
183183
StorageMode color_storage_mode,
184184
LoadAction color_load_action,
185185
StoreAction color_store_action,
@@ -230,7 +230,7 @@ RenderTarget RenderTarget::CreateOffscreen(const Context& context,
230230
stencil0.texture->SetLabel(SPrintF("%s Stencil Texture", label.c_str()));
231231

232232
RenderTarget target;
233-
target.SetColorAttachment(std::move(color0), 0u);
233+
target.SetColorAttachment(color0, 0u);
234234
target.SetStencilAttachment(std::move(stencil0));
235235

236236
return target;
@@ -239,7 +239,7 @@ RenderTarget RenderTarget::CreateOffscreen(const Context& context,
239239
RenderTarget RenderTarget::CreateOffscreenMSAA(
240240
const Context& context,
241241
ISize size,
242-
std::string label,
242+
const std::string& label,
243243
StorageMode color_storage_mode,
244244
StorageMode color_resolve_storage_mode,
245245
LoadAction color_load_action,
@@ -322,7 +322,7 @@ RenderTarget RenderTarget::CreateOffscreenMSAA(
322322
stencil0.texture->SetLabel(SPrintF("%s Stencil Texture", label.c_str()));
323323

324324
RenderTarget target;
325-
target.SetColorAttachment(std::move(color0), 0u);
325+
target.SetColorAttachment(color0, 0u);
326326
target.SetStencilAttachment(std::move(stencil0));
327327

328328
return target;

impeller/renderer/render_target.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class RenderTarget {
2222
static RenderTarget CreateOffscreen(
2323
const Context& context,
2424
ISize size,
25-
std::string label = "Offscreen",
25+
const std::string& label = "Offscreen",
2626
StorageMode color_storage_mode = StorageMode::kDevicePrivate,
2727
LoadAction color_load_action = LoadAction::kClear,
2828
StoreAction color_store_action = StoreAction::kStore,
@@ -33,7 +33,7 @@ class RenderTarget {
3333
static RenderTarget CreateOffscreenMSAA(
3434
const Context& context,
3535
ISize size,
36-
std::string label = "Offscreen MSAA",
36+
const std::string& label = "Offscreen MSAA",
3737
StorageMode color_storage_mode = StorageMode::kDeviceTransient,
3838
StorageMode color_resolve_storage_mode = StorageMode::kDevicePrivate,
3939
LoadAction color_load_action = LoadAction::kClear,

impeller/typographer/backends/skia/text_render_context_skia.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ static FontGlyphPair::Set CollectUniqueFontGlyphPairsSet(
4747

4848
static FontGlyphPair::Vector CollectUniqueFontGlyphPairs(
4949
GlyphAtlas::Type type,
50-
TextRenderContext::FrameIterator frame_iterator) {
50+
const TextRenderContext::FrameIterator& frame_iterator) {
5151
TRACE_EVENT0("impeller", __FUNCTION__);
5252
FontGlyphPair::Vector vector;
53-
auto set = CollectUniqueFontGlyphPairsSet(type, std::move(frame_iterator));
53+
auto set = CollectUniqueFontGlyphPairsSet(type, frame_iterator);
5454
vector.reserve(set.size());
5555
for (const auto& item : set) {
5656
vector.emplace_back(item);

impeller/typographer/typographer_unittests.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ TEST_P(TypographerTest, LazyAtlasTracksColor) {
8080
LazyGlyphAtlas lazy_atlas;
8181
ASSERT_FALSE(lazy_atlas.HasColor());
8282

83-
lazy_atlas.AddTextFrame(std::move(frame));
83+
lazy_atlas.AddTextFrame(frame);
8484

8585
ASSERT_FALSE(lazy_atlas.HasColor());
8686

8787
frame = TextFrameFromTextBlob(SkTextBlob::MakeFromString("😀 ", emoji_font));
8888

8989
ASSERT_TRUE(frame.HasColor());
9090

91-
lazy_atlas.AddTextFrame(std::move(frame));
91+
lazy_atlas.AddTextFrame(frame);
9292

9393
ASSERT_TRUE(lazy_atlas.HasColor());
9494
}

lib/ui/compositing/scene.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static sk_sp<DlImage> CreateDeferredImage(
110110
width, height, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
111111
return DlDeferredImageGPUSkia::MakeFromLayerTree(
112112
image_info, std::move(layer_tree), std::move(snapshot_delegate),
113-
std::move(raster_task_runner), std::move(unref_queue));
113+
raster_task_runner, std::move(unref_queue));
114114
}
115115

116116
void Scene::RasterizeToImage(uint32_t width,

lib/ui/painting/image_encoding.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,9 @@ Dart_Handle EncodeImage(CanvasImage* canvas_image,
275275
snapshot_delegate =
276276
UIDartState::Current()->GetSnapshotDelegate()]() mutable {
277277
EncodeImageAndInvokeDataCallback(
278-
std::move(image), std::move(callback), image_format, ui_task_runner,
279-
std::move(raster_task_runner), std::move(io_task_runner),
280-
io_manager->GetResourceContext(), std::move(snapshot_delegate),
278+
image, std::move(callback), image_format, ui_task_runner,
279+
raster_task_runner, io_task_runner,
280+
io_manager->GetResourceContext(), snapshot_delegate,
281281
io_manager->GetIsGpuDisabledSyncSwitch());
282282
}));
283283

lib/ui/painting/immutable_buffer.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,9 @@ Dart_Handle ImmutableBuffer::initFromFile(Dart_Handle raw_buffer_handle,
139139
sk_data = MakeSkDataWithCopy(bytes, buffer_size);
140140
}
141141
ui_task_runner->PostTask(
142-
[sk_data = std::move(sk_data), ui_task = std::move(ui_task),
143-
buffer_size]() { ui_task(sk_data, buffer_size); });
142+
[sk_data = std::move(sk_data), ui_task = ui_task, buffer_size]() {
143+
ui_task(sk_data, buffer_size);
144+
});
144145
});
145146
return Dart_Null();
146147
}

lib/ui/painting/multi_frame_codec.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ void MultiFrameCodec::State::GetNextFrameAndInvokeCallback(
184184
int duration = 0;
185185
sk_sp<DlImage> dlImage =
186186
GetNextFrameImage(std::move(resourceContext), gpu_disable_sync_switch,
187-
impeller_context, unref_queue);
187+
std::move(impeller_context), std::move(unref_queue));
188188
if (dlImage) {
189189
image = CanvasImage::Create();
190190
image->set_image(dlImage);

0 commit comments

Comments
 (0)