================
@@ -272,6 +273,26 @@ QualType ObjCMessageExpr::getCallReturnType(ASTContext
&Ctx) const {
return Ctx.getReferenceQualifiedType(this);
}
+std::pair<const NamedDecl *, const Attr *>
+ObjCMessageExpr::getUnusedResultAttr(ASTContext &Ctx) const {
+ // If the callee is marked nodiscard, return that attribute
+ if (const ObjCMethodDecl *MD = getMethodDecl())
+ if (const auto *A = MD->getAttr<WarnUnusedResultAttr>())
+ return {nullptr, A};
----------------
Sirraide wrote:
For more context, see #112521, but tl;dr all of this is because we want to
issue an unused result diagnostic in two different situations: either because
the *function* is declared `nodiscard` or because the *return type* is declared
`nodiscard`. If *both* are `nodiscard`, then we prefer printing the function as
the cause instead of the type.
https://github.com/llvm/llvm-project/pull/142541
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits