Turn this_object_ and return_object_ into pointers.

PiperOrigin-RevId: 458413758
diff --git a/lifetime_analysis/object_repository.cc b/lifetime_analysis/object_repository.cc
index 5f3f063..04c81df 100644
--- a/lifetime_analysis/object_repository.cc
+++ b/lifetime_analysis/object_repository.cc
@@ -48,7 +48,7 @@
   bool VisitReturnStmt(clang::ReturnStmt* stmt) {
     const clang::Expr* expr = stmt->getRetValue();
     if (IsInitExprInitializingARecordObject(expr)) {
-      PropagateInitializedObject(expr, object_repository_.return_object_);
+      PropagateInitializedObject(expr, *object_repository_.return_object_);
     }
     return true;
   }
@@ -456,19 +456,18 @@
   if (definition) func = definition;
 
   // For the return value, we only need to create field objects.
-  return_object_ =
-      *CreateObject(Lifetime::CreateLocal(), func->getReturnType());
+  return_object_ = CreateObject(Lifetime::CreateLocal(), func->getReturnType());
   CreateObjects(
-      return_object_, func->getReturnType(),
+      *return_object_, func->getReturnType(),
       [](const clang::Expr*) { return Lifetime::CreateLocal(); },
       /*transitive=*/false);
 
   if (method_decl) {
     if (!method_decl->isStatic()) {
-      this_object_ = *CreateObject(Lifetime::CreateVariable(),
-                                   method_decl->getThisObjectType());
+      this_object_ = CreateObject(Lifetime::CreateVariable(),
+                                  method_decl->getThisObjectType());
       CreateObjects(
-          *this_object_, method_decl->getThisObjectType(),
+          **this_object_, method_decl->getThisObjectType(),
           [](const clang::Expr*) { return Lifetime::CreateVariable(); },
           /*transitive=*/true);
     }
@@ -486,7 +485,7 @@
   llvm::raw_string_ostream os(result);
 
   if (this_object_) {
-    os << "This " << this_object_->DebugString() << "\n";
+    os << "This " << (*this_object_)->DebugString() << "\n";
   }
   for (const auto& [decl, object] : object_repository_) {
     os << decl->getDeclKindName() << " " << decl << " (";
@@ -509,7 +508,7 @@
     os << "' on " << field.first.Type().getAsString()
        << " object: " << object.DebugString() << "\n";
   }
-  os << "Return " << return_object_.DebugString() << "\n";
+  os << "Return " << return_object_->DebugString() << "\n";
   os.flush();
   return result;
 }
diff --git a/lifetime_analysis/object_repository.h b/lifetime_analysis/object_repository.h
index 431fada..c4638d7 100644
--- a/lifetime_analysis/object_repository.h
+++ b/lifetime_analysis/object_repository.h
@@ -143,7 +143,13 @@
   ObjectValueType GetObjectValueType(Object object) const;
 
   // Returns the object that represents `*this`, if in a member function.
-  std::optional<Object> GetThisObject() const { return this_object_; }
+  std::optional<Object> GetThisObject() const {
+    if (this_object_) {
+      return **this_object_;
+    } else {
+      return std::nullopt;
+    }
+  }
 
   // Returns the `Object` associated with the return value of the function.
   // Unlike the `Object`s for variables, the "return value object" is a fiction
@@ -151,7 +157,7 @@
   // the return value, and it will not, in general, be possible to take the
   // address of the return value object. It's still a useful fiction, however,
   // because it allows us to treat return values the same way as other values.
-  Object GetReturnObject() const { return return_object_; }
+  Object GetReturnObject() const { return *return_object_; }
 
   // Returns the object associated with a given field in the struct
   // represented by `struct_object`.
@@ -227,8 +233,8 @@
   // case it is only found in this map.
   llvm::DenseMap<const clang::Expr*, Object> initialized_objects_;
 
-  std::optional<Object> this_object_;
-  Object return_object_;
+  std::optional<const Object*> this_object_;
+  const Object* return_object_;
 
   llvm::DenseMap<Object, ObjectValueType> object_value_types_;