[clang] [clang] Improve diagnostic on [[nodiscard]] attribute (PR #112521)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 15 06:19:11 PST 2024


================
@@ -1616,22 +1616,24 @@ QualType CallExpr::getCallReturnType(const ASTContext &Ctx) const {
   return FnType->getReturnType();
 }
 
-const Attr *CallExpr::getUnusedResultAttr(const ASTContext &Ctx) const {
+std::pair<const NamedDecl *, const Attr *>
+CallExpr::getUnusedResultAttr(const ASTContext &Ctx) const {
+  // If the callee is marked nodiscard, return that attribute
+  const Decl *D = getCalleeDecl();
----------------
erichkeane wrote:

We should document this inversion in the release notes.This is more than just changing the name, it is preferring the `callee` decl here instead of the return type.  this is at least notable.

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


More information about the cfe-commits mailing list