https://github.com/NeKon69 updated 
https://github.com/llvm/llvm-project/pull/201101

>From de0de62c33360385673f71008333f9a2e7ce781b Mon Sep 17 00:00:00 2001
From: NeKon69 <[email protected]>
Date: Tue, 2 Jun 2026 14:48:25 +0300
Subject: [PATCH 1/4] [LifetimeSafety] Warn when function parameter annotated
 with [[clang::lifetimebound]] can not be lifetimbound

---
 .../Analyses/LifetimeSafety/LifetimeSafety.h  |  2 +
 clang/include/clang/Basic/DiagnosticGroups.td | 14 +++-
 .../clang/Basic/DiagnosticSemaKinds.td        |  5 ++
 clang/lib/Analysis/LifetimeSafety/Checker.cpp | 18 +++++
 clang/lib/Sema/SemaLifetimeSafety.h           | 13 +++-
 ...etime-safety-meaningless-lifetimebound.cpp | 76 +++++++++++++++++++
 6 files changed, 124 insertions(+), 4 deletions(-)
 create mode 100644 
clang/test/Sema/warn-lifetime-safety-meaningless-lifetimebound.cpp

diff --git 
a/clang/include/clang/Analysis/Analyses/LifetimeSafety/LifetimeSafety.h 
b/clang/include/clang/Analysis/Analyses/LifetimeSafety/LifetimeSafety.h
index 398cce1395854..d3d9a523c9b19 100644
--- a/clang/include/clang/Analysis/Analyses/LifetimeSafety/LifetimeSafety.h
+++ b/clang/include/clang/Analysis/Analyses/LifetimeSafety/LifetimeSafety.h
@@ -141,6 +141,8 @@ class LifetimeSafetySemaHelper {
                                             const ParmVarDecl *PVDDef,
                                             const ParmVarDecl *PVDDecl) {}
 
+  virtual void reportMeaninglessLifetimebound(const ParmVarDecl *PVD) {}
+
   // Suggests lifetime bound annotations for implicit this.
   virtual void suggestLifetimeboundToImplicitThis(WarningScope Scope,
                                                   const CXXMethodDecl *MD,
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 8031f99419bdc..17374d4aadae3 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -631,6 +631,13 @@ This warning may produce false-positives diagnostics when 
it cannot fully model
   }];
 }
 
+def LifetimeSafetyMeaninglessLifetimebound
+    : DiagGroup<"lifetime-safety-meaningless-lifetimebound"> {
+  code Documentation = [{
+Detects uses of [[clang::lifetimebound]] that have no effect because the 
annotated type cannot carry a lifetime.
+  }];
+}
+
 def LifetimeSafetyCrossTUMisplacedLifetimebound
     : DiagGroup<"lifetime-safety-cross-tu-misplaced-lifetimebound">;
 def LifetimeSafetyIntraTUMisplacedLifetimebound
@@ -686,9 +693,10 @@ Detects misuse of [[clang::noescape]] annotation where the 
parameter escapes (fo
 }
 
 def LifetimeSafetyValidations : DiagGroup<"lifetime-safety-validations",
