================
@@ -297,9 +297,25 @@ class LifetimeSafetySemaHelperImpl : public 
LifetimeSafetySemaHelper {
         Scope == WarningScope::CrossTU
             ? diag::warn_lifetime_safety_cross_tu_misplaced_lifetimebound
             : diag::warn_lifetime_safety_intra_tu_misplaced_lifetimebound;
-    S.Diag(Lexer::getLocForEndOfToken(FDecl->getEndLoc(), 0,
-                                      S.getSourceManager(), S.getLangOpts()),
-           DiagID);
+
+    SourceLocation DiagLoc = Lexer::getLocForEndOfToken(
+        FDecl->getEndLoc(), 0, S.getSourceManager(), S.getLangOpts());
+
+    // Scope so diagnostic emits first.
+    {
+      auto DB = S.Diag(DiagLoc, DiagID);
+
+      SourceLocation FixItLoc;
+      if (const TypeSourceInfo *TSI = FDecl->getTypeSourceInfo())
+        FixItLoc =
+            Lexer::getLocForEndOfToken(TSI->getTypeLoc().getEndLoc(), 0,
+                                       S.getSourceManager(), S.getLangOpts());
+      else
+        FixItLoc = DiagLoc;
+
+      if (FixItLoc.isValid() && !FixItLoc.isMacroID())
+        DB << FixItHint::CreateInsertion(FixItLoc, " 
[[clang::lifetimebound]]");
+    }
----------------
NeKon69 wrote:

We probably want the fix it to be placed after the diagnostic is emitted same 
as for the other suggestions.

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