run clang-tidy --extra-arg=-I/path/to/boost/include -checks=-*,bugprone-use-after-move test.cpp (clang-tidy version 14.0.5)
yields:
/tmp/test.cpp:8:36: warning: 'v' used after it was moved [bugprone-use-after-move]
BOOST_CHECK_NO_THROW(f(std::move(v)));
/tmp/test.cpp:8:26: note: move occurred here
BOOST_CHECK_NO_THROW(f(std::move(v)));
/tmp/test.cpp:8:36: note: the use happens in a later loop iteration than the move
BOOST_CHECK_NO_THROW(f(std::move(v)));
Control flow analysis seems to be unable to see do { … } while( ::boost::test_tools::tt_detail::dummy_cond() ) as a loop that runs only once. If I replace these loops by do { … } while(0) loops in boost/test/tools/old/interface.hpp, the warning disappears.
Since it's probably unreasonable to expect clang-tidy to look into function calls, I wanted to first ask here – what is the purpose of dummy_cond? Would it be possible to use do { … } while(0) instead, which seems to be a common pattern?
run
clang-tidy --extra-arg=-I/path/to/boost/include -checks=-*,bugprone-use-after-move test.cpp
(clang-tidy version 14.0.5)yields:
Control flow analysis seems to be unable to see
do { … } while( ::boost::test_tools::tt_detail::dummy_cond() )
as a loop that runs only once. If I replace these loops bydo { … } while(0)
loops inboost/test/tools/old/interface.hpp
, the warning disappears.Since it's probably unreasonable to expect clang-tidy to look into function calls, I wanted to first ask here – what is the purpose of
dummy_cond
? Would it be possible to usedo { … } while(0)
instead, which seems to be a common pattern?