处理大量的Boost单位测试与Clang-Tidy相关的警告



我正在设置一个项目。我使用Boost单位测试进行了骨骼测试。不幸的是,从宏扩展中产生了大量警告。有没有办法禁用这些,而无需指定各个行号?

即使我有//nolint。

也会发生这种情况。

一个例子:

/home/peter/checkouts/canopen-gateway/./unittests/projs/server/exe/testunit-tcp-socket.cpp:12:1: warning: construction of 'end_suite12_registrar12' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp]
BOOST_AUTO_TEST_SUITE_END()  // NOLINT
^
/usr/include/boost/test/unit_test_suite.hpp:62:73: note: expanded from macro 'BOOST_AUTO_TEST_SUITE_END'
#define BOOST_AUTO_TEST_SUITE_END()                                     
                                                                        ^
/usr/include/boost/test/unit_test_suite.hpp:209:62: note: expanded from macro 'BOOST_AUTO_TU_REGISTRAR'
static boost::unit_test::ut_detail::auto_test_unit_registrar BOOST_JOIN( BOOST_JOIN( test_name, _registrar ), __LINE__ )
                                                             ^
/usr/include/boost/config/suffix.hpp:544:28: note: expanded from macro 'BOOST_JOIN'
#define BOOST_JOIN( X, Y ) BOOST_DO_JOIN( X, Y )
                           ^
/usr/include/boost/config/suffix.hpp:545:31: note: expanded from macro 'BOOST_DO_JOIN'
#define BOOST_DO_JOIN( X, Y ) BOOST_DO_JOIN2(X,Y)
                              ^
/usr/include/boost/config/suffix.hpp:546:32: note: expanded from macro 'BOOST_DO_JOIN2'
#define BOOST_DO_JOIN2( X, Y ) X##Y
                               ^
note: expanded from here
/usr/include/boost/test/unit_test_suite_impl.hpp:284:17: note: possibly throwing constructor declared here
    explicit    auto_test_unit_registrar( int );

您可能没有粘贴整个错误消息,但是其中某个地方应该有一条线说

警告:残疾递归宏的扩展 [-wdisabled-macro-expansion]

您可以通过将-Wno-disabled-macro-expansion传递到clang命令行来禁用此问题。

尝试包装有问题的代码:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdisabled-macro-expansion"
// your code here
#pragma clang diagnostic pop

相关内容

  • 没有找到相关文章

最新更新