Add missing header guards (#41322)
These keep turning up, so I did a little bash-fu to find them all.
```bash
grep -lL "#pragma once" $(grep -lL "#ifndef .*_H_" $(find . | grep "\.h$")) | cut -c 3-
```
diff --git a/common/constants.h b/common/constants.h
index 50b0f91..378f7c8 100644
--- a/common/constants.h
+++ b/common/constants.h
@@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef FLUTTER_COMMON_CONSTANTS_H_
+#define FLUTTER_COMMON_CONSTANTS_H_
+
namespace flutter {
constexpr double kMegaByteSizeInBytes = (1 << 20);
} // namespace flutter
+
+#endif // FLUTTER_COMMON_CONSTANTS_H_
diff --git a/flow/flow_test_utils.h b/flow/flow_test_utils.h
index ed4ca28..a436181 100644
--- a/flow/flow_test_utils.h
+++ b/flow/flow_test_utils.h
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef FLUTTER_FLOW_TEST_UTILS_H_
+#define FLUTTER_FLOW_TEST_UTILS_H_
+
#include <string>
namespace flutter {
@@ -15,3 +18,5 @@
void SetFontFile(const std::string& dir);
} // namespace flutter
+
+#endif // FLUTTER_FLOW_TEST_UTILS_H_
diff --git a/flow/paint_region.h b/flow/paint_region.h
index 1fd8896..be12c82 100644
--- a/flow/paint_region.h
+++ b/flow/paint_region.h
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef FLUTTER_FLOW_PAINT_REGION_H_
+#define FLUTTER_FLOW_PAINT_REGION_H_
+
#include <vector>
#include "flutter/fml/logging.h"
#include "third_party/skia/include/core/SkRect.h"
@@ -65,3 +68,5 @@
};
} // namespace flutter
+
+#endif // FLUTTER_FLOW_PAINT_REGION_H_
diff --git a/flow/testing/diff_context_test.h b/flow/testing/diff_context_test.h
index f606e42..69beb41 100644
--- a/flow/testing/diff_context_test.h
+++ b/flow/testing/diff_context_test.h
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef FLUTTER_SHELL_DIFF_CONTEXT_TEST_H_
+#define FLUTTER_SHELL_DIFF_CONTEXT_TEST_H_
+
#include "flutter/flow/layers/container_layer.h"
#include "flutter/flow/layers/display_list_layer.h"
#include "flutter/flow/layers/opacity_layer.h"
@@ -66,3 +69,5 @@
} // namespace testing
} // namespace flutter
+
+#endif // FLUTTER_SHELL_DIFF_CONTEXT_TEST_H_
diff --git a/flow/testing/mock_texture.h b/flow/testing/mock_texture.h
index bf5d79b..c1b786e 100644
--- a/flow/testing/mock_texture.h
+++ b/flow/testing/mock_texture.h
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef FLOW_TESTING_MOCK_TEXTURE_H_
+#define FLOW_TESTING_MOCK_TEXTURE_H_
+
#include <ostream>
#include <vector>
@@ -57,3 +60,5 @@
} // namespace testing
} // namespace flutter
+
+#endif // FLOW_TESTING_MOCK_TEXTURE_H_
diff --git a/fml/math.h b/fml/math.h
index 848f161..6182ada 100644
--- a/fml/math.h
+++ b/fml/math.h
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef FLUTTER_FML_MATH_H_
+#define FLUTTER_FML_MATH_H_
+
namespace flutter {
namespace math {
@@ -46,3 +49,5 @@
} // namespace math
} // namespace flutter
+
+#endif // FLUTTER_FML_MATH_H_
diff --git a/impeller/archivist/archive_class_registration.h b/impeller/archivist/archive_class_registration.h
index d290a46..7976fe3 100644
--- a/impeller/archivist/archive_class_registration.h
+++ b/impeller/archivist/archive_class_registration.h
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#pragma once
+
#include <map>
#include <optional>
diff --git a/impeller/entity/contents/scene_contents.h b/impeller/entity/contents/scene_contents.h
index def5a36..9191728 100644
--- a/impeller/entity/contents/scene_contents.h
+++ b/impeller/entity/contents/scene_contents.h
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#pragma once
+
#include <memory>
#include "impeller/entity/contents/color_source_contents.h"
diff --git a/impeller/fixtures/golden_paths.h b/impeller/fixtures/golden_paths.h
index fd53f52..95fae57 100644
--- a/impeller/fixtures/golden_paths.h
+++ b/impeller/fixtures/golden_paths.h
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#pragma once
+
#include <vector>
#include "impeller/geometry/path_component.h"
diff --git a/impeller/fixtures/types.h b/impeller/fixtures/types.h
index d877595..aca0e96 100644
--- a/impeller/fixtures/types.h
+++ b/impeller/fixtures/types.h
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#pragma once
+
struct Uniforms {
mat4 model;
mat4 view;
diff --git a/impeller/geometry/geometry_asserts.h b/impeller/geometry/geometry_asserts.h
index d2c63fc..57022b4 100644
--- a/impeller/geometry/geometry_asserts.h
+++ b/impeller/geometry/geometry_asserts.h
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#pragma once
+
#include <array>
#include <iostream>
diff --git a/impeller/renderer/backend/gles/formats_gles.h b/impeller/renderer/backend/gles/formats_gles.h
index fa44297..a4ceb93 100644
--- a/impeller/renderer/backend/gles/formats_gles.h
+++ b/impeller/renderer/backend/gles/formats_gles.h
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#pragma once
+
#include <optional>
#include "flutter/fml/logging.h"
diff --git a/impeller/renderer/backend/metal/vertex_descriptor_mtl.h b/impeller/renderer/backend/metal/vertex_descriptor_mtl.h
index 0fe392b..030d36f 100644
--- a/impeller/renderer/backend/metal/vertex_descriptor_mtl.h
+++ b/impeller/renderer/backend/metal/vertex_descriptor_mtl.h
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#pragma once
+
#include <Metal/Metal.h>
#include <set>
diff --git a/lib/snapshot/snapshot.h b/lib/snapshot/snapshot.h
index 6a9ebfe..9938f9f 100644
--- a/lib/snapshot/snapshot.h
+++ b/lib/snapshot/snapshot.h
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef FLUTTER_LIB_SNAPSHOT_SNAPSHOT_H_
+#define FLUTTER_LIB_SNAPSHOT_SNAPSHOT_H_
+
#include <inttypes.h>
#include <stddef.h>
#include <stdint.h>
@@ -12,3 +15,5 @@
extern const uint8_t kDartIsolateSnapshotData[];
extern const uint8_t kDartIsolateSnapshotInstructions[];
}
+
+#endif // FLUTTER_LIB_SNAPSHOT_SNAPSHOT_H_
diff --git a/lib/ui/painting/image_generator_apng.h b/lib/ui/painting/image_generator_apng.h
index a18ef58..14b357a 100644
--- a/lib/ui/painting/image_generator_apng.h
+++ b/lib/ui/painting/image_generator_apng.h
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef FLUTTER_LIB_UI_PAINTING_IMAGE_GENERATOR_APNG_H_
+#define FLUTTER_LIB_UI_PAINTING_IMAGE_GENERATOR_APNG_H_
+
#include "image_generator.h"
#include "flutter/fml/endianness.h"
@@ -214,3 +217,5 @@
};
} // namespace flutter
+
+#endif // FLUTTER_LIB_UI_PAINTING_IMAGE_GENERATOR_APNG_H_
diff --git a/shell/common/resource_cache_limit_calculator.h b/shell/common/resource_cache_limit_calculator.h
index cb47727..89ef8fd 100644
--- a/shell/common/resource_cache_limit_calculator.h
+++ b/shell/common/resource_cache_limit_calculator.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef FLUTTER_SHELL_COMMON_RESOURCE_CACHE_LIMIT_CALCULATOR_
-#define FLUTTER_SHELL_COMMON_RESOURCE_CACHE_LIMIT_CALCULATOR_
+#ifndef FLUTTER_SHELL_COMMON_RESOURCE_CACHE_LIMIT_CALCULATOR_H_
+#define FLUTTER_SHELL_COMMON_RESOURCE_CACHE_LIMIT_CALCULATOR_H_
#include <cstdint>
#include <unordered_map>
@@ -45,4 +45,4 @@
};
} // namespace flutter
-#endif // FLUTTER_SHELL_COMMON_RESOURCE_CACHE_LIMIT_CALCULATOR_
+#endif // FLUTTER_SHELL_COMMON_RESOURCE_CACHE_LIMIT_CALCULATOR_H_
diff --git a/shell/platform/embedder/test_utils/proc_table_replacement.h b/shell/platform/embedder/test_utils/proc_table_replacement.h
index 711557a..3f2cd88 100644
--- a/shell/platform/embedder/test_utils/proc_table_replacement.h
+++ b/shell/platform/embedder/test_utils/proc_table_replacement.h
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef FLUTTER_SHELL_PLATFORM_COMMON_TESTING_PROC_TABLE_REPLACEMENT_H_
+#define FLUTTER_SHELL_PLATFORM_COMMON_TESTING_PROC_TABLE_REPLACEMENT_H_
+
#include "flutter/shell/platform/embedder/embedder.h"
// Wraps capturing lambas with non-capturing version that can be assigned to
@@ -22,3 +25,5 @@
static auto non_capturing = [](auto... args) { return closure(args...); }; \
return non_capturing; \
})()
+
+#endif // FLUTTER_SHELL_PLATFORM_COMMON_TESTING_PROC_TABLE_REPLACEMENT_H_
diff --git a/shell/platform/fuchsia/dart_runner/embedder/snapshot.h b/shell/platform/fuchsia/dart_runner/embedder/snapshot.h
index 44a8901..edd9c1e 100644
--- a/shell/platform/fuchsia/dart_runner/embedder/snapshot.h
+++ b/shell/platform/fuchsia/dart_runner/embedder/snapshot.h
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef FLUTTER_SHELL_PLATFORM_FUCHSIA_DART_RUNNER_EMBEDDER_SNAPSHOT_H_
+#define FLUTTER_SHELL_PLATFORM_FUCHSIA_DART_RUNNER_EMBEDDER_SNAPSHOT_H_
+
#include <cstdint>
namespace dart_runner {
@@ -10,3 +13,5 @@
extern uint8_t const* const isolate_snapshot_buffer;
} // namespace dart_runner
+
+#endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_DART_RUNNER_EMBEDDER_SNAPSHOT_H_
diff --git a/third_party/accessibility/ax/ax_constants.h b/third_party/accessibility/ax/ax_constants.h
index e9e7388..db93292 100644
--- a/third_party/accessibility/ax/ax_constants.h
+++ b/third_party/accessibility/ax/ax_constants.h
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef UI_ACCESSIBILITY_AX_CONSTANTS_H_
+#define UI_ACCESSIBILITY_AX_CONSTANTS_H_
+
#include <cstdint>
namespace ax {
@@ -19,3 +22,5 @@
} // namespace mojom
} // namespace ax
+
+#endif // UI_ACCESSIBILITY_AX_CONSTANTS_H_
diff --git a/third_party/accessibility/base/win/windows_types.h b/third_party/accessibility/base/win/windows_types.h
index 9b8c421..d1084b8 100644
--- a/third_party/accessibility/base/win/windows_types.h
+++ b/third_party/accessibility/base/win/windows_types.h
@@ -5,8 +5,8 @@
// This file contains defines and typedefs that allow popular Windows types to
// be used without the overhead of including windows.h.
-#ifndef BASE_WIN_WINDOWS_TYPES_H
-#define BASE_WIN_WINDOWS_TYPES_H
+#ifndef BASE_WIN_WINDOWS_TYPES_H_
+#define BASE_WIN_WINDOWS_TYPES_H_
// Needed for function prototypes.
#include <concurrencysal.h>
@@ -273,4 +273,4 @@
#define StartService StartServiceW
#define UpdateResource UpdateResourceW
-#endif // BASE_WIN_WINDOWS_TYPES_H
+#endif // BASE_WIN_WINDOWS_TYPES_H_
diff --git a/third_party/txt/tests/txt_test_utils.h b/third_party/txt/tests/txt_test_utils.h
index 897020f..603c93a 100644
--- a/third_party/txt/tests/txt_test_utils.h
+++ b/third_party/txt/tests/txt_test_utils.h
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+#ifndef LIB_TXT_TESTS_TXT_TEST_UTILS_H_
+#define LIB_TXT_TESTS_TXT_TEST_UTILS_H_
+
#include <string>
namespace txt {
@@ -23,3 +26,5 @@
void SetFontDir(const std::string& dir);
} // namespace txt
+
+#endif // LIB_TXT_TESTS_TXT_TEST_UTILS_H_