Delete incomplete BuildSettings/Args copy ctors BuildSettings::BuildSettings(const BuildSettings&) omitted over half of its fields (including root_target_label_, root_patterns_, no_stamp_files_, callbacks, and allowlists), and Args::Args(const Args&) omitted build_args_dependency_files_ while copying lock-guarded members without locking. Bind setup.build_settings() by const reference in command_args.cc, initialize TestWithScope::build_settings_ in place, and delete both copy constructors alongside their already-deleted copy assignment operators. Bug: None Test: ninja -C out run_tests Change-Id: I247983472496d6bd29f3e1d717c8ae54c64098cc Reviewed-on: https://gn-review.googlesource.com/c/gn/+/29043 Commit-Queue: Takuto Ikuta <tikuta@google.com> Reviewed-by: David Turner <digit@google.com>
diff --git a/src/gn/args.cc b/src/gn/args.cc index d78d862..7cecdf4 100644 --- a/src/gn/args.cc +++ b/src/gn/args.cc
@@ -99,13 +99,6 @@ Args::Args() = default; -Args::Args(const Args& other) - : overrides_(other.overrides_), - all_overrides_(other.all_overrides_), - declared_arguments_per_toolchain_( - other.declared_arguments_per_toolchain_), - toolchain_overrides_(other.toolchain_overrides_) {} - Args::~Args() = default; void Args::AddArgOverride(const char* name, const Value& value) {
diff --git a/src/gn/args.h b/src/gn/args.h index 07ae332..6ee3aaa 100644 --- a/src/gn/args.h +++ b/src/gn/args.h
@@ -41,7 +41,8 @@ using ValueWithOverrideMap = std::map<std::string_view, ValueWithOverride>; Args(); - Args(const Args& other); + Args(const Args&) = delete; + Args& operator=(const Args&) = delete; ~Args(); // Specifies overrides of the build arguments. These are normally specified @@ -155,8 +156,6 @@ mutable ArgumentsPerToolchain toolchain_overrides_; SourceFileSet build_args_dependency_files_; - - Args& operator=(const Args&) = delete; }; #endif // TOOLS_GN_ARGS_H_
diff --git a/src/gn/build_settings.cc b/src/gn/build_settings.cc index 9869ea3..51a8a0e 100644 --- a/src/gn/build_settings.cc +++ b/src/gn/build_settings.cc
@@ -11,21 +11,6 @@ BuildSettings::BuildSettings() = default; -BuildSettings::BuildSettings(const BuildSettings& other) - : dotfile_name_(other.dotfile_name_), - root_path_(other.root_path_), - root_path_utf8_(other.root_path_utf8_), - secondary_source_path_(other.secondary_source_path_), - python_path_(other.python_path_), - python_args_(other.python_args_), - python_path_is_relative_to_build_dir_( - other.python_path_is_relative_to_build_dir_), - ninja_required_version_(other.ninja_required_version_), - build_config_file_(other.build_config_file_), - arg_file_template_path_(other.arg_file_template_path_), - build_dir_(other.build_dir_), - build_args_(other.build_args_) {} - void BuildSettings::SetRootTargetLabel(const Label& r) { root_target_label_ = r; }
diff --git a/src/gn/build_settings.h b/src/gn/build_settings.h index e27cb83..f9cda86 100644 --- a/src/gn/build_settings.h +++ b/src/gn/build_settings.h
@@ -33,7 +33,8 @@ using PrintCallback = std::function<void(const std::string&)>; BuildSettings(); - BuildSettings(const BuildSettings& other); + BuildSettings(const BuildSettings&) = delete; + BuildSettings& operator=(const BuildSettings&) = delete; // Root target label. const Label& root_target_label() const { return root_target_label_; } @@ -218,8 +219,6 @@ std::make_unique<SourceFileSet>(); std::unique_ptr<std::vector<LabelPattern>> allow_circular_includes_from_allowlist_; - - BuildSettings& operator=(const BuildSettings&) = delete; }; #endif // TOOLS_GN_BUILD_SETTINGS_H_
diff --git a/src/gn/command_args.cc b/src/gn/command_args.cc index 6f4600b..39303e1 100644 --- a/src/gn/command_args.cc +++ b/src/gn/command_args.cc
@@ -353,7 +353,7 @@ // Ensure the file exists. Need to normalize path separators since on // Windows they can come out as forward slashes here, and that confuses some // of the commands. - BuildSettings build_settings = setup.build_settings(); + const BuildSettings& build_settings = setup.build_settings(); base::FilePath arg_file = build_settings.GetFullPath(setup.GetBuildArgFile()) .NormalizePathSeparators();
diff --git a/src/gn/test_with_scope.cc b/src/gn/test_with_scope.cc index 6d93b48..5d76887 100644 --- a/src/gn/test_with_scope.cc +++ b/src/gn/test_with_scope.cc
@@ -12,17 +12,15 @@ namespace { -BuildSettings CreateBuildSettingsForTest() { - BuildSettings build_settings; - build_settings.SetBuildDir(SourceDir("//out/Debug/")); +BuildSettings* InitBuildSettingsForTest(BuildSettings* build_settings) { + build_settings->SetBuildDir(SourceDir("//out/Debug/")); return build_settings; } } // namespace TestWithScope::TestWithScope() - : build_settings_(CreateBuildSettingsForTest()), - settings_(&build_settings_, std::string()), + : settings_(InitBuildSettingsForTest(&build_settings_), std::string()), toolchain_(&settings_, Label(SourceDir("//toolchain/"), "default")), scope_(&settings_), scope_progammatic_provider_(&scope_, true) {