[lld] 1c108c8 - Mark operator== const to avoid errors when asserts are enabled
Sterling Augustine via llvm-commits
llvm-commits at lists.llvm.org
Tue May 28 17:29:13 PDT 2024
Author: Sterling Augustine
Date: 2024-05-29T00:28:51Z
New Revision: 1c108c80dc5b878452c00e1411cb530a66122ea5
URL: https://github.com/llvm/llvm-project/commit/1c108c80dc5b878452c00e1411cb530a66122ea5
DIFF: https://github.com/llvm/llvm-project/commit/1c108c80dc5b878452c00e1411cb530a66122ea5.diff
LOG: Mark operator== const to avoid errors when asserts are enabled
Without this change, the build will fail like so:
llvm-project/lld/MachO/ObjC.cpp:1387:75: error: ISO C++20 considers use of overloaded operator '==' (with operand types 'ObjcCategoryMerger::PointerListInfo' and 'ObjcCategoryMerger::PointerListInfo') to be ambiguous despite there being a unique best viable function [-Werror,-Wambiguous-reversed-operator]
1387 | parseProtocolListInfo(classIsec, roClassLayout.baseProtocolsOffset) ==
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
1388 | parseProtocolListInfo(metaIsec, roClassLayout.baseProtocolsOffset) &&
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/assert.h:100:27: note: expanded from macro 'assert'
100 | (static_cast <bool> (expr) \
| ^~~~
llvm-project/lld/MachO/ObjC.cpp:391:17: note: ambiguity is between a regular call to this operator and a call with the argument order reversed
391 | inline bool operator==(const PointerListInfo &cmp) {
| ^
llvm-project/lld/MachO/ObjC.cpp:391:17: note: mark 'operator==' as const or add a matching 'operator!=' to resolve the ambiguity
1 error generated.
Added:
Modified:
lld/MachO/ObjC.cpp
Removed:
################################################################################
diff --git a/lld/MachO/ObjC.cpp b/lld/MachO/ObjC.cpp
index 635ded554497b..6e857cfcd92f6 100644
--- a/lld/MachO/ObjC.cpp
+++ b/lld/MachO/ObjC.cpp
@@ -388,7 +388,7 @@ class ObjcCategoryMerger {
: categoryPrefix(_categoryPrefix),
pointersPerStruct(_pointersPerStruct) {}
- inline bool operator==(const PointerListInfo &cmp) {
+ inline bool operator==(const PointerListInfo &cmp) const {
return pointersPerStruct == cmp.pointersPerStruct &&
structSize == cmp.structSize && structCount == cmp.structCount &&
allPtrs == cmp.allPtrs;
More information about the llvm-commits
mailing list