[clang] [clang] Generate note on declaration for nodiscard-related attributes (PR #112289)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 15 09:51:08 PDT 2024


================
@@ -204,23 +205,26 @@ static bool DiagnoseUnusedComparison(Sema &S, const Expr *E) {
   return true;
 }
 
-static bool DiagnoseNoDiscard(Sema &S, const WarnUnusedResultAttr *A,
-                              SourceLocation Loc, SourceRange R1,
-                              SourceRange R2, bool IsCtor) {
+static bool DiagnoseNoDiscard(Sema &S, const Decl *OffendingDecl,
+                              const WarnUnusedResultAttr *A, SourceLocation Loc,
+                              SourceRange R1, SourceRange R2, bool IsCtor) {
   if (!A)
     return false;
   StringRef Msg = A->getMessage();
 
   if (Msg.empty()) {
     if (IsCtor)
-      return S.Diag(Loc, diag::warn_unused_constructor) << A << R1 << R2;
-    return S.Diag(Loc, diag::warn_unused_result) << A << R1 << R2;
-  }
+      S.Diag(Loc, diag::warn_unused_constructor) << A << R1 << R2;
+    else
+      S.Diag(Loc, diag::warn_unused_result) << A << R1 << R2;
+  } else if (IsCtor)
----------------
erichkeane wrote:

This needs curleys on it per coding standard (as the previous thing has them).  

https://github.com/llvm/llvm-project/pull/112289


More information about the cfe-commits mailing list