[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 08:22:57 PDT 2024


================
@@ -290,9 +297,12 @@ void Sema::DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID) {
     if (E->getType()->isVoidType())
       return;
 
-    if (DiagnoseNoDiscard(*this, cast_or_null<WarnUnusedResultAttr>(
-                                     CE->getUnusedResultAttr(Context)),
-                          Loc, R1, R2, /*isCtor=*/false))
+    const NamedDecl *OffendingDecl;
+    const Attr *A;
+    std::tie(OffendingDecl, A) = CE->getUnusedResultAttr(Context);
----------------
erichkeane wrote:

```suggestion
    auto &[OffendingDecl, A] = CE->getUnusedResultAttr(Context);
```

Then you can do away with the declarations.

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


More information about the cfe-commits mailing list