Add some accessors to Function/Object/ValueLifetimes.

PiperOrigin-RevId: 442811825
diff --git a/lifetime_annotations/function_lifetimes.h b/lifetime_annotations/function_lifetimes.h
index f3dd592..b28ce21 100644
--- a/lifetime_annotations/function_lifetimes.h
+++ b/lifetime_annotations/function_lifetimes.h
@@ -12,6 +12,7 @@
 #include "lifetime_annotations/lifetime_substitutions.h"
 #include "lifetime_annotations/type_lifetimes.h"
 #include "third_party/llvm/llvm-project/clang/include/clang/AST/Decl.h"
+#include "third_party/llvm/llvm-project/clang/include/clang/AST/DeclCXX.h"
 #include "third_party/llvm/llvm-project/clang/include/clang/AST/Type.h"
 #include "third_party/llvm/llvm-project/llvm/include/llvm/ADT/DenseSet.h"
 #include "third_party/llvm/llvm-project/llvm/include/llvm/ADT/SmallVector.h"
@@ -65,6 +66,9 @@
     return param_lifetimes_[i];
   }
 
+  // Returns the number of function parameters (excluding the implicit `this).
+  const size_t GetNumParams() const { return param_lifetimes_.size(); }
+
   // Lifetimes for the return type.
   const ValueLifetimes& GetReturnLifetimes() const { return return_lifetimes_; }
 
@@ -74,6 +78,9 @@
     return *this_lifetimes_;
   }
 
+  // Returns whether this FunctionLifetimes represents a non-static method.
+  bool IsNonStaticMethod() const { return this_lifetimes_.has_value(); }
+
   // Creates lifetimes for a function with a given decl.
   // Only fails if lifetime_factory fails.
   // Lifetimes will be created first for the object parameter, if any, then for
@@ -88,6 +95,20 @@
 
   // TODO(veluca): add support for pointer-to-member-fn.
 
+  // Creates a copy of this FunctionLifetimes with the same structure, but
+  // fresh, unrelated lifetimes independently of whether the lifetimes where
+  // identical in this FunctionLifetimes.
+  // TODO(veluca): remove this method once FunctionLifetimes keeps track of its
+  // own type, and replace it with an appropriate call to Create().
+  llvm::Expected<FunctionLifetimes> CreateCopy(
+      const LifetimeFactory& factory) const;
+
+  // Returns FunctionLifetimes for a method that this method overrides.
+  // Precondition: `IsNonStaticMethod()` is true,
+  // `method`'s signature is compatible with this FunctionLifetimes except for
+  // the `this` parameter.
+  FunctionLifetimes ForOverriddenMethod(const clang::CXXMethodDecl* method);
+
   // Checks if this FunctionLifetimes represents valid lifetimes for the given
   // Decl.
   bool IsValidForDecl(const clang::FunctionDecl* function);