Skip to content

Commit

Permalink
Add support for boost sync objects (#6007)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github authored Feb 20, 2024
1 parent 6c0a222 commit da5006a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cfg/boost.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -1267,4 +1267,17 @@
<not-uninit/>
</arg>
</function>
<type-checks>
<unusedvar>
<checkFiniteLifetime>boost::lock_guard</checkFiniteLifetime>
<checkFiniteLifetime>boost::mutex::scoped_lock</checkFiniteLifetime>
<checkFiniteLifetime>boost::recursive_mutex::scoped_lock</checkFiniteLifetime>
<checkFiniteLifetime>boost::unique_lock</checkFiniteLifetime>
<checkFiniteLifetime>boost::shared_lock</checkFiniteLifetime>
</unusedvar>
<operatorEqVarError>
<suppress>boost::mutex</suppress>
<suppress>boost::recursive_mutex</suppress>
</operatorEqVarError>
</type-checks>
</def>
8 changes: 8 additions & 0 deletions test/cfg/boost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <boost/smart_ptr/scoped_array.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/lock_guard.hpp>

BOOST_FORCEINLINE void boost_forceinline_test()
{}
Expand Down Expand Up @@ -94,4 +96,10 @@ void containerOutOfBounds_scoped_array(std::size_t n) // #12356
boost::scoped_array<int> d(new int[n] {});
for (std::size_t i = 0; i < n; i++)
if (d[i]) {}
}

void lock_guard_finiteLifetime(boost::mutex& m)
{
// cppcheck-suppress unusedScopedObject
boost::lock_guard<boost::mutex>{ m };
}

0 comments on commit da5006a

Please sign in to comment.