Modernize code in xcode_object.{h,cc}

Use std::make_unique<...> when possible instead of new as it
makes it obvious that the allocated object is properly deleted.

Use default initializer for member variable that are pointers
to ensure that they are always initialized to a sensible value.

Bug: none
Change-Id: I1ab5886d58d4dba61493a7b2d24baebc33905121
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/8100
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: Brett Wilson <brettw@chromium.org>
diff --git a/src/gn/xcode_object.cc b/src/gn/xcode_object.cc
index ac971fc..1b139a8 100644
--- a/src/gn/xcode_object.cc
+++ b/src/gn/xcode_object.cc
@@ -374,7 +374,8 @@
                      const std::string& shell_script,
                      const std::string& config_name,
                      const PBXAttributes& attributes)
-    : configurations_(new XCConfigurationList(config_name, attributes, this)),
+    : configurations_(
+          std::make_unique<XCConfigurationList>(config_name, attributes, this)),
       name_(name) {
   if (!shell_script.empty()) {
     build_phases_.push_back(
@@ -738,7 +739,7 @@
                        const std::string& source_path,
                        const PBXAttributes& attributes)
     : name_(name), config_name_(config_name), target_for_indexing_(nullptr) {
-  main_group_.reset(new PBXGroup);
+  main_group_ = std::make_unique<PBXGroup>();
   main_group_->set_autosorted(false);
 
   sources_ = main_group_->CreateChild<PBXGroup>(source_path, "Source");
@@ -746,7 +747,8 @@
 
   products_ = main_group_->CreateChild<PBXGroup>(std::string(), "Products");
 
-  configurations_.reset(new XCConfigurationList(config_name, attributes, this));
+  configurations_ =
+      std::make_unique<XCConfigurationList>(config_name, attributes, this);
 }
 
 PBXProject::~PBXProject() = default;
diff --git a/src/gn/xcode_object.h b/src/gn/xcode_object.h
index 9458840..aaa494c 100644
--- a/src/gn/xcode_object.h
+++ b/src/gn/xcode_object.h
@@ -151,7 +151,7 @@
   std::unique_ptr<XCConfigurationList> configurations_;
   std::vector<std::unique_ptr<PBXBuildPhase>> build_phases_;
   std::vector<std::unique_ptr<PBXTargetDependency>> dependencies_;
-  PBXSourcesBuildPhase* source_build_phase_;
+  PBXSourcesBuildPhase* source_build_phase_ = nullptr;
   std::string name_;
 
  private:
@@ -191,8 +191,8 @@
   void Print(std::ostream& out, unsigned indent) const override;
 
  private:
-  const PBXFileReference* file_reference_;
-  const PBXSourcesBuildPhase* build_phase_;
+  const PBXFileReference* file_reference_ = nullptr;
+  const PBXSourcesBuildPhase* build_phase_ = nullptr;
   const CompilerFlags compiler_flag_;
 
   DISALLOW_COPY_AND_ASSIGN(PBXBuildFile);
@@ -210,8 +210,8 @@
   void Print(std::ostream& out, unsigned indent) const override;
 
  private:
-  const PBXProject* project_;
-  const PBXTarget* target_;
+  const PBXProject* project_ = nullptr;
+  const PBXTarget* target_ = nullptr;
 
   DISALLOW_COPY_AND_ASSIGN(PBXContainerItemProxy);
 };
@@ -323,7 +323,7 @@
   void Print(std::ostream& out, unsigned indent) const override;
 
  private:
-  const PBXFileReference* product_reference_;
+  const PBXFileReference* product_reference_ = nullptr;
   std::string product_type_;
   std::string product_name_;
 
@@ -381,9 +381,9 @@
   std::string name_;
   std::string config_name_;
 
-  PBXGroup* sources_;
-  PBXGroup* products_;
-  PBXNativeTarget* target_for_indexing_;
+  PBXGroup* sources_ = nullptr;
+  PBXGroup* products_ = nullptr;
+  PBXNativeTarget* target_for_indexing_ = nullptr;
 
   DISALLOW_COPY_AND_ASSIGN(PBXProject);
 };
@@ -446,7 +446,7 @@
   void Print(std::ostream& out, unsigned indent) const override;
 
  private:
-  const PBXTarget* target_;
+  const PBXTarget* target_ = nullptr;
   std::unique_ptr<PBXContainerItemProxy> container_item_proxy_;
 
   DISALLOW_COPY_AND_ASSIGN(PBXTargetDependency);
@@ -490,7 +490,7 @@
 
  private:
   std::vector<std::unique_ptr<XCBuildConfiguration>> configurations_;
-  const PBXObject* owner_reference_;
+  const PBXObject* owner_reference_ = nullptr;
 
   DISALLOW_COPY_AND_ASSIGN(XCConfigurationList);
 };