From nobody Fri May 17 19:59:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+112363+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+112363+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702370946; cv=none; d=zohomail.com; s=zohoarc; b=nUG+uuekJWfTfZMgks5SesiwGAkSuBE3R2J/XPA7xvVuyV9MkgP7rwmfKUDv9sz5HucKB3c0WIDPRY7a0vIoU6sh11BWW+fJOSNW2qtzCyL6wcoMi+y33Z+k/R9WJhjEkhkseuNzmruth+VNoh0Pe8FIw8FcOug7RNkuMLeQkpU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702370946; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=zQmbqzFI2Qe4q+6GHrtw0QVBqib1ofqkzBi6VLpSKYU=; b=FRzRdmw3lLy5EUIqlzBlS/Eb8awxgjSNNs1wx3QlrMdZVu2q7qzWbvkcYDy8OpEtcWbKknXBm8L4ceDT0dql5+1BpB3MHzEibKMNAHFiLqgezWYmZk8TIubR/w1T5VI527rewHnrOG32tBr+mCqDD1P1Bedw/xH57YmiqCKgOXg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+112363+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1702370946134151.34990102126358; Tue, 12 Dec 2023 00:49:06 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=Hr6sa6HUXVH2TYxax+8YGIMLkGCp7LAZyD6UiPZA8J8=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1702370945; v=1; b=ZlwqHVNCMn6yuJmhnG/x4OlJeQdwjuGaVtnjZOwJnoLeheQ2GDHA3d9wyfbCrnhrsUQPYOQN 63QWBgBT1PvmNOTDypz/FsEaW/I/n1qenwPUhoIcZWidHZQH41pESrnSUOG7bAQPltPGbfzIWdS 9bBerxEWSn+9eodEUSPrzxsY= X-Received: by 127.0.0.2 with SMTP id kMkTYY1788612xu9FgR1BoO4; Tue, 12 Dec 2023 00:49:05 -0800 X-Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by mx.groups.io with SMTP id smtpd.web10.12497.1702370944947756586 for ; Tue, 12 Dec 2023 00:49:05 -0800 X-Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-3333224c7b9so4774255f8f.1 for ; Tue, 12 Dec 2023 00:49:04 -0800 (PST) X-Gm-Message-State: 4WFrrVxuIORwABp0XMoeB1BSx1787277AA= X-Google-Smtp-Source: AGHT+IGe+R5XCqvHidqT+8PhXdgvADhS/bgXOiMLjY/ktosswy/9d2dc4Jlj/iTaJGQMYNfjjQxoDg== X-Received: by 2002:adf:fd0e:0:b0:336:9f9:6e0 with SMTP id e14-20020adffd0e000000b0033609f906e0mr3192562wrr.0.1702370942603; Tue, 12 Dec 2023 00:49:02 -0800 (PST) X-Received: from mikes-OptiPlex-3070.. (82-132-230-99.dab.02.net. [82.132.230.99]) by smtp.gmail.com with ESMTPSA id s3-20020a5d69c3000000b00333320cf08bsm10285942wrw.102.2023.12.12.00.49.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 00:49:02 -0800 (PST) From: "Mike Beaton" To: devel@edk2.groups.io Cc: ardb@google.com, lersek@redhat.com, Mike Beaton Subject: [edk2-devel] [PATCH] DebugLib: Allow -Wunneeded-internal-declaration with clang Date: Tue, 12 Dec 2023 08:48:56 +0000 Message-Id: <20231212084856.118099-1-mjsbeaton@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mjsbeaton@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1702370947595100001 Content-Type: text/plain; charset="utf-8" From: Mike Beaton Provides a variant of the DEBUG macro for clang when MDEPKG_NDEBUG is defin= ed, which uses but discards the contained expression, this means clang can tell that it has optimised away variable usage, therefore we can keep -Wunneeded-internal-declaration (as part of -Wall) to warn about any mistakenly genuinely unused variables. Signed-off-by: Mike Beaton Acked-by: Laszlo Ersek --- BaseTools/Conf/tools_def.template | 2 +- MdePkg/Include/Library/DebugLib.h | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.t= emplate index c34ecfd557..eaccf0b698 100755 --- a/BaseTools/Conf/tools_def.template +++ b/BaseTools/Conf/tools_def.template @@ -1859,7 +1859,7 @@ DEFINE CLANGDWARF_X64_DLINK2_FLAGS =3D -Wl,--d= efsym=3DPECOFF_HEADER_SIZE=3D0x22 DEFINE CLANGDWARF_IA32_TARGET =3D -target i686-pc-linux-gnu DEFINE CLANGDWARF_X64_TARGET =3D -target x86_64-pc-linux-gnu =20 -DEFINE CLANGDWARF_WARNING_OVERRIDES =3D -Wno-parentheses-equality -Wno-= empty-body -Wno-unused-const-variable -Wno-varargs -Wno-unknown-warning-opt= ion -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-unaligned-= access -Wno-unneeded-internal-declaration +DEFINE CLANGDWARF_WARNING_OVERRIDES =3D -Wno-parentheses-equality -Wno-= empty-body -Wno-unused-const-variable -Wno-varargs -Wno-unknown-warning-opt= ion -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-unaligned-= access DEFINE CLANGDWARF_ALL_CC_FLAGS =3D DEF(GCC48_ALL_CC_FLAGS) DEF(CLA= NGDWARF_WARNING_OVERRIDES) -fno-stack-protector -mms-bitfields -Wno-address= -Wno-shift-negative-value -Wno-unknown-pragmas -Wno-incompatible-library-r= edeclaration -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -msoft-float= -mno-implicit-float -ftrap-function=3Dundefined_behavior_has_been_optimiz= ed_away_by_clang -funsigned-char -fno-ms-extensions -Wno-null-dereference =20 ########################### diff --git a/MdePkg/Include/Library/DebugLib.h b/MdePkg/Include/Library/Deb= ugLib.h index f0c9f64487..e2158b1a3d 100644 --- a/MdePkg/Include/Library/DebugLib.h +++ b/MdePkg/Include/Library/DebugLib.h @@ -425,6 +425,16 @@ UnitTestDebugAssert ( _DEBUG (Expression); \ } \ } while (FALSE) +#elif defined (__clang__) +#define DEBUG(Expression) \ + do { \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wunused-value\"") \ + if ((FALSE)) { \ + (VOID) Expression; \ + } \ + _Pragma("GCC diagnostic pop") \ + } while (FALSE) #else #define DEBUG(Expression) #endif --=20 2.39.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112363): https://edk2.groups.io/g/devel/message/112363 Mute This Topic: https://groups.io/mt/103126777/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-