Evaluate argument of (DYNAMIC_)SECTION in static-analysis mode

This commit is contained in:
Martin Jeřábek 2024-02-19 18:17:42 +01:00 committed by Martin Hořeňovský
parent c3fd4eb17e
commit da303cc668
1 changed files with 7 additions and 3 deletions

View File

@ -69,7 +69,9 @@ namespace Catch {
namespace Detail { namespace Detail {
// Intentionally without linkage, as it should only be used as a dummy // Intentionally without linkage, as it should only be used as a dummy
// symbol for static analysis. // symbol for static analysis.
int GetNewSectionHint(); // The arguments are used as a dummy for checking warnings in the passed
// expressions.
int GetNewSectionHint( StringRef, const char* const = nullptr );
} // namespace Detail } // namespace Detail
} // namespace Catch } // namespace Catch
@ -80,7 +82,8 @@ namespace Catch {
CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \
if ( [[maybe_unused]] const int catchInternalPreviousSectionHint = \ if ( [[maybe_unused]] const int catchInternalPreviousSectionHint = \
catchInternalSectionHint, \ catchInternalSectionHint, \
catchInternalSectionHint = Catch::Detail::GetNewSectionHint(); \ catchInternalSectionHint = \
Catch::Detail::GetNewSectionHint(__VA_ARGS__); \
catchInternalPreviousSectionHint == __LINE__ ) \ catchInternalPreviousSectionHint == __LINE__ ) \
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
@ -90,7 +93,8 @@ namespace Catch {
CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \
if ( [[maybe_unused]] const int catchInternalPreviousSectionHint = \ if ( [[maybe_unused]] const int catchInternalPreviousSectionHint = \
catchInternalSectionHint, \ catchInternalSectionHint, \
catchInternalSectionHint = Catch::Detail::GetNewSectionHint(); \ catchInternalSectionHint = Catch::Detail::GetNewSectionHint( \
( Catch::ReusableStringStream() << __VA_ARGS__ ).str()); \
catchInternalPreviousSectionHint == __LINE__ ) \ catchInternalPreviousSectionHint == __LINE__ ) \
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION