[Lldb-commits] [lldb] 19141c4 - [lldb] Mark operator== const to avoid ambiguity in C++20. (#68224)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 4 09:04:20 PDT 2023
Author: Samira Bazuzi
Date: 2023-10-04T09:04:13-07:00
New Revision: 19141c4172ea5a4979fa0419dcf712d3f0cadefc
URL: https://github.com/llvm/llvm-project/commit/19141c4172ea5a4979fa0419dcf712d3f0cadefc
DIFF: https://github.com/llvm/llvm-project/commit/19141c4172ea5a4979fa0419dcf712d3f0cadefc.diff
LOG: [lldb] Mark operator== const to avoid ambiguity in C++20. (#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.
Added:
Modified:
lldb/include/lldb/Utility/XcodeSDK.h
lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h
lldb/source/Utility/XcodeSDK.cpp
Removed:
################################################################################
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