[lifetime_annotations] Add tests for lifetime elision on alias templates.
These tests demonstrate how the current behavior is erroneous.
PiperOrigin-RevId: 660265309
Change-Id: If9200ef0f75ea6027b9602e7483c0571cadf4fc9
diff --git a/bazel/llvm.bzl b/bazel/llvm.bzl
index 6703808..543a5c9 100644
--- a/bazel/llvm.bzl
+++ b/bazel/llvm.bzl
@@ -53,7 +53,7 @@
executable = False,
)
-LLVM_COMMIT_SHA = "77011b00ad5f7f1789e788e85aed1babeb540213"
+LLVM_COMMIT_SHA = "2f28378317827afed81db1c2ce33c187ee6582a0"
def llvm_loader_repository_dependencies():
# This *declares* the dependency, but it won't actually be *downloaded* unless it's used.
diff --git a/lifetime_annotations/lifetime_annotations_test.cc b/lifetime_annotations/lifetime_annotations_test.cc
index 9c18d04..26ce3a2 100644
--- a/lifetime_annotations/lifetime_annotations_test.cc
+++ b/lifetime_annotations/lifetime_annotations_test.cc
@@ -391,6 +391,31 @@
IsOkAndHolds(LifetimesAre({{"f", "(a, b)"}})));
}
+TEST_F(LifetimeAnnotationsTest, LifetimeElision_AliasTemplate) {
+ EXPECT_THAT(GetNamedLifetimeAnnotations(R"(
+ #pragma clang lifetime_elision
+ template <class T>
+ using Alias = T;
+ void f(Alias<int *>);
+ )"),
+ // TODO(b/357835254): Should be "a" rather than "b".
+ IsOkAndHolds(LifetimesAre({{"f", "b"}})));
+}
+
+TEST_F(LifetimeAnnotationsTest, LifetimeElision_AliasTemplate2) {
+ EXPECT_THAT(GetNamedLifetimeAnnotations(R"(
+ #pragma clang lifetime_elision
+ template <class T>
+ using PtrToT = T*;
+ void f(PtrToT<int *>);
+ )"),
+ // TODO(b/357835254): Should be "(a, b)" rather than "(b, c)".
+ // TODO(b/290574080): Also, there's a question of whether we
+ // want elision to "see into" the type alias? If not, this should
+ // simply be "a" rather than "(a, b)".See bug for details.
+ IsOkAndHolds(LifetimesAre({{"f", "(b, c)"}})));
+}
+
TEST_F(LifetimeAnnotationsTest, LifetimeElision_FunctionAlias) {
EXPECT_THAT(GetNamedLifetimeAnnotations(R"_(
#pragma clang lifetime_elision