Add test demonstrating failure to forward static lifetimes through function call
PiperOrigin-RevId: 457964951
diff --git a/lifetime_analysis/test/static_lifetime.cc b/lifetime_analysis/test/static_lifetime.cc
index 8d18583..243020e 100644
--- a/lifetime_analysis/test/static_lifetime.cc
+++ b/lifetime_analysis/test/static_lifetime.cc
@@ -176,6 +176,21 @@
LifetimesAre({{"target", "(static, a), (b, a) -> (b, a)"}}));
}
+TEST_F(LifetimeAnalysisTest, StaticParameterChainedCall) {
+ EXPECT_THAT(GetLifetimes(R"(
+ class S {};
+ void f1(S* s) {
+ static S* s_static = s;
+ }
+ void f2(S* s) {
+ f1(s);
+ }
+ )"),
+ // TODO(b/237517535): The lifetimes deduced for `f2` are incorrect
+ // and should be static.
+ LifetimesAre({{"f1", "static"}, {"f2", "a"}}));
+}
+
TEST_F(LifetimeAnalysisTest, ConstructorStoresThisPointerInStatic) {
EXPECT_THAT(GetLifetimes(R"(
struct S {