================
@@ -302,27 +307,43 @@ void Sema::DiagnoseUnusedExprResult(const Stmt *S, 
unsigned DiagID) {
     if (const Decl *FD = CE->getCalleeDecl()) {
       if (ShouldSuppress)
         return;
-      if (FD->hasAttr<PureAttr>()) {
-        Diag(Loc, diag::warn_unused_call) << R1 << R2 << "pure";
-        return;
-      }
-      if (FD->hasAttr<ConstAttr>()) {
-        Diag(Loc, diag::warn_unused_call) << R1 << R2 << "const";
+
+      const InheritableAttr *A = nullptr;
+      if (const auto *PA = FD->getAttr<PureAttr>())
+        A = PA;
+      else if (const auto *CA = FD->getAttr<ConstAttr>())
+        A = CA;
+
+      if (A) {
+        StringRef type = (isa<PureAttr>(A) ? "pure" : "const");
+        Diag(Loc, diag::warn_unused_call) << R1 << R2 << type;
+        if (const auto *ND = dyn_cast<NamedDecl>(OffendingDecl)) {
+          if (!ND->getIdentifier()->getBuiltinID())
----------------
erichkeane wrote:

I still didn't get the justification for skipping if this is a builtin?  It 
seems sensible to do so, even if the source location is a builtin.

https://github.com/llvm/llvm-project/pull/112289
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to