-                                          [LifetimeSafetyNoescape,
-                                           
LifetimeSafetyLifetimeboundViolation,
-                                           
LifetimeSafetyMisplacedLifetimebound]> {
+                                           [LifetimeSafetyNoescape,
+                                            
LifetimeSafetyLifetimeboundViolation,
+                                            
LifetimeSafetyMeaninglessLifetimebound,
+                                            
LifetimeSafetyMisplacedLifetimebound]> {
   code Documentation = [{
 Verify function implementations adhere to the annotated lifetime contracts 
through lifetime safety
 like verifying [[clang::noescape]] and [[clang::lifetimebound]].
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 077aace321264..c6511a84d82bc 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11034,6 +11034,11 @@ def 
warn_lifetime_safety_cross_tu_misplaced_lifetimebound
       InGroup<LifetimeSafetyCrossTUMisplacedLifetimebound>,
       DefaultIgnore;
 
+def warn_lifetime_safety_meaningless_lifetimebound
+    : Warning<"'lifetimebound' attribute has no effect on parameter of type 
%0">,
+      InGroup<LifetimeSafetyMeaninglessLifetimebound>,
+      DefaultIgnore;
+
 def note_lifetime_safety_used_here : Note<"later used here">;
 def note_lifetime_safety_invalidated_here : Note<"invalidated here">;
 def note_lifetime_safety_destroyed_here : Note<"destroyed here">;
diff --git a/clang/lib/Analysis/LifetimeSafety/Checker.cpp 
b/clang/lib/Analysis/LifetimeSafety/Checker.cpp
index d6d4ec6b5617e..a35069f49f460 100644
--- a/clang/lib/Analysis/LifetimeSafety/Checker.cpp
+++ b/clang/lib/Analysis/LifetimeSafety/Checker.cpp
@@ -104,6 +104,7 @@ class LifetimeChecker {
     reportNoescapeViolations();
     reportLifetimeboundViolations();
     reportMisplacedLifetimebound();
+    reportMeaninglessLifetimebound();
     //  Annotation inference is currently guarded by a frontend flag. In the
     //  future, this might be replaced by a design that differentiates between
     //  explicit and inferred findings with separate warning groups.
@@ -467,6 +468,23 @@ class LifetimeChecker {
     }
   }
 
+  static bool canBeLifetimebound(QualType QT) {
+    if (QT->isReferenceType() || QT->isPointerType())
+      return true;
+    if (isGslOwnerType(QT) || QT->isScalarType())
+      return false;
+    return true;
+  }
+
+  void reportMeaninglessLifetimebound() {
+    for (const auto &PVD : cast<FunctionDecl>(FD)->parameters()) {
+      if (!PVD->hasAttr<LifetimeBoundAttr>())
+        continue;
+      if (!canBeLifetimebound(PVD->getType()))
+        SemaHelper->reportMeaninglessLifetimebound(PVD);
+    }
+  }
+
   void inferAnnotations() {
     for (auto [Target, EscapeTarget] : AnnotationWarningsMap) {
       if (const auto *MD = Target.dyn_cast<const CXXMethodDecl *>()) {
diff --git a/clang/lib/Sema/SemaLifetimeSafety.h 
b/clang/lib/Sema/SemaLifetimeSafety.h
index 6da4953dea56d..6b070b07d36e2 100644
--- a/clang/lib/Sema/SemaLifetimeSafety.h
+++ b/clang/lib/Sema/SemaLifetimeSafety.h
@@ -20,6 +20,7 @@
 #include "clang/Basic/DiagnosticSema.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Sema/Sema.h"
+#include <clang/AST/Attrs.inc>
 #include <string>
 
 namespace clang::lifetimes {
@@ -48,7 +49,8 @@ inline bool IsLifetimeSafetyEnabled(Sema &S, const Decl *D) {
       diag::warn_lifetime_safety_cross_tu_param_suggestion,
       diag::warn_lifetime_safety_intra_tu_param_suggestion,
       diag::warn_lifetime_safety_cross_tu_this_suggestion,
-      diag::warn_lifetime_safety_intra_tu_this_suggestion};
+      diag::warn_lifetime_safety_intra_tu_this_suggestion,
+      diag::warn_lifetime_safety_meaningless_lifetimebound};
   for (unsigned DiagID : DiagIDs)
     if (!Diags.isIgnored(DiagID, D->getBeginLoc()))
       return true;
@@ -343,6 +345,15 @@ class LifetimeSafetySemaHelperImpl : public 
LifetimeSafetySemaHelper {
         << Attr->getRange();
   }
 
+  void reportMeaninglessLifetimebound(const ParmVarDecl *PVD) override {
+    assert(PVD->hasAttr<LifetimeBoundAttr>() &&
+           "Expected parameter to have lifetimebound attribute");
+    const auto *Attr = PVD->getAttr<LifetimeBoundAttr>();
+    S.Diag(Attr->getLocation(),
+           diag::warn_lifetime_safety_meaningless_lifetimebound)
+        << PVD->getType() << Attr->getRange();
+  }
+
   void suggestLifetimeboundToImplicitThis(WarningScope Scope,
                                           const CXXMethodDecl *MD,
                                           const Expr *EscapeExpr) override {
diff --git a/clang/test/Sema/warn-lifetime-safety-meaningless-lifetimebound.cpp 
b/clang/test/Sema/warn-lifetime-safety-meaningless-lifetimebound.cpp
new file mode 100644
index 0000000000000..39345d484aaec
--- /dev/null
+++ b/clang/test/Sema/warn-lifetime-safety-meaningless-lifetimebound.cpp
@@ -0,0 +1,76 @@
+// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety-meaningless-lifetimebound 
-Wno-dangling -verify %s
+
+struct [[gsl::Owner]] Owner {};
+
+struct [[gsl::Pointer()]] View {
+  View();
+  View(const Owner &o [[clang::lifetimebound]]);
+};
+
+struct Plain {};
+
+enum Enum { Enumerator };
+
+struct Mixed {
+  Mixed(const int &i [[clang::lifetimebound]]);
+};
+
+using IntAlias = int;
+
+Owner *owner_value(Owner o [[clang::lifetimebound]]) { // expected-warning 
{{'lifetimebound' attribute has no effect on parameter of type 'Owner'}}
+  return {};
+}
+
+Owner *const_owner_value(const Owner o [[clang::lifetimebound]]) { // 
expected-warning {{'lifetimebound' attribute has no effect on parameter of type 
'const Owner'}}
+  return {};
+}
+
+Owner *owner_ref(Owner &o [[clang::lifetimebound]]) {
+  return &o;
+}
+
+const Owner *const_owner_ref(const Owner &o [[clang::lifetimebound]]) {
+  return &o;
+}
+
+Owner *owner_ptr(Owner *o [[clang::lifetimebound]]) {
+  return o;
+}
+
+int *scalar_ptr(int *p [[clang::lifetimebound]]) {
+  return p;
+}
+
+int *scalar_value(int i [[clang::lifetimebound]]) { // expected-warning 
{{'lifetimebound' attribute has no effect on parameter of type 'int'}}
+  return {};
+}
+
+int *scalar_alias_value(IntAlias i [[clang::lifetimebound]]) { // 
expected-warning {{'lifetimebound' attribute has no effect on parameter of type 
'IntAlias' (aka 'int')}}
+  return {};
+}
+
+int *enum_value(Enum e [[clang::lifetimebound]]) { // expected-warning 
{{'lifetimebound' attribute has no effect on parameter of type 'Enum'}}
+  return {};
+}
+
+View view_value(View v [[clang::lifetimebound]]) {
+  return v;
+}
+
+Plain *plain_value(Plain p [[clang::lifetimebound]]) {
+  return {};
+}
+
+Mixed *mixed_value(Mixed m [[clang::lifetimebound]]) {
+  return {};
+}
+
+template <class T>
+Owner *template_value(T t [[clang::lifetimebound]]) { // expected-warning 
{{'lifetimebound' attribute has no effect on parameter of type 'Owner'}}
+  return {};
+}
+
+void instantiate_template() {
+  Owner o;
+  (void)template_value(o); // expected-note {{in instantiation of function 
template specialization 'template_value<Owner>' requested here}}
+}

>From 15f4bc48b477c575a7f223f8918a51c55a30a30f Mon Sep 17 00:00:00 2001
From: NeKon69 <[email protected]>
Date: Tue, 2 Jun 2026 15:44:12 +0300
Subject: [PATCH 2/4] a few nits

---
 clang/include/clang/Basic/DiagnosticGroups.td | 2 +-
 clang/lib/Analysis/LifetimeSafety/Checker.cpp | 2 +-
 clang/lib/Sema/SemaLifetimeSafety.h           | 1 -
 3 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 17374d4aadae3..58c0f7628b332 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -634,7 +634,7 @@ This warning may produce false-positives diagnostics when 
it cannot fully model
 def LifetimeSafetyMeaninglessLifetimebound
     : DiagGroup<"lifetime-safety-meaningless-lifetimebound"> {
   code Documentation = [{
-Detects uses of [[clang::lifetimebound]] that have no effect because the 
annotated type cannot carry a lifetime.
+Detects uses of [[clang::lifetimebound]] that have no effect because the type 
of the annotated parameter cannot carry a lifetime.
   }];
 }
 
diff --git a/clang/lib/Analysis/LifetimeSafety/Checker.cpp 
b/clang/lib/Analysis/LifetimeSafety/Checker.cpp
index a35069f49f460..da2328e12361a 100644
--- a/clang/lib/Analysis/LifetimeSafety/Checker.cpp
+++ b/clang/lib/Analysis/LifetimeSafety/Checker.cpp
@@ -469,7 +469,7 @@ class LifetimeChecker {
   }
 
   static bool canBeLifetimebound(QualType QT) {
-    if (QT->isReferenceType() || QT->isPointerType())
+    if (QT->isReferenceType() || QT->isAnyPointerType())
       return true;
     if (isGslOwnerType(QT) || QT->isScalarType())
       return false;
diff --git a/clang/lib/Sema/SemaLifetimeSafety.h 
b/clang/lib/Sema/SemaLifetimeSafety.h
index 6b070b07d36e2..9490d8a5f6d6e 100644
--- a/clang/lib/Sema/SemaLifetimeSafety.h
+++ b/clang/lib/Sema/SemaLifetimeSafety.h
@@ -20,7 +20,6 @@
 #include "clang/Basic/DiagnosticSema.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Sema/Sema.h"
-#include <clang/AST/Attrs.inc>
 #include <string>
 
 namespace clang::lifetimes {

>From 2f0aae43c0a4ed8f9a3fcc129e960f717e147f65 Mon Sep 17 00:00:00 2001
From: NeKon69 <[email protected]>
Date: Wed, 3 Jun 2026 17:54:31 +0300
Subject: [PATCH 3/4] apply review suggestions

---
 .../Analyses/LifetimeSafety/LifetimeSafety.h  |  2 +-
 clang/include/clang/Basic/DiagnosticGroups.td | 12 ++++-----
 .../clang/Basic/DiagnosticSemaKinds.td        |  6 ++---
 clang/lib/Analysis/LifetimeSafety/Checker.cpp | 25 ++++++++-----------
 clang/lib/Sema/SemaLifetimeSafety.h           |  6 ++---
 .../Sema/warn-lifetime-analysis-nocfg.cpp     |  4 +--
 .../warn-lifetime-safety-dangling-field.cpp   |  4 +--
 .../Sema/warn-lifetime-safety-dataflow.cpp    |  2 +-
 .../test/Sema/warn-lifetime-safety-fixits.cpp |  4 +--
 ...ime-safety-inapplicable-lifetimebound.cpp} | 10 ++++----
 .../warn-lifetime-safety-lifetimebound.cpp    |  2 +-
 ...afety-misplaced-lifetimebound-cross-tu.cpp |  8 +++---
 ...afety-misplaced-lifetimebound-intra-tu.cpp |  8 +++---
 ...e-safety-misplaced-lifetimebound-macro.cpp |  4 +--
 .../Sema/warn-lifetime-safety-noescape.cpp    |  2 +-
 .../Sema/warn-lifetime-safety-suggestions.cpp |  8 +++---
 clang/test/Sema/warn-lifetime-safety.cpp      |  8 +++---
 17 files changed, 55 insertions(+), 60 deletions(-)
 rename clang/test/Sema/{warn-lifetime-safety-meaningless-lifetimebound.cpp => 
warn-lifetime-safety-inapplicable-lifetimebound.cpp} (76%)

diff --git 
a/clang/include/clang/Analysis/Analyses/LifetimeSafety/LifetimeSafety.h 
b/clang/include/clang/Analysis/Analyses/LifetimeSafety/LifetimeSafety.h
index d3d9a523c9b19..b89e1bfe4b43e 100644
--- a/clang/include/clang/Analysis/Analyses/LifetimeSafety/LifetimeSafety.h
+++ b/clang/include/clang/Analysis/Analyses/LifetimeSafety/LifetimeSafety.h
@@ -141,7 +141,7 @@ class LifetimeSafetySemaHelper {
                                             const ParmVarDecl *PVDDef,
                                             const ParmVarDecl *PVDDecl) {}
 
-  virtual void reportMeaninglessLifetimebound(const ParmVarDecl *PVD) {}
+  virtual void reportInapplicableLifetimebound(const ParmVarDecl *PVD) {}
 
   // Suggests lifetime bound annotations for implicit this.
   virtual void suggestLifetimeboundToImplicitThis(WarningScope Scope,
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 58c0f7628b332..26935587d64a3 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -631,8 +631,8 @@ This warning may produce false-positives diagnostics when 
it cannot fully model
   }];
 }
 
-def LifetimeSafetyMeaninglessLifetimebound
-    : DiagGroup<"lifetime-safety-meaningless-lifetimebound"> {
+def LifetimeSafetyInapplicableLifetimebound
+    : DiagGroup<"lifetime-safety-inapplicable-lifetimebound"> {
   code Documentation = [{
 Detects uses of [[clang::lifetimebound]] that have no effect because the type 
of the annotated parameter cannot carry a lifetime.
   }];
@@ -693,10 +693,10 @@ Detects misuse of [[clang::noescape]] annotation where 
the parameter escapes (fo
 }
 
 def LifetimeSafetyValidations : DiagGroup<"lifetime-safety-validations",
-                                           [LifetimeSafetyNoescape,
-                                            
LifetimeSafetyLifetimeboundViolation,
-                                            
LifetimeSafetyMeaninglessLifetimebound,
-                                            
LifetimeSafetyMisplacedLifetimebound]> {
+                                         [LifetimeSafetyNoescape,
+                                          LifetimeSafetyLifetimeboundViolation,
+                                          
LifetimeSafetyInapplicableLifetimebound,
+                                          
LifetimeSafetyMisplacedLifetimebound]> {
   code Documentation = [{
 Verify function implementations adhere to the annotated lifetime contracts 
through lifetime safety
 like verifying [[clang::noescape]] and [[clang::lifetimebound]].
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index c6511a84d82bc..03bf3b088e9d7 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11034,9 +11034,9 @@ def 
warn_lifetime_safety_cross_tu_misplaced_lifetimebound
       InGroup<LifetimeSafetyCrossTUMisplacedLifetimebound>,
       DefaultIgnore;
 
-def warn_lifetime_safety_meaningless_lifetimebound
-    : Warning<"'lifetimebound' attribute has no effect on parameter of type 
%0">,
-      InGroup<LifetimeSafetyMeaninglessLifetimebound>,
+def warn_lifetime_safety_inapplicable_lifetimebound
+    : Warning<"'lifetimebound' attribute has no effect on parameter of type 
%0. The attribute only applies to reference types, pointer types, and non-owner 
record types">,
+      InGroup<LifetimeSafetyInapplicableLifetimebound>,
       DefaultIgnore;
 
 def note_lifetime_safety_used_here : Note<"later used here">;
diff --git a/clang/lib/Analysis/LifetimeSafety/Checker.cpp 
b/clang/lib/Analysis/LifetimeSafety/Checker.cpp
index da2328e12361a..16340120f99d1 100644
--- a/clang/lib/Analysis/LifetimeSafety/Checker.cpp
+++ b/clang/lib/Analysis/LifetimeSafety/Checker.cpp
@@ -104,7 +104,7 @@ class LifetimeChecker {
     reportNoescapeViolations();
     reportLifetimeboundViolations();
     reportMisplacedLifetimebound();
-    reportMeaninglessLifetimebound();
+    reportInapplicableLifetimebound();
     //  Annotation inference is currently guarded by a frontend flag. In the
     //  future, this might be replaced by a design that differentiates between
     //  explicit and inferred findings with separate warning groups.
@@ -468,21 +468,16 @@ class LifetimeChecker {
     }
   }
 
-  static bool canBeLifetimebound(QualType QT) {
-    if (QT->isReferenceType() || QT->isAnyPointerType())
-      return true;
-    if (isGslOwnerType(QT) || QT->isScalarType())
-      return false;
-    return true;
-  }
+  void reportInapplicableLifetimebound() {
+    const auto *FDef = cast<FunctionDecl>(FD);
+    if (FDef->getTemplatedKind() == FunctionDecl::TK_FunctionTemplate ||
+        FDef->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
+      return;
 
-  void reportMeaninglessLifetimebound() {
-    for (const auto &PVD : cast<FunctionDecl>(FD)->parameters()) {
-      if (!PVD->hasAttr<LifetimeBoundAttr>())
-        continue;
-      if (!canBeLifetimebound(PVD->getType()))
-        SemaHelper->reportMeaninglessLifetimebound(PVD);
-    }
+    for (const auto &PVD : FDef->parameters())
+      if (PVD->hasAttr<LifetimeBoundAttr>() &&
+          !FactMgr.getOriginMgr().hasOrigins(PVD->getType()))
+        SemaHelper->reportInapplicableLifetimebound(PVD);
   }
 
   void inferAnnotations() {
diff --git a/clang/lib/Sema/SemaLifetimeSafety.h 
b/clang/lib/Sema/SemaLifetimeSafety.h
index 9490d8a5f6d6e..462a4ed168e24 100644
--- a/clang/lib/Sema/SemaLifetimeSafety.h
+++ b/clang/lib/Sema/SemaLifetimeSafety.h
@@ -49,7 +49,7 @@ inline bool IsLifetimeSafetyEnabled(Sema &S, const Decl *D) {
       diag::warn_lifetime_safety_intra_tu_param_suggestion,
       diag::warn_lifetime_safety_cross_tu_this_suggestion,
       diag::warn_lifetime_safety_intra_tu_this_suggestion,
-      diag::warn_lifetime_safety_meaningless_lifetimebound};
+      diag::warn_lifetime_safety_inapplicable_lifetimebound};
   for (unsigned DiagID : DiagIDs)
     if (!Diags.isIgnored(DiagID, D->getBeginLoc()))
       return true;
@@ -344,12 +344,12 @@ class LifetimeSafetySemaHelperImpl : public 
LifetimeSafetySemaHelper {
         << Attr->getRange();
   }
 
-  void reportMeaninglessLifetimebound(const ParmVarDecl *PVD) override {
+  void reportInapplicableLifetimebound(const ParmVarDecl *PVD) override {
     assert(PVD->hasAttr<LifetimeBoundAttr>() &&
            "Expected parameter to have lifetimebound attribute");
     const auto *Attr = PVD->getAttr<LifetimeBoundAttr>();
     S.Diag(Attr->getLocation(),
-           diag::warn_lifetime_safety_meaningless_lifetimebound)
+           diag::warn_lifetime_safety_inapplicable_lifetimebound)
         << PVD->getType() << Attr->getRange();
   }
 
diff --git a/clang/test/Sema/warn-lifetime-analysis-nocfg.cpp 
b/clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
index 41b07771c52c1..e2a340401ac87 100644
--- a/clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
+++ b/clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -Wdangling -Wdangling-field 
-Wreturn-stack-address -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety -Wno-dangling -verify=cfg %s
-// RUN: %clang_cc1 -fsyntax-only -flifetime-safety-inference 
-fexperimental-lifetime-safety-tu-analysis -Wlifetime-safety -Wno-dangling 
-verify=cfg,tu %s
+// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety 
-Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling -verify=cfg %s
+// RUN: %clang_cc1 -fsyntax-only -flifetime-safety-inference 
-fexperimental-lifetime-safety-tu-analysis -Wlifetime-safety 
-Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling -verify=cfg,tu %s
 
 #include "Inputs/lifetime-analysis.h"
 
diff --git a/clang/test/Sema/warn-lifetime-safety-dangling-field.cpp 
b/clang/test/Sema/warn-lifetime-safety-dangling-field.cpp
index cb13f51b41355..7aa1cd93a3bcc 100644
--- a/clang/test/Sema/warn-lifetime-safety-dangling-field.cpp
+++ b/clang/test/Sema/warn-lifetime-safety-dangling-field.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety -Wno-dangling -verify %s
-// RUN: %clang_cc1 -fsyntax-only -fexperimental-lifetime-safety-tu-analysis 
-Wlifetime-safety -Wno-dangling -verify=expected,tu %s
+// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety 
-Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fexperimental-lifetime-safety-tu-analysis 
-Wlifetime-safety -Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling 
-verify=expected,tu %s
 
 #include "Inputs/lifetime-analysis.h"
 
diff --git a/clang/test/Sema/warn-lifetime-safety-dataflow.cpp 
b/clang/test/Sema/warn-lifetime-safety-dataflow.cpp
index 2cfec824b0866..f1c64229e1e34 100644
--- a/clang/test/Sema/warn-lifetime-safety-dataflow.cpp
+++ b/clang/test/Sema/warn-lifetime-safety-dataflow.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -mllvm -debug-only=LifetimeFacts -Wlifetime-safety %s 2>&1 
| FileCheck %s
+// RUN: %clang_cc1 -mllvm -debug-only=LifetimeFacts -Wlifetime-safety 
-Wlifetime-safety-inapplicable-lifetimebound %s 2>&1 | FileCheck %s
 // REQUIRES: asserts
 
 struct MyObj {
diff --git a/clang/test/Sema/warn-lifetime-safety-fixits.cpp 
b/clang/test/Sema/warn-lifetime-safety-fixits.cpp
index d9c7e8d3f0519..0b103bfe0863e 100644
--- a/clang/test/Sema/warn-lifetime-safety-fixits.cpp
+++ b/clang/test/Sema/warn-lifetime-safety-fixits.cpp
@@ -1,11 +1,11 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++17 -flifetime-safety-inference \
 // RUN:   -fexperimental-lifetime-safety-tu-analysis \
-// RUN:   -Wlifetime-safety-suggestions -Wno-dangling \
+// RUN:   -Wlifetime-safety-suggestions 
-Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling \
 // RUN:   -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 // RUN: cp %s %t.cpp
 // RUN: %clang_cc1 -std=c++17 -flifetime-safety-inference \
 // RUN:   -fexperimental-lifetime-safety-tu-analysis \
-// RUN:   -Wlifetime-safety-suggestions -Wno-dangling -fixit %t.cpp
+// RUN:   -Wlifetime-safety-suggestions 
-Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling -fixit %t.cpp
 // RUN: %clang_cc1 -fsyntax-only -std=c++17 -flifetime-safety-inference \
 // RUN:   -fexperimental-lifetime-safety-tu-analysis \
 // RUN:   -Werror=lifetime-safety-suggestions -Wno-dangling %t.cpp
diff --git a/clang/test/Sema/warn-lifetime-safety-meaningless-lifetimebound.cpp 
b/clang/test/Sema/warn-lifetime-safety-inapplicable-lifetimebound.cpp
similarity index 76%
rename from clang/test/Sema/warn-lifetime-safety-meaningless-lifetimebound.cpp
rename to clang/test/Sema/warn-lifetime-safety-inapplicable-lifetimebound.cpp
index 39345d484aaec..308487ff65add 100644
--- a/clang/test/Sema/warn-lifetime-safety-meaningless-lifetimebound.cpp
+++ b/clang/test/Sema/warn-lifetime-safety-inapplicable-lifetimebound.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety-meaningless-lifetimebound 
-Wno-dangling -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety-inapplicable-lifetimebound 
-Wno-dangling -verify %s
 
 struct [[gsl::Owner]] Owner {};
 
@@ -57,20 +57,20 @@ View view_value(View v [[clang::lifetimebound]]) {
   return v;
 }
 
-Plain *plain_value(Plain p [[clang::lifetimebound]]) {
+Plain *plain_value(Plain p [[clang::lifetimebound]]) { // expected-warning 
{{'lifetimebound' attribute has no effect on parameter of type 'Plain'}}
   return {};
 }
 
-Mixed *mixed_value(Mixed m [[clang::lifetimebound]]) {
+Mixed *mixed_value(Mixed m [[clang::lifetimebound]]) { // expected-warning 
{{'lifetimebound' attribute has no effect on parameter of type 'Mixed'}}
   return {};
 }
 
 template <class T>
-Owner *template_value(T t [[clang::lifetimebound]]) { // expected-warning 
{{'lifetimebound' attribute has no effect on parameter of type 'Owner'}}
+Owner *template_value(T t [[clang::lifetimebound]]) {
   return {};
 }
 
 void instantiate_template() {
   Owner o;
-  (void)template_value(o); // expected-note {{in instantiation of function 
template specialization 'template_value<Owner>' requested here}}
+  (void)template_value(o);
 }
diff --git a/clang/test/Sema/warn-lifetime-safety-lifetimebound.cpp 
b/clang/test/Sema/warn-lifetime-safety-lifetimebound.cpp
index 5e22677f5269d..8a01e4a18f703 100644
--- a/clang/test/Sema/warn-lifetime-safety-lifetimebound.cpp
+++ b/clang/test/Sema/warn-lifetime-safety-lifetimebound.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety-lifetimebound-violation 
-Wno-dangling -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety-lifetimebound-violation 
-Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling -verify %s
 
 #include "Inputs/lifetime-analysis.h"
 
diff --git 
a/clang/test/Sema/warn-lifetime-safety-misplaced-lifetimebound-cross-tu.cpp 
b/clang/test/Sema/warn-lifetime-safety-misplaced-lifetimebound-cross-tu.cpp
index 1705da44bdf19..ecec7582d30d8 100644
--- a/clang/test/Sema/warn-lifetime-safety-misplaced-lifetimebound-cross-tu.cpp
+++ b/clang/test/Sema/warn-lifetime-safety-misplaced-lifetimebound-cross-tu.cpp
@@ -1,9 +1,9 @@
 // RUN: rm -rf %t
 // RUN: split-file %s %t
-// RUN: %clang_cc1 -fsyntax-only 
-Wlifetime-safety-cross-tu-misplaced-lifetimebound -Wno-dangling -I%t -verify 
%t/cross.cpp
-// RUN: %clang_cc1 -fsyntax-only 
-Wlifetime-safety-cross-tu-misplaced-lifetimebound -Wno-dangling -I%t 
-fdiagnostics-parseable-fixits %t/cross.cpp 2>&1 | FileCheck %s
-// RUN: %clang_cc1 -Wlifetime-safety-cross-tu-misplaced-lifetimebound 
-Wno-dangling -I%t -fixit %t/cross.cpp
-// RUN: %clang_cc1 -fsyntax-only 
-Wlifetime-safety-cross-tu-misplaced-lifetimebound -Wno-dangling -I%t -Werror 
%t/cross.cpp
+// RUN: %clang_cc1 -fsyntax-only 
-Wlifetime-safety-cross-tu-misplaced-lifetimebound 
-Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling -I%t -verify 
%t/cross.cpp
+// RUN: %clang_cc1 -fsyntax-only 
-Wlifetime-safety-cross-tu-misplaced-lifetimebound 
-Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling -I%t 
-fdiagnostics-parseable-fixits %t/cross.cpp 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -Wlifetime-safety-cross-tu-misplaced-lifetimebound 
-Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling -I%t -fixit 
%t/cross.cpp
+// RUN: %clang_cc1 -fsyntax-only 
-Wlifetime-safety-cross-tu-misplaced-lifetimebound 
-Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling -I%t -Werror 
%t/cross.cpp
 
 //--- cross.h
 struct HeaderObj {
diff --git 
a/clang/test/Sema/warn-lifetime-safety-misplaced-lifetimebound-intra-tu.cpp 
b/clang/test/Sema/warn-lifetime-safety-misplaced-lifetimebound-intra-tu.cpp
index e92d5c7a2d90a..8e33d41aa614f 100644
--- a/clang/test/Sema/warn-lifetime-safety-misplaced-lifetimebound-intra-tu.cpp
+++ b/clang/test/Sema/warn-lifetime-safety-misplaced-lifetimebound-intra-tu.cpp
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -fsyntax-only 
-Wlifetime-safety-intra-tu-misplaced-lifetimebound -Wno-dangling -verify %s
-// RUN: %clang_cc1 -fsyntax-only 
-Wlifetime-safety-intra-tu-misplaced-lifetimebound -Wno-dangling 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -fsyntax-only 
-Wlifetime-safety-intra-tu-misplaced-lifetimebound 
-Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling -verify %s
+// RUN: %clang_cc1 -fsyntax-only 
-Wlifetime-safety-intra-tu-misplaced-lifetimebound 
-Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 // RUN: cp %s %t.intra.cpp
-// RUN: %clang_cc1 -Wlifetime-safety-intra-tu-misplaced-lifetimebound 
-Wno-dangling -fixit %t.intra.cpp
-// RUN: %clang_cc1 -fsyntax-only 
-Wlifetime-safety-intra-tu-misplaced-lifetimebound -Wno-dangling -Werror 
%t.intra.cpp
+// RUN: %clang_cc1 -Wlifetime-safety-intra-tu-misplaced-lifetimebound 
-Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling -fixit %t.intra.cpp
+// RUN: %clang_cc1 -fsyntax-only 
-Wlifetime-safety-intra-tu-misplaced-lifetimebound 
-Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling -Werror %t.intra.cpp
 
 struct MyObj {
   ~MyObj() {}
diff --git 
a/clang/test/Sema/warn-lifetime-safety-misplaced-lifetimebound-macro.cpp 
b/clang/test/Sema/warn-lifetime-safety-misplaced-lifetimebound-macro.cpp
index ccda9aed01832..80e429614a19a 100644
--- a/clang/test/Sema/warn-lifetime-safety-misplaced-lifetimebound-macro.cpp
+++ b/clang/test/Sema/warn-lifetime-safety-misplaced-lifetimebound-macro.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only 
-Wlifetime-safety-intra-tu-misplaced-lifetimebound -Wno-dangling -verify %s
-// RUN: %clang_cc1 -fsyntax-only 
-Wlifetime-safety-intra-tu-misplaced-lifetimebound -Wno-dangling 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -fsyntax-only 
-Wlifetime-safety-intra-tu-misplaced-lifetimebound 
-Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling -verify %s
+// RUN: %clang_cc1 -fsyntax-only 
-Wlifetime-safety-intra-tu-misplaced-lifetimebound 
-Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 // CHECK-NOT: fix-it:
 
diff --git a/clang/test/Sema/warn-lifetime-safety-noescape.cpp 
b/clang/test/Sema/warn-lifetime-safety-noescape.cpp
index 4bb57e6b9df95..1735e878bd919 100644
--- a/clang/test/Sema/warn-lifetime-safety-noescape.cpp
+++ b/clang/test/Sema/warn-lifetime-safety-noescape.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -flifetime-safety-inference 
-Wlifetime-safety-noescape -verify %s
+// RUN: %clang_cc1 -fsyntax-only -flifetime-safety-inference 
-Wlifetime-safety-noescape -Wlifetime-safety-inapplicable-lifetimebound -verify 
%s
 
 #include "Inputs/lifetime-analysis.h"
 
diff --git a/clang/test/Sema/warn-lifetime-safety-suggestions.cpp 
b/clang/test/Sema/warn-lifetime-safety-suggestions.cpp
index f5a3cf89e4c8d..05d366227a532 100644
--- a/clang/test/Sema/warn-lifetime-safety-suggestions.cpp
+++ b/clang/test/Sema/warn-lifetime-safety-suggestions.cpp
@@ -1,9 +1,9 @@
 // RUN: rm -rf %t
 // RUN: split-file %s %t
-// RUN: %clang_cc1 -fsyntax-only -flifetime-safety-inference 
-fexperimental-lifetime-safety-tu-analysis -Wlifetime-safety-suggestions 
-Wlifetime-safety -Wno-dangling -I%t -I%S -verify %t/test_source.cpp
-// RUN: %clang_cc1 -fsyntax-only -std=c++23 -flifetime-safety-inference 
-fexperimental-lifetime-safety-tu-analysis -Wlifetime-safety-suggestions 
-Wlifetime-safety -Wno-dangling -I%t -I%S -verify %t/test_source.cpp
-// RUN: %clang_cc1 -flifetime-safety-inference 
-fexperimental-lifetime-safety-tu-analysis -Wlifetime-safety-suggestions 
-Wlifetime-safety -Wno-dangling -I%t -I%S -fixit %t/test_source.cpp
-// RUN: %clang_cc1 -fsyntax-only -flifetime-safety-inference 
-fexperimental-lifetime-safety-tu-analysis -Wlifetime-safety-suggestions 
-Wno-dangling -I%t -I%S -Werror=lifetime-safety-suggestions %t/test_source.cpp
+// RUN: %clang_cc1 -fsyntax-only -flifetime-safety-inference 
-fexperimental-lifetime-safety-tu-analysis -Wlifetime-safety-suggestions 
-Wlifetime-safety -Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling 
-I%t -I%S -verify %t/test_source.cpp
+// RUN: %clang_cc1 -fsyntax-only -std=c++23 -flifetime-safety-inference 
-fexperimental-lifetime-safety-tu-analysis -Wlifetime-safety-suggestions 
-Wlifetime-safety -Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling 
-I%t -I%S -verify %t/test_source.cpp
+// RUN: %clang_cc1 -flifetime-safety-inference 
-fexperimental-lifetime-safety-tu-analysis -Wlifetime-safety-suggestions 
-Wlifetime-safety -Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling 
-I%t -I%S -fixit %t/test_source.cpp
+// RUN: %clang_cc1 -fsyntax-only -flifetime-safety-inference 
-fexperimental-lifetime-safety-tu-analysis -Wlifetime-safety-suggestions 
-Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling -I%t -I%S 
-Werror=lifetime-safety-suggestions %t/test_source.cpp
 
 View definition_before_header(View a);
 
diff --git a/clang/test/Sema/warn-lifetime-safety.cpp 
b/clang/test/Sema/warn-lifetime-safety.cpp
index 5aaa389b63ccd..d118db16e8f4a 100644
--- a/clang/test/Sema/warn-lifetime-safety.cpp
+++ b/clang/test/Sema/warn-lifetime-safety.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety -Wno-dangling 
-verify=expected,function %s
-// RUN: %clang_cc1 -fsyntax-only -flifetime-safety-inference 
-fexperimental-lifetime-safety-tu-analysis -Wlifetime-safety -Wno-dangling 
-verify=expected,tu %s
-// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety -Wno-dangling 
-fcxx-exceptions -verify=expected,function %s
+// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety 
-Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling 
-verify=expected,function %s
+// RUN: %clang_cc1 -fsyntax-only -flifetime-safety-inference 
-fexperimental-lifetime-safety-tu-analysis -Wlifetime-safety 
-Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling -verify=expected,tu 
%s
+// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety 
-Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling -fcxx-exceptions 
-verify=expected,function %s
 
 #include "Inputs/lifetime-analysis.h"
 
@@ -3594,4 +3594,4 @@ void capturing_multiple_locals() {
         setCaptureBy(v, local2);    // expected-warning{{local variable 
'local2' does not live long enough}}
     }                               // expected-note 2 {{destroyed here}} 
     (void)v;                        // expected-note 2 {{later used here}}
-}
\ No newline at end of file
+}

>From 87c42cdea682c796e2b83e4900fc669b249f6ccd Mon Sep 17 00:00:00 2001
From: NeKon69 <[email protected]>
Date: Wed, 3 Jun 2026 18:06:06 +0300
Subject: [PATCH 4/4] revert unrelated change

---
 clang/test/Sema/warn-lifetime-safety.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/Sema/warn-lifetime-safety.cpp 
b/clang/test/Sema/warn-lifetime-safety.cpp
index d118db16e8f4a..db1291975fe74 100644
--- a/clang/test/Sema/warn-lifetime-safety.cpp
+++ b/clang/test/Sema/warn-lifetime-safety.cpp
@@ -3594,4 +3594,4 @@ void capturing_multiple_locals() {
         setCaptureBy(v, local2);    // expected-warning{{local variable 
'local2' does not live long enough}}
     }                               // expected-note 2 {{destroyed here}} 
     (void)v;                        // expected-note 2 {{later used here}}
-}
+}
\ No newline at end of file

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to