[compiler-rt] Replace bool operator== for VersionType in sanitizer_mac.h (PR #135068)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 9 12:04:04 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: Ivan Tadeu Ferreira Antunes Filho (itf)
<details>
<summary>Changes</summary>
Fixes error: ISO C++20 considers use of overloaded operator '==' (with operand types 'MacosVersion' and 'MacosVersion') to be ambiguous despite there being a unique best viable function [-Werror,-Wambiguous-reversed-operator].
This converts the comparison operator from a non-symmetric operator (const VersionBase<VersionType>& (as "this") and const VersionType &). into a symmetric operator
---
Full diff: https://github.com/llvm/llvm-project/pull/135068.diff
1 Files Affected:
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_mac.h (+2-2)
``````````diff
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.h b/compiler-rt/lib/sanitizer_common/sanitizer_mac.h
index f0a97d098eea0..ebf013e8e917b 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.h
@@ -37,8 +37,8 @@ struct VersionBase {
VersionBase(u16 major, u16 minor) : major(major), minor(minor) {}
- bool operator==(const VersionType &other) const {
- return major == other.major && minor == other.minor;
+ friend bool operator==(const VersionType &self, const VersionType &other) {
+ return self.major == other.major && self.minor == other.minor;
}
bool operator>=(const VersionType &other) const {
return major > other.major ||
``````````
</details>
https://github.com/llvm/llvm-project/pull/135068
More information about the llvm-commits
mailing list