> > A completely different approach, which allows clang to spot that the > > usage has been 'optimised away' and so to not complain (and therefore > > allows us to re-enable the warning in CLANGDWARF as well), is the > > following: > > > > --- a/MdePkg/Include/Library/DebugLib.h > > +++ b/MdePkg/Include/Library/DebugLib.h > > @@ -426,7 +426,10 @@ UnitTestDebugAssert ( > > } \ > > } while (FALSE) > > #else > > -#define DEBUG(Expression) > > +#define DEBUG(Expression) \ > > + if (FALSE) { \ > > + _DEBUG (Expression); \ > > + } > > #endif > > > > /** > > > > But will this not litter the object files with a bunch of format strings > etc?
Yes. Which would be optimized away at link time. (Or rather, I believe so, would need further tests to confirm exactly what is optimized away when.) > It feels like, for CLANGPDB (and maybe CLANGDWARF), the RELEASE target > should not define MDEPKG_NDEBUG, but make sure (instead) that > DebugPrintEnabled() evals to FALSE. If PcdDebugPropertyMask is > fixed-at-build, then DebugPrintEnabled() should be possible to evaluate > at compile time; is that right? (At least for clang?) Yes, that is my understanding of how compile-time Pcds work too - but wouldn't the net result be the same as what I suggested? -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112358): https://edk2.groups.io/g/devel/message/112358 Mute This Topic: https://groups.io/mt/103087794/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-