diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-05-10 11:53:19 +0100 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-05-10 18:02:05 +0200 |
commit | eb8f353f8b201dd2a1e24b03c7cc496b5ed32f22 (patch) | |
tree | 4b5894207166e22e6e08d381a612337805b3cff4 /external | |
parent | c24db71bc56c5d81a6e8fb744442b6d6358992d0 (diff) |
help msvc -analyzer out wrt CPPUNIT_ASSERT
so it can code following the CPPUNIT_ASSERT doesn't need
to check what condition might have failed in the assert
Change-Id: Ife7e5e54b17a8316425222d2a0efd694c9467089
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167480
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'external')
-rw-r--r-- | external/cppunit/UnpackedTarball_cppunit.mk | 1 | ||||
-rw-r--r-- | external/cppunit/help-msvc-analyzer.patch | 60 |
2 files changed, 61 insertions, 0 deletions
diff --git a/external/cppunit/UnpackedTarball_cppunit.mk b/external/cppunit/UnpackedTarball_cppunit.mk index 7efe5c4f92bf..207c7e76f283 100644 --- a/external/cppunit/UnpackedTarball_cppunit.mk +++ b/external/cppunit/UnpackedTarball_cppunit.mk @@ -37,6 +37,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,cppunit,\ external/cppunit/sprintf.patch.0 \ external/cppunit/clang.patch.0 \ external/cppunit/0001-cid-1546460-COPY_INSTEAD_OF_MOVE.patch.1 \ + external/cppunit/help-msvc-analyzer.patch \ )) ifeq ($(DISABLE_DYNLOADING),TRUE) $(eval $(call gb_UnpackedTarball_add_patches,cppunit,\ diff --git a/external/cppunit/help-msvc-analyzer.patch b/external/cppunit/help-msvc-analyzer.patch new file mode 100644 index 000000000000..26d7fe6e89e6 --- /dev/null +++ b/external/cppunit/help-msvc-analyzer.patch @@ -0,0 +1,60 @@ +--- misc/cppunit-1.14.0/include/cppunit/TestAssert.h ++++ misc/build/cppunit-1.14.0/include/cppunit/TestAssert.h +@@ -261,6 +261,13 @@ + message ); + } + } ++ ++#ifdef _MSC_VER ++# define ANALYSIS_ASSUME(condition) __analysis_assume(condition) ++#else ++# define ANALYSIS_ASSUME(condition) static_cast<void>(0) ++#endif ++ + /* A set of macros which allow us to get the line number + * and file name at the point of an error. + * Just goes to show that preprocessors do have some +@@ -271,15 +278,17 @@ + * \ingroup Assertions + */ + #define CPPUNIT_ASSERT(condition) \ +- ( CPPUNIT_NS::Asserter::failIf( !(condition), \ ++ do { ( CPPUNIT_NS::Asserter::failIf( !(condition), \ + CPPUNIT_NS::Message( "assertion failed", \ + "Expression: " #condition), \ +- CPPUNIT_SOURCELINE() ) ) ++ CPPUNIT_SOURCELINE() ) ); \ ++ ANALYSIS_ASSUME(condition); } while(0) + #else + #define CPPUNIT_ASSERT(condition) \ +- ( CPPUNIT_NS::Asserter::failIf( !(condition), \ ++ do { ( CPPUNIT_NS::Asserter::failIf( !(condition), \ + CPPUNIT_NS::Message( "assertion failed" ), \ +- CPPUNIT_SOURCELINE() ) ) ++ CPPUNIT_SOURCELINE() ) ); \ ++ ANALYSIS_ASSUME(condition); } while(0) + #endif + + /** Assertion with a user specified message. +@@ -289,13 +298,14 @@ + * \param condition If this condition evaluates to \c false then the + * test failed. + */ +-#define CPPUNIT_ASSERT_MESSAGE(message,condition) \ +- ( CPPUNIT_NS::Asserter::failIf( !(condition), \ +- CPPUNIT_NS::Message( "assertion failed", \ +- "Expression: " \ +- #condition, \ +- CPPUNIT_NS::message_to_string(message) ), \ +- CPPUNIT_SOURCELINE() ) ) ++#define CPPUNIT_ASSERT_MESSAGE(message,condition) \ ++ do { ( CPPUNIT_NS::Asserter::failIf( !(condition), \ ++ CPPUNIT_NS::Message( "assertion failed", \ ++ "Expression: " \ ++ #condition, \ ++ CPPUNIT_NS::message_to_string(message) ), \ ++ CPPUNIT_SOURCELINE() ) ); \ ++ ANALYSIS_ASSUME(condition); } while(0) + + /** Fails with the specified message. + * \ingroup Assertions |