[clang] [LifetimeSafety] Add fixit verification with FileCheck (PR #180488)
Baranov Victor via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 9 05:22:15 PST 2026
================
@@ -0,0 +1,139 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -flifetime-safety-inference \
+// RUN: -fexperimental-lifetime-safety-tu-analysis \
+// RUN: -Wlifetime-safety-suggestions -Wno-dangling \
+// RUN: -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+struct View;
+
+struct [[gsl::Owner]] MyObj {
+ int id;
+ MyObj(int i) : id(i) {}
+ MyObj() {}
+ ~MyObj() {}
+ MyObj operator+(MyObj);
+ View getView() const [[clang::lifetimebound]];
+};
+
+struct [[gsl::Pointer()]] View {
+ View(const MyObj &);
+ View();
+ void use() const;
+};
+
+View return_view(View a) {
+ // CHECK: :[[@LINE-1]]:18: warning: parameter in intra-TU function should be marked {{\[\[}}clang::lifetimebound]] [-Wlifetime-safety-intra-tu-suggestions]
----------------
vbvictor wrote:
> I think it might be sufficient to only match on the full diagnostics once and just match a prefix for the rest
Yeah, I removed long lines but fixes remained as is.
https://github.com/llvm/llvm-project/pull/180488
More information about the cfe-commits
mailing list