[英]clang-tidy parsing error at spaceship operator
Using clang++-11
with libstdc++-11
and clang-tidy-11
, I run into failures when linting the code with clang-tidy
- namely parsing error when dealing with the well-known sleeper std::this_thread::sleep_for(std::chrono::seconds(1));
将
clang++-11
与libstdc++-11
和clang-tidy-11
一起使用,我在使用clang-tidy
对代码进行 linting 时遇到了失败 - 即在处理众所周知的 sleeper 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]
I checked it works fine with a basic spaceship operator usage我检查了它在基本的宇宙飞船操作员使用情况下工作正常
#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));
}
The fiasco seems to occur at the last line of this template from <chrono>
惨败似乎发生在
<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();
}
I managed to get over this with a temporary workaround (suure) of using boost::this_thread::sleep_for(boost::chrono::seconds(1));
我设法通过使用
boost::this_thread::sleep_for(boost::chrono::seconds(1));
的临时解决方法(肯定)克服了这个问题。 as it's a dependency in my project anyway.因为无论如何它都是我项目的依赖项。
Do you have any pointers ?你有什么指示吗? Have I failed somewhere or perhaps it's well-known bug in clang-tidy and I should not hesitate to file a bug report?
我是否在某个地方失败了,或者它可能是 clang-tidy 中众所周知的错误,我应该毫不犹豫地提交错误报告?
You can use the std::this_thread::sleep_until method with (now() + 1s) as argument.您可以使用带有 (now() + 1s) 作为参数的std::this_thread::sleep_until方法。
Confirmed clang-tidy bug, https://bugs.llvm.org/show_bug.cgi?id=47511 .确认 clang-tidy 错误, https://bugs.llvm.org/show_bug.cgi?id=47511 。 I'll leave the question as it is, perhaps someone will find the
boost
trick useful until it's fixed.我会保留这个问题,也许有人会发现
boost
技巧很有用,直到它被修复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.