[clang] [LifetimeSafety] Add fix-it for misplaced lifetimebound attributes (PR #199149)
David Meng via cfe-commits
cfe-commits at lists.llvm.org
Wed May 27 10:52:14 PDT 2026
================
@@ -27,11 +27,10 @@ struct S {
);
const MyObj &both(const MyObj & // expected-warning {{'lifetimebound' attribute on this definition is not visible to callers before the definition; add it to the declaration instead}}
- // CHECK: fix-it:"{{.*}}":{[[@LINE+4]]:{{[0-9]+}}-[[@LINE+4]]:{{[0-9]+}}}:" {{\[\[clang::lifetimebound\]\]}}"
- obj,
- // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:{{[0-9]+}}-[[@LINE-1]]:{{[0-9]+}}}:" {{\[\[clang::lifetimebound\]\]}}"
+ obj, // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE]]:{{[0-9]+}}-[[@LINE]]:{{[0-9]+}}}:" {{\[\[clang::lifetimebound\]\]}}"
bool
); // expected-warning {{'lifetimebound' attribute on this definition is not visible to callers before the definition; add it to the declaration instead}}
+ // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-1]]:{{[0-9]+}}-[[@LINE-1]]:{{[0-9]+}}}:" {{\[\[clang::lifetimebound\]\]}}"
----------------
davidmenggx wrote:
I don't believe this works because `@LINE` works on the absolute line number so the continuation `\` doesn't apply
At least this is what I see when testing locally
Source ? https://llvm.org/docs/CommandGuide/FileCheck.html#filecheck-pseudo-numeric-variables
https://github.com/llvm/llvm-project/pull/199149
More information about the cfe-commits
mailing list