diff --git a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp --- a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp +++ b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp @@ -423,6 +423,14 @@ return UnknownVal(); } + if (op == BinaryOperatorKind::BO_Cmp) { + // We can't reason about C++20 spaceship operator yet. + // + // FIXME: Support C++20 spaceship operator. + // The main problem here is that the result is not integer. + return UnknownVal(); + } + if (Optional LV = lhs.getAs()) { if (Optional RV = rhs.getAs()) return evalBinOpLL(state, op, *LV, *RV, type); diff --git a/clang/test/Analysis/PR47511.cpp b/clang/test/Analysis/PR47511.cpp new file mode 100644 --- /dev/null +++ b/clang/test/Analysis/PR47511.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_analyze_cc1 -std=c++20 -w -analyzer-checker=core -verify %s + +// expected-no-diagnostics + +namespace std { +struct strong_ordering { + int n; + constexpr operator int() const { return n; } + static const strong_ordering equal, greater, less; +}; +constexpr strong_ordering strong_ordering::equal = {0}; +constexpr strong_ordering strong_ordering::greater = {1}; +constexpr strong_ordering strong_ordering::less = {-1}; +} // namespace std + +void test() { + // no crash + (void)(0 <=> 0); +}