[Lldb-commits] [lldb] [lldb] Mark operator== const to avoid ambiguity in C++20. (PR #68224)
Samira Bazuzi via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 4 07:23:36 PDT 2023
https://github.com/bazuzi created https://github.com/llvm/llvm-project/pull/68224
C++20 will automatically generate an operator== with reversed operand order, which is ambiguous with the written operator== when one argument is marked const and the other isn't.
These operators currently trigger -Wambiguous-reversed-operator at usage sites lldb/source/Symbol/SymbolFileOnDemand.cpp:68 and lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp:1286.
>From f87e05395e499069178660a2b614ae3ac7f887c2 Mon Sep 17 00:00:00 2001
From: Samira Bazuzi <bazuzi at google.com>
Date: Wed, 4 Oct 2023 10:06:14 -0400
Subject: [PATCH] [lldb] Mark operator== const to avoid ambiguity in C++20.
C++20 will automatically generate an operator== with reversed operand order, which is ambiguous with the written operator== when one argument is marked const and the other isn't.
These operators currently trigger -Wambiguous-reversed-operator at usage
sites lldb/source/Symbol/SymbolFileOnDemand.cpp:68 and lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp:1286.
---
lldb/include/lldb/Utility/XcodeSDK.h | 2 +-
.../DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp | 4 ++--
.../DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h | 2 +-
lldb/source/Utility/XcodeSDK.cpp | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/lldb/include/lldb/Utility/XcodeSDK.h b/lldb/include/lldb/Utility/XcodeSDK.h
index 878b131a1814536..f8528995d549c9c 100644
--- a/lldb/include/lldb/Utility/XcodeSDK.h
+++ b/lldb/include/lldb/Utility/XcodeSDK.h
@@ -69,7 +69,7 @@ class XcodeSDK {
XcodeSDK &operator=(const XcodeSDK &other);
XcodeSDK(const XcodeSDK&) = default;
- bool operator==(const XcodeSDK &other);
+ bool operator==(const XcodeSDK &other) const;
/// Return parsed SDK type and version number.
Info Parse() const;
diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
index 378b2472278605d..5aeaf3ae24d7c7b 100644
--- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -606,8 +606,8 @@ void DynamicLoaderDarwinKernel::KextImageInfo::SetProcessStopId(
m_load_process_stop_id = stop_id;
}
-bool DynamicLoaderDarwinKernel::KextImageInfo::
-operator==(const KextImageInfo &rhs) {
+bool DynamicLoaderDarwinKernel::KextImageInfo::operator==(
+ const KextImageInfo &rhs) const {
if (m_uuid.IsValid() || rhs.GetUUID().IsValid()) {
return m_uuid == rhs.GetUUID();
}
diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h
index 38a60d154820a96..000c382b2c01117 100644
--- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h
+++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h
@@ -176,7 +176,7 @@ class DynamicLoaderDarwinKernel : public lldb_private::DynamicLoader {
void SetProcessStopId(uint32_t stop_id);
- bool operator==(const KextImageInfo &rhs);
+ bool operator==(const KextImageInfo &rhs) const;
uint32_t GetAddressByteSize(); // as determined by Mach-O header
diff --git a/lldb/source/Utility/XcodeSDK.cpp b/lldb/source/Utility/XcodeSDK.cpp
index 84f3ccbd01e2d07..154ddbebe8b30d5 100644
--- a/lldb/source/Utility/XcodeSDK.cpp
+++ b/lldb/source/Utility/XcodeSDK.cpp
@@ -56,7 +56,7 @@ XcodeSDK::XcodeSDK(XcodeSDK::Info info) : m_name(GetName(info.type).str()) {
XcodeSDK &XcodeSDK::operator=(const XcodeSDK &other) = default;
-bool XcodeSDK::operator==(const XcodeSDK &other) {
+bool XcodeSDK::operator==(const XcodeSDK &other) const {
return m_name == other.m_name;
}
More information about the lldb-commits
mailing list