Introduce AllFreeLifetimes.

For now, this function is equivalent to iterating over all the non-static
lifetimes in the FunctionLifetimes and storing each visited lifetime in a
DenseSet.  However, this function is meant to behave differently in the
presence of HRTBs.

PiperOrigin-RevId: 440317977
diff --git a/lifetime_annotations/function_lifetimes.h b/lifetime_annotations/function_lifetimes.h
index 074d2c4..f7be923 100644
--- a/lifetime_annotations/function_lifetimes.h
+++ b/lifetime_annotations/function_lifetimes.h
@@ -12,6 +12,7 @@
 #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/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"
 #include "third_party/llvm/llvm-project/llvm/include/llvm/ADT/StringRef.h"
 #include "third_party/llvm/llvm-project/llvm/include/llvm/Support/Error.h"
@@ -105,6 +106,11 @@
   // the `FunctionLifetimes`.
   bool HasAny(const std::function<bool(Lifetime)>& predicate) const;
 
+  // Returns the set of all lifetimes that are either lifetime parameters of
+  // this function, or (if this FunctionLifetimes is a declaration of a method)
+  // of the enclosing class.
+  llvm::DenseSet<Lifetime> AllFreeLifetimes() const;
+
   // Traverses all the lifetimes in the function signature, recursively. The
   // visit is done in post-order on the lifetime tree of this type.
   void Traverse(std::function<void(Lifetime&, Variance)> visitor);