在使用clang++-11
和libstdc++-11
以及clang-tidy-11
时,当使用clang-tidy
检查代码时,遇到了失败情况 - 即在处理众所周知的睡眠器std::this_thread::sleep_for(std::chrono::seconds(1));
时出现解析错误。
clang-tidy-11 -header-filter=include/ -p=/tmp/dev/build/bin/aggregation/ -quiet /tmp/de
v/build/aggregation/src/main.cc
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0. Program arguments: clang-tidy-11 -header-filter=include/ -p=/tmp/dev/build/bin/
aggregation/ -quiet /tmp/dev/build/aggregation/src/main.cc
1. <eof> parser at end of file
2. While analyzing stack:
#0 Calling std::chrono::operator<=> at line /usr/include/c++/11/thread:125:6
#1 Calling std::this_thread::sleep_for at line 159
#2 Calling main
3. /usr/include/c++/11/chrono:771:9: Error evaluating statement
4. /usr/include/c++/11/chrono:771:9: Error evaluating statement
/usr/lib/x86_64-linux-gnu/libLLVM-11.so.1(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostre
amE+0x1f)[0x7f4ae7718e7f]
/usr/lib/x86_64-linux-gnu/libLLVM-11.so.1(_ZN4llvm3sys17RunSignalHandlersEv+0x50)[0x7f4
ae77171e0]
/usr/lib/x86_64-linux-gnu/libLLVM-11.so.1(+0xbd1355)[0x7f4ae7719355]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x14140)[0x7f4aee8ec140]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.11(_ZN5clang4ento17BasicValueFactory25getPers
istentSValWithDataERKNS0_4SValEm+0x58)[0x7f4aedd82e38]
我检查过,使用基本的飞船操作符可以正常工作。(了解更多)
#include <compare>
struct IntWrapper {
int value;
constexpr IntWrapper(int value): value{value} { }
auto operator<=>(const IntWrapper&) const = default;
};
constexpr bool is_lt(const IntWrapper& a, const IntWrapper& b) {
return a < b;
}
int main() {
static_assert(is_lt(0, 1));
}
这个灾难似乎发生在这个模板的最后一行,来自于
<chrono>
。 template<typename _Rep1, typename _Period1,
typename _Rep2, typename _Period2>
requires three_way_comparable<common_type_t<_Rep1, _Rep2>>
constexpr auto
operator<=>(const duration<_Rep1, _Period1>& __lhs,
const duration<_Rep2, _Period2>& __rhs)
{
using __ct = common_type_t<duration<_Rep1, _Period1>,
duration<_Rep2, _Period2>>;
return __ct(__lhs).count() <=> __ct(__rhs).count();
}
我设法通过一个临时解决方法(确实)来解决这个问题,使用boost :: this_thread :: sleep_for(boost :: chrono :: seconds(1)); ,因为它已经是我的项目依赖项。
你有任何建议吗? 我有哪里做错了吗,或者这是clang-tidy中众所周知的bug,我应该毫不犹豫地提交错误报告吗?