Make the lifetime code not crash on non-type template parameters
PiperOrigin-RevId: 470818155
diff --git a/lifetime_annotations/lifetime_annotations_test.cc b/lifetime_annotations/lifetime_annotations_test.cc
index 1b467db..d634197 100644
--- a/lifetime_annotations/lifetime_annotations_test.cc
+++ b/lifetime_annotations/lifetime_annotations_test.cc
@@ -220,6 +220,16 @@
IsOkAndHolds(LifetimesAre({{"f", "a -> a"}, {"g", "a -> a"}})));
}
+TEST_F(LifetimeAnnotationsTest, LifetimeElision_TemplatesWithConstant) {
+ EXPECT_THAT(GetNamedLifetimeAnnotations(R"(
+ #pragma clang lifetime_elision
+ template <class T, bool B> class vector {};
+ int* f(vector<int *, true>);
+ vector<int*, false> g(int *);
+ )"),
+ IsOkAndHolds(LifetimesAre({{"f", "a -> a"}, {"g", "a -> a"}})));
+}
+
TEST_F(LifetimeAnnotationsTest, LifetimeElision_NestedTemplates) {
EXPECT_THAT(GetNamedLifetimeAnnotations(R"(
#pragma clang lifetime_elision