Skip to content

Commit

Permalink
Use the Clang unreachable code warning flag in the engine tree (flutt…
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-simmons authored Aug 8, 2023
1 parent 877e5bc commit 2e2321e
Show file tree
Hide file tree
Showing 19 changed files with 111 additions and 55 deletions.
6 changes: 5 additions & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ declare_args() {

config("config") {
include_dirs = [ ".." ]
cflags = []
if (is_win) {
if (current_cpu != "x86") {
cflags = [ "/WX" ] # Treat warnings as errors.
cflags += [ "/WX" ] # Treat warnings as errors.
}
}
if (is_clang) {
cflags += [ "-Wunreachable-code" ]
}
}

config("export_dynamic_symbols") {
Expand Down
3 changes: 2 additions & 1 deletion display_list/testing/dl_rendering_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3363,7 +3363,7 @@ TEST_F(DisplayListCanvas, DrawTextBlob) {
// default.
#if defined(OS_FUCHSIA)
GTEST_SKIP() << "Rendering comparisons require a valid default font manager";
#endif // OS_FUCHSIA
#else
sk_sp<SkTextBlob> blob =
CanvasCompareTester::MakeTextBlob("Testing", kRenderHeight * 0.33f);
SkScalar render_y_1_3 = kRenderTop + kRenderHeight * 0.3;
Expand All @@ -3388,6 +3388,7 @@ TEST_F(DisplayListCanvas, DrawTextBlob) {
// padding to the tolerance
CanvasCompareTester::DefaultTolerance.addBoundsPadding(33, 13));
EXPECT_TRUE(blob->unique());
#endif // OS_FUCHSIA
}

TEST_F(DisplayListCanvas, DrawShadow) {
Expand Down
3 changes: 2 additions & 1 deletion flow/layers/performance_overlay_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static void TestPerformanceOverlayLayerGold(int refresh_rate) {
// platforms.
#if !defined(FML_OS_LINUX)
GTEST_SKIP() << "Skipping golden tests on non-Linux OSes";
#endif // FML_OS_LINUX
#else
const bool golden_data_matches = golden_data->equals(snapshot_data.get());
if (!golden_data_matches) {
SkFILEWStream wstream(new_golden_file_path.c_str());
Expand All @@ -126,6 +126,7 @@ static void TestPerformanceOverlayLayerGold(int refresh_rate) {
<< "See also the base64 encoded " << new_golden_file_path << ":\n"
<< b64_char;
}
#endif // FML_OS_LINUX
}

} // namespace
Expand Down
12 changes: 8 additions & 4 deletions fml/message_loop_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ TEST(MessageLoop, TIMESENSITIVE(SingleDelayedTaskByDelta)) {
#if defined(OS_FUCHSIA)
GTEST_SKIP()
<< "This test does not work on Fuchsia. https://fxbug.dev/110020 ";
#endif // OS_FUCHSIA
#else

bool checked = false;
std::thread thread([&checked]() {
Expand All @@ -180,13 +180,14 @@ TEST(MessageLoop, TIMESENSITIVE(SingleDelayedTaskByDelta)) {
});
thread.join();
ASSERT_TRUE(checked);
#endif // OS_FUCHSIA
}

TEST(MessageLoop, TIMESENSITIVE(SingleDelayedTaskForTime)) {
#if defined(OS_FUCHSIA)
GTEST_SKIP()
<< "This test does not work on Fuchsia. https://fxbug.dev/110020 ";
#endif // OS_FUCHSIA
#else

bool checked = false;
std::thread thread([&checked]() {
Expand All @@ -207,13 +208,14 @@ TEST(MessageLoop, TIMESENSITIVE(SingleDelayedTaskForTime)) {
});
thread.join();
ASSERT_TRUE(checked);
#endif // OS_FUCHSIA
}

TEST(MessageLoop, TIMESENSITIVE(MultipleDelayedTasksWithIncreasingDeltas)) {
#if defined(OS_FUCHSIA)
GTEST_SKIP()
<< "This test does not work on Fuchsia. https://fxbug.dev/110020 ";
#endif // OS_FUCHSIA
#else

const auto count = 10;
int checked = false;
Expand All @@ -239,13 +241,14 @@ TEST(MessageLoop, TIMESENSITIVE(MultipleDelayedTasksWithIncreasingDeltas)) {
});
thread.join();
ASSERT_EQ(checked, count);
#endif // OS_FUCHSIA
}

TEST(MessageLoop, TIMESENSITIVE(MultipleDelayedTasksWithDecreasingDeltas)) {
#if defined(OS_FUCHSIA)
GTEST_SKIP()
<< "This test does not work on Fuchsia. https://fxbug.dev/110020 ";
#endif // OS_FUCHSIA
#else

const auto count = 10;
int checked = false;
Expand All @@ -271,6 +274,7 @@ TEST(MessageLoop, TIMESENSITIVE(MultipleDelayedTasksWithDecreasingDeltas)) {
});
thread.join();
ASSERT_EQ(checked, count);
#endif // OS_FUCHSIA
}

TEST(MessageLoop, TaskObserverFire) {
Expand Down
3 changes: 2 additions & 1 deletion impeller/entity/contents/runtime_effect_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ bool RuntimeEffectContents::Render(const ContentContext& renderer,
// run m3 applications.
#ifdef FML_OS_ANDROID
return true;
#endif
#else

auto context = renderer.GetContext();
auto library = context->GetShaderLibrary();
Expand Down Expand Up @@ -261,6 +261,7 @@ bool RuntimeEffectContents::Render(const ContentContext& renderer,
return restore.Render(renderer, entity, pass);
}
return true;
#endif // FML_OS_ANDROID
}

} // namespace impeller
3 changes: 2 additions & 1 deletion impeller/renderer/backend/metal/context_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static bool DeviceSupportsFramebufferFetch(id<MTLDevice> device) {
// The iOS simulator lies about supporting framebuffer fetch.
#if FML_OS_IOS_SIMULATOR
return false;
#endif // FML_OS_IOS_SIMULATOR
#else // FML_OS_IOS_SIMULATOR

if (@available(macOS 10.15, iOS 13, tvOS 13, *)) {
return [device supportsFamily:MTLGPUFamilyApple2];
Expand All @@ -34,6 +34,7 @@ static bool DeviceSupportsFramebufferFetch(id<MTLDevice> device) {
#else
return false;
#endif // FML_OS_IOS
#endif // FML_OS_IOS_SIMULATOR
}

static bool DeviceSupportsComputeSubgroups(id<MTLDevice> device) {
Expand Down
7 changes: 4 additions & 3 deletions impeller/renderer/backend/metal/render_pass_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -498,13 +498,13 @@ static bool Bind(PassBindingsCache& pass,
#if TARGET_OS_SIMULATOR
VALIDATION_LOG << "iOS Simulator does not support instanced rendering.";
return false;
#endif
#else // TARGET_OS_SIMULATOR
[encoder drawPrimitives:ToMTLPrimitiveType(primitive_type)
vertexStart:command.base_vertex
vertexCount:command.vertex_count
instanceCount:command.instance_count
baseInstance:0u];

#endif // TARGET_OS_SIMULATOR
} else {
[encoder drawPrimitives:ToMTLPrimitiveType(primitive_type)
vertexStart:command.base_vertex
Expand Down Expand Up @@ -538,7 +538,7 @@ static bool Bind(PassBindingsCache& pass,
#if TARGET_OS_SIMULATOR
VALIDATION_LOG << "iOS Simulator does not support instanced rendering.";
return false;
#endif
#else // TARGET_OS_SIMULATOR
[encoder drawIndexedPrimitives:ToMTLPrimitiveType(primitive_type)
indexCount:command.vertex_count
indexType:ToMTLIndexType(command.index_type)
Expand All @@ -547,6 +547,7 @@ static bool Bind(PassBindingsCache& pass,
instanceCount:command.instance_count
baseVertex:command.base_vertex
baseInstance:0u];
#endif // TARGET_OS_SIMULATOR
} else {
[encoder drawIndexedPrimitives:ToMTLPrimitiveType(primitive_type)
indexCount:command.vertex_count
Expand Down
5 changes: 3 additions & 2 deletions lib/ui/painting/path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,10 @@ tonic::Float32List CanvasPath::getBounds() {
}

bool CanvasPath::op(CanvasPath* path1, CanvasPath* path2, int operation) {
return Op(path1->path(), path2->path(), static_cast<SkPathOp>(operation),
&tracked_path_->path);
bool result = Op(path1->path(), path2->path(),
static_cast<SkPathOp>(operation), &tracked_path_->path);
resetVolatility();
return result;
}

void CanvasPath::clone(Dart_Handle path_handle) {
Expand Down
4 changes: 4 additions & 0 deletions shell/common/rasterizer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,7 @@ TEST(RasterizerTest, TeardownNoSurface) {
TEST(RasterizerTest, presentationTimeSetWhenVsyncTargetInFuture) {
GTEST_SKIP() << "eglPresentationTime is disabled due to "
"https://github.com/flutter/flutter/issues/112503";
#if false
std::string test_name =
::testing::UnitTest::GetInstance()->current_test_info()->name();
ThreadHost thread_host("io.flutter.test." + test_name + ".",
Expand Down Expand Up @@ -1111,11 +1112,13 @@ TEST(RasterizerTest, presentationTimeSetWhenVsyncTargetInFuture) {
latch.Signal();
});
latch.Wait();
#endif // false
}

TEST(RasterizerTest, presentationTimeNotSetWhenVsyncTargetInPast) {
GTEST_SKIP() << "eglPresentationTime is disabled due to "
"https://github.com/flutter/flutter/issues/112503";
#if false
std::string test_name =
::testing::UnitTest::GetInstance()->current_test_info()->name();
ThreadHost thread_host("io.flutter.test." + test_name + ".",
Expand Down Expand Up @@ -1188,6 +1191,7 @@ TEST(RasterizerTest, presentationTimeNotSetWhenVsyncTargetInPast) {
latch.Signal();
});
latch.Wait();
#endif // false
}

} // namespace flutter
6 changes: 5 additions & 1 deletion shell/common/shell_fuchsia_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class FuchsiaShellTest : public ShellTest {
fuchsia::settings::IntlSettings save_settings_;
};

// These functions are used by tests that are currently disabled.
#if false
static bool ValidateShell(Shell* shell) {
if (!shell) {
return false;
Expand Down Expand Up @@ -145,6 +147,7 @@ static void RunCoroutineWithRetry(int retries,
sleep(1);
}
}
#endif // false

// Verifies that changing the Fuchsia settings timezone through the FIDL
// settings interface results in a change of the reported local time in the
Expand All @@ -165,7 +168,7 @@ TEST_F(FuchsiaShellTest, LocaltimesVaryOnTimezoneChanges) {
#if defined(OS_FUCHSIA)
GTEST_SKIP()
<< "This test fails after the CF V2 migration. https://fxbug.dev/110019 ";
#endif // OS_FUCHSIA
#else

// See fixtures/shell_test.dart, the callback NotifyLocalTime is declared
// there.
Expand Down Expand Up @@ -258,6 +261,7 @@ TEST_F(FuchsiaShellTest, LocaltimesVaryOnTimezoneChanges) {
continue_fixture = false;
fixture_latch.Signal();
DestroyShell(std::move(shell));
#endif // OS_FUCHSIA
}

} // namespace testing
Expand Down
Loading

0 comments on commit 2e2321e

Please sign in to comment.