[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
================
@@ -302,27 +312,38 @@ void Sema::DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID) {
if (const Decl *FD = CE->getCalleeDecl()) {
if (ShouldSuppress)
return;
- if (FD->hasAttr<PureAttr>()) {
+ if (const auto *A = FD->getAttr<PureAttr>()) {
Diag(Loc, diag::warn_unused_call) << R1 << R2 << "pure";
+ if (OffendingDecl && !OffendingDecl->getIdentifier()->getBuiltinID())
----------------
erichkeane wrote:
This situation of an offending decl not being always present is, imo, not really something we should be ok with. As far as skipping on builtins, I don't know if we SHOULD, I would think the note there is still meaningful.
https://github.com/llvm/llvm-project/pull/112289
More information about the cfe-commits
mailing list