forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang-tidy] Ignore implicit functions in readability-implicit-bool-c…
…onversion Ignore implicit declarations and defaulted functions. Helps with issues in generated code like, C++ spaceship operator. Closes llvm#93409
- Loading branch information
Showing
3 changed files
with
38 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-cxx20.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// RUN: %check_clang_tidy -std=c++20 %s readability-implicit-bool-conversion %t | ||
|
||
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 | ||
|
||
namespace PR93409 { | ||
struct X | ||
{ | ||
auto operator<=>(const X&) const = default; | ||
bool m_b; | ||
}; | ||
|
||
struct Y | ||
{ | ||
auto operator<=>(const Y&) const = default; | ||
X m_x; | ||
}; | ||
|
||
bool compare(const Y& y1, const Y& y2) | ||
{ | ||
return y1 == y2 || y1 < y2 || y1 > y2; | ||
} | ||
} |