Skip to content

Commit

Permalink
Clean up C++ includes (flutter#21127)
Browse files Browse the repository at this point in the history
Cleans up header order/grouping for consistency: associated header, C/C++ system/standard library headers, library headers, platform-specific #includes.

Adds <cstring> where strlen, memcpy are being used: there are a bunch of places we use them transitively.

Applies linter-required cleanups. Disables linter on one file due to included RapidJson header. See flutter/flutter#65676

This patch does not cover flutter/shell/platform/darwin. There's a separate, slightly more intensive cleanup for those in progress.
  • Loading branch information
cbracken authored Sep 12, 2020
1 parent 2ac4755 commit 08dabe9
Show file tree
Hide file tree
Showing 182 changed files with 340 additions and 202 deletions.
3 changes: 2 additions & 1 deletion flow/gl_context_switch_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
// found in the LICENSE file.
#define FML_USED_ON_EMBEDDER

#include "flutter/flow/gl_context_switch.h"

#include <functional>
#include <future>
#include <memory>

#include "flutter/flow/gl_context_switch.h"
#include "flutter/flow/testing/gl_context_switch_test.h"
#include "gtest/gtest.h"

Expand Down
1 change: 0 additions & 1 deletion flow/layers/backdrop_filter_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#define FLUTTER_FLOW_LAYERS_BACKDROP_FILTER_LAYER_H_

#include "flutter/flow/layers/container_layer.h"

#include "third_party/skia/include/core/SkImageFilter.h"

namespace flutter {
Expand Down
5 changes: 2 additions & 3 deletions flow/layers/child_scene_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
#ifndef FLUTTER_FLOW_LAYERS_CHILD_SCENE_LAYER_H_
#define FLUTTER_FLOW_LAYERS_CHILD_SCENE_LAYER_H_

#include "flutter/flow/layers/layer.h"
#include "flutter/flow/scene_update_context.h"
#include "third_party/skia/include/core/SkMatrix.h"
#include "third_party/skia/include/core/SkPoint.h"
#include "third_party/skia/include/core/SkSize.h"

#include "flutter/flow/layers/layer.h"
#include "flutter/flow/scene_update_context.h"

namespace flutter {

// Layer that represents an embedded child.
Expand Down
2 changes: 0 additions & 2 deletions flow/layers/clip_path_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
#include "flutter/flow/layers/clip_path_layer.h"

#if defined(LEGACY_FUCHSIA_EMBEDDER)

#include "lib/ui/scenic/cpp/commands.h"

#endif

namespace flutter {
Expand Down
1 change: 0 additions & 1 deletion flow/layers/color_filter_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#define FLUTTER_FLOW_LAYERS_COLOR_FILTER_LAYER_H_

#include "flutter/flow/layers/container_layer.h"

#include "third_party/skia/include/core/SkColorFilter.h"

namespace flutter {
Expand Down
1 change: 1 addition & 0 deletions flow/layers/container_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define FLUTTER_FLOW_LAYERS_CONTAINER_LAYER_H_

#include <vector>

#include "flutter/flow/layers/layer.h"

namespace flutter {
Expand Down
7 changes: 3 additions & 4 deletions flow/layers/fuchsia_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <deque>

#include "gtest/gtest.h"

#include <fuchsia/ui/scenic/cpp/fidl.h>
#include <fuchsia/ui/scenic/cpp/fidl_test_base.h>
#include <lib/async-loop/cpp/loop.h>
Expand All @@ -16,6 +12,8 @@
#include <lib/ui/scenic/cpp/id.h>
#include <lib/ui/scenic/cpp/view_token_pair.h>

#include <deque>

#include "flutter/flow/layers/child_scene_layer.h"
#include "flutter/flow/layers/container_layer.h"
#include "flutter/flow/layers/opacity_layer.h"
Expand All @@ -24,6 +22,7 @@
#include "flutter/flow/view_holder.h"
#include "flutter/fml/platform/fuchsia/message_loop_fuchsia.h"
#include "flutter/fml/task_runner.h"
#include "gtest/gtest.h"

namespace flutter {
namespace testing {
Expand Down
1 change: 0 additions & 1 deletion flow/layers/image_filter_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#define FLUTTER_FLOW_LAYERS_IMAGE_FILTER_LAYER_H_

#include "flutter/flow/layers/container_layer.h"

#include "third_party/skia/include/core/SkImageFilter.h"

namespace flutter {
Expand Down
2 changes: 0 additions & 2 deletions flow/layers/layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@
#include "third_party/skia/include/utils/SkNWayCanvas.h"

#if defined(LEGACY_FUCHSIA_EMBEDDER)

#include "flutter/flow/scene_update_context.h" //nogncheck
#include "lib/ui/scenic/cpp/resources.h" //nogncheck
#include "lib/ui/scenic/cpp/session.h" //nogncheck

#endif

namespace flutter {
Expand Down
3 changes: 2 additions & 1 deletion flow/layers/performance_overlay_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "flutter/flow/layers/performance_overlay_layer.h"

#include <iomanip>
#include <iostream>
#include <string>

#include "flutter/flow/layers/performance_overlay_layer.h"
#include "third_party/skia/include/core/SkFont.h"
#include "third_party/skia/include/core/SkTextBlob.h"

Expand Down
6 changes: 3 additions & 3 deletions flow/layers/performance_overlay_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

#include "flutter/flow/layers/performance_overlay_layer.h"

#include <cstdint>
#include <sstream>

#include "flutter/flow/flow_test_utils.h"
#include "flutter/flow/raster_cache.h"
#include "flutter/flow/testing/layer_test.h"
Expand All @@ -18,9 +21,6 @@
#include "third_party/skia/include/core/SkTextBlob.h"
#include "third_party/skia/include/utils/SkBase64.h"

#include <cstdint>
#include <sstream>

namespace flutter {
namespace testing {
namespace {
Expand Down
1 change: 1 addition & 0 deletions flow/layers/platform_view_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

#include "flutter/flow/layers/platform_view_layer.h"

#include "flutter/flow/testing/layer_test.h"
#include "flutter/flow/testing/mock_layer.h"
#include "flutter/fml/macros.h"
Expand Down
1 change: 0 additions & 1 deletion flow/layers/shader_mask_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#define FLUTTER_FLOW_LAYERS_SHADER_MASK_LAYER_H_

#include "flutter/flow/layers/container_layer.h"

#include "third_party/skia/include/core/SkShader.h"

namespace flutter {
Expand Down
3 changes: 2 additions & 1 deletion flow/matrix_decomposition_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

#define _USE_MATH_DEFINES

#include "flutter/flow/matrix_decomposition.h"

#include <cmath>

#include "flutter/flow/matrix_decomposition.h"
#include "gtest/gtest.h"

namespace flutter {
Expand Down
1 change: 0 additions & 1 deletion flow/mutators_stack_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// found in the LICENSE file.

#include "flutter/flow/embedded_views.h"

#include "gtest/gtest.h"

namespace flutter {
Expand Down
1 change: 1 addition & 0 deletions flow/raster_cache_key.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define FLUTTER_FLOW_RASTER_CACHE_KEY_H_

#include <unordered_map>

#include "flutter/flow/matrix_decomposition.h"
#include "flutter/fml/logging.h"

Expand Down
4 changes: 2 additions & 2 deletions flow/skia_gpu_object_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

#include "flutter/flow/skia_gpu_object.h"

#include <future>

#include "flutter/fml/message_loop.h"
#include "flutter/fml/synchronization/waitable_event.h"
#include "flutter/fml/task_runner.h"
#include "flutter/testing/thread_test.h"
#include "gtest/gtest.h"
#include "third_party/skia/include/core/SkRefCnt.h"

#include <future>

namespace flutter {
namespace testing {

Expand Down
6 changes: 3 additions & 3 deletions flow/testing/mock_texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "flutter/flow/texture.h"
#include "flutter/testing/assertions_skia.h"

#include <ostream>
#include <vector>

#include "flutter/flow/texture.h"
#include "flutter/testing/assertions_skia.h"

namespace flutter {
namespace testing {

Expand Down
2 changes: 1 addition & 1 deletion flow/texture_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "flutter/flow/testing/mock_texture.h"
#include "flutter/flow/texture.h"

#include "flutter/flow/testing/mock_texture.h"
#include "gtest/gtest.h"

namespace flutter {
Expand Down
1 change: 1 addition & 0 deletions fml/ascii_trie.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

#include "flutter/fml/ascii_trie.h"

#include "flutter/fml/logging.h"

namespace fml {
Expand Down
1 change: 1 addition & 0 deletions fml/ascii_trie_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

#include "flutter/fml/ascii_trie.h"

#include "gtest/gtest.h"

using fml::AsciiTrie;
Expand Down
4 changes: 2 additions & 2 deletions fml/backtrace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
#include "flutter/fml/backtrace.h"

#include <cxxabi.h>
#include <sstream>

#include <dlfcn.h>
#include <execinfo.h>
#include <signal.h>

#include <sstream>

#include "flutter/fml/logging.h"

namespace fml {
Expand Down
1 change: 1 addition & 0 deletions fml/backtrace_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

#include "backtrace.h"

#include "gtest/gtest.h"
#include "logging.h"

Expand Down
3 changes: 2 additions & 1 deletion fml/base32_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
// found in the LICENSE file.

#include "flutter/fml/base32.h"
#include "gtest/gtest.h"

#include <iostream>

#include "gtest/gtest.h"

TEST(Base32Test, CanEncode) {
{
auto result = fml::Base32Encode("hello");
Expand Down
4 changes: 2 additions & 2 deletions fml/delayed_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#ifndef FLUTTER_FML_DELAYED_TASK_H_
#define FLUTTER_FML_DELAYED_TASK_H_

#include <queue>

#include "flutter/fml/closure.h"
#include "flutter/fml/time/time_point.h"

#include <queue>

namespace fml {

class DelayedTask {
Expand Down
4 changes: 2 additions & 2 deletions fml/eintr_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#ifndef FLUTTER_FML_EINTR_WRAPPER_H_
#define FLUTTER_FML_EINTR_WRAPPER_H_

#include "flutter/fml/build_config.h"

#include <errno.h>

#include "flutter/fml/build_config.h"

#if defined(OS_WIN)

// Windows has no concept of EINTR.
Expand Down
4 changes: 2 additions & 2 deletions fml/file_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <cstring>
#include <memory>
#include <vector>

#include "gtest/gtest.h"

#include "flutter/fml/build_config.h"
#include "flutter/fml/file.h"
#include "flutter/fml/mapping.h"
#include "flutter/fml/paths.h"
#include "flutter/fml/unique_fd.h"
#include "gtest/gtest.h"

static bool WriteStringToFile(const fml::UniqueFD& fd,
const std::string& contents) {
Expand Down
1 change: 1 addition & 0 deletions fml/hash_combine_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

#include "flutter/fml/hash_combine.h"

#include "flutter/testing/testing.h"

namespace fml {
Expand Down
4 changes: 2 additions & 2 deletions fml/log_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#ifndef FLUTTER_FML_LOG_SETTINGS_H_
#define FLUTTER_FML_LOG_SETTINGS_H_

#include "flutter/fml/log_level.h"

#include <string>

#include "flutter/fml/log_level.h"

namespace fml {

// Settings which control the behavior of FML logging.
Expand Down
1 change: 0 additions & 1 deletion fml/memory/ref_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#define FLUTTER_FML_MEMORY_REF_PTR_H_

#include <cstddef>

#include <functional>
#include <utility>

Expand Down
4 changes: 2 additions & 2 deletions fml/memory/task_runner_checker_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

#define FML_USED_ON_EMBEDDER

#include <gtest/gtest.h>
#include "flutter/fml/memory/task_runner_checker.h"

#include <thread>
#include "flutter/fml/memory/task_runner_checker.h"

#include "flutter/fml/message_loop.h"
#include "flutter/fml/raster_thread_merger.h"
#include "flutter/fml/synchronization/count_down_latch.h"
#include "flutter/fml/synchronization/waitable_event.h"
#include "gtest/gtest.h"

namespace fml {
namespace testing {
Expand Down
5 changes: 2 additions & 3 deletions fml/memory/thread_checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@
#define FLUTTER_FML_MEMORY_THREAD_CHECKER_H_

#include "flutter/fml/build_config.h"
#include "flutter/fml/logging.h"
#include "flutter/fml/macros.h"

#if defined(OS_WIN)
#include <windows.h>
#else
#include <pthread.h>
#endif

#include "flutter/fml/logging.h"
#include "flutter/fml/macros.h"

namespace fml {

// A simple class that records the identity of the thread that it was created
Expand Down
Loading

0 comments on commit 08dabe9

Please sign in to comment.