This showed up as a false positive from clang static analysis. It's because it doesn't realize that gtest ASSERT_* macros will return. Clang does allow for analyzer_noreturn annotations to help it understand, but I believe that's only on functions. Clang does recognize standard assert statements though, so I thought that would be the simplest solution here.
Example
/home/brawner/workspace/ros2_master/src/ros2/rosidl_typesupport/rosidl_typesupport_c/test/test_message_type_support_dispatch.cpp:117:15: warning: Called C++ object pointer is null
EXPECT_TRUE(lib->has_symbol("test_message_type_support"));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/brawner/workspace/ros2_master/install/gtest_vendor/src/gtest_vendor/include/gtest/gtest.h:1969:23: note: expanded from macro 'EXPECT_TRUE'
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
^~~~~~~~~
/home/brawner/workspace/ros2_master/install/gtest_vendor/src/gtest_vendor/include/gtest/internal/gtest-internal.h:1325:34: note: expanded from macro 'GTEST_TEST_BOOLEAN_'
::testing::AssertionResult(expression)) \
^~~~~~~~~~
This showed up as a false positive from clang static analysis. It's because it doesn't realize that gtest
ASSERT_*
macros will return. Clang does allow foranalyzer_noreturn
annotations to help it understand, but I believe that's only on functions. Clang does recognize standardassert
statements though, so I thought that would be the simplest solution here.Example
Signed-off-by: Stephen Brawner brawner@gmail.com