[clang] [clang] Diagnose [[nodiscard]] return types in Objective-C++ (PR #142541)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 9 05:13:34 PDT 2025
================
@@ -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:
The attribute I believe is returned so we can ge tthe diagnostic message from it but don’t quote me on that.
https://github.com/llvm/llvm-project/pull/142541
More information about the cfe-commits
mailing list