From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 40656740040 for ; Tue, 12 Dec 2023 08:49:07 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=eaKCivGLgkQL6/oOvYd44pdNwRIBcmHnHasdNCtRAKg=; 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=mUWlZEcH7ToYdNYFVakyGPHsCVN2A/ijE8R4h35OiZyHhM97N46Yun9xmIi/6gLmMsgs7AP4 BNsfQYwVpWiH+6C08aw06mv/pt2odRwMc9/MIKPIypZBqZT9BZYf2pblUbhLsp2X8cnWoJgRWkI TaxQYlMLhSH0e3nj9i7PSByY= X-Received: by 127.0.0.2 with SMTP id dV67YY7687511xYbTVajzpKv; 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: ZVGQOxbl3U2VZzLMwlEASWyVx7686176AA= 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-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=mUWlZEcH; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io 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 --- 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=0D DEFINE CLANGDWARF_X64_TARGET =3D -target x86_64-pc-linux-gnu= =0D =0D -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=0D +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=0D 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=0D =0D ###########################=0D 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); \=0D } \=0D } while (FALSE)=0D +#elif defined (__clang__)=0D +#define DEBUG(Expression) \=0D + do { \=0D + _Pragma("GCC diagnostic push") \=0D + _Pragma("GCC diagnostic ignored \"-Wunused-value\"") \=0D + if ((FALSE)) { \=0D + (VOID) Expression; \=0D + } \=0D + _Pragma("GCC diagnostic pop") \=0D + } while (FALSE)=0D #else=0D #define DEBUG(Expression)=0D #endif=0D --=20 2.39.2 -=-=-=-=-=-=-=-=-=-=-=- 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/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-