================
@@ -74,29 +90,63 @@ struct IntraSuppressedObj {
 };
 
 IntraSuppressedObj &intra_suppressed(IntraSuppressedObj &obj); // 
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-1]]:{{[0-9]+}}-[[@LINE-1]]:{{[0-9]+}}}:" 
{{\[\[clang::lifetimebound\]\]}}"
+
 IntraSuppressedObj &intra_suppressed(
     IntraSuppressedObj &obj [[clang::lifetimebound]]) { // expected-note 
{{'lifetimebound' attribute appears here on the definition}}
   return obj;
 }
 
 struct View {
   friend View friend_redecl(MyObj &obj); // 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-1]]:{{[0-9]+}}-[[@LINE-1]]:{{[0-9]+}}}:" 
{{\[\[clang::lifetimebound\]\]}}"
 };
 
 // FIXME: This diagnoses an attribute inherited from another redeclaration, 
not one written on the definition. Once we enforce that redeclarations agree on 
lifetimebound, handle this with a dedicated warning and note.
 View friend_redecl(MyObj &obj [[clang::lifetimebound]]); // expected-note 
{{'lifetimebound' attribute appears here on the definition}}
-
 View friend_redecl(MyObj &obj) {
   return View{};
 }
 
 template <typename T>
 // FIXME: Current analysis suggests adding to the primary template 
declaration, which is not ideal, as it will affect all specializations.
 MyObj &spec_func(T &obj); // 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-1]]:{{[0-9]+}}-[[@LINE-1]]:{{[0-9]+}}}:" 
{{\[\[clang::lifetimebound\]\]}}"
 
 template <>
 // FIXME: Attribute is inhetired, diagnostic's wording is not correct.
 MyObj &spec_func<MyObj>(MyObj &obj [[clang::lifetimebound]]); // expected-note 
{{'lifetimebound' attribute appears here on the definition}}
 
 template <>
 MyObj &spec_func<MyObj>(MyObj &obj) { return obj; }
+
+MyObj get_default_obj();
+
+const MyObj &default_arg_param(const MyObj &obj = get_default_obj()); // 
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-1]]:48-[[@LINE-1]]:48}:" 
{{\[\[clang::lifetimebound\]\]}}"
+
+const MyObj &default_arg_param(const MyObj &obj [[clang::lifetimebound]]) { // 
expected-note {{'lifetimebound' attribute appears here on the definition}}
+  return obj;
+}
+
+struct Base {
+  virtual const MyObj& virtual_get(const MyObj& obj) const = 0;
+};
+
+struct Derived : Base {
+  auto virtual_get(const MyObj& obj) const -> const MyObj& override; // 
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-1]]:36-[[@LINE-1]]:36}:" 
{{\[\[clang::lifetimebound\]\]}}"
----------------
usx95 wrote:

Hardcoded numbers does not fail gracefully and are hard to debug and maintain.

There is a slightly inaccurate but still useful way to have the target loc on a 
separate line and validate the fixit appears on that line.

E.g. `auto virtual_get(const MyObj& obj) const -> const MyObj& override;` could 
look like
```cpp
auto virtual_get(const MyObj& 
                              obj // CHECK: ...
                 ) const -> const MyObj& override; 
```
Similar for `default_arg_param`.

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

Reply via email to