Skip to content

Commit 2ef7ef1

Browse files
committed
Wrap some operators in #ifndef __swift__ guards.
Swift C++ interop has a bug where certain operator declarations cannot be imported successfully due to percieved circular references in the declarations. Since these declarations are already dropped by the ClangImporter, it's helpful to hide the declarations entirely from Swift to avoid spurious diagnostics that cannot be addressed. See swiftlang/swift#71032 for a similar workaround in the Swift compiler implementation.
1 parent 266d03f commit 2ef7ef1

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

clang/include/clang/AST/DependentDiagnostic.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,11 @@ class DeclContext::ddiag_iterator {
147147
return tmp;
148148
}
149149

150+
#ifndef __swift__
150151
bool operator==(ddiag_iterator Other) const {
151152
return Ptr == Other.Ptr;
152153
}
154+
#endif
153155

154156
bool operator!=(ddiag_iterator Other) const {
155157
return Ptr != Other.Ptr;

llvm/include/llvm/Transforms/IPO/Attributor.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5623,7 +5623,9 @@ struct AAPointerInfo : public AbstractAttribute {
56235623

56245624
unsigned size() const { return Ranges.size(); }
56255625

5626+
#ifndef __swift__
56265627
bool operator==(const RangeList &OI) const { return Ranges == OI.Ranges; }
5628+
#endif
56275629

56285630
/// Merge the ranges in \p RHS into the current ranges.
56295631
/// - Merging a list of unknown ranges makes the current list unknown.
@@ -5757,11 +5759,13 @@ struct AAPointerInfo : public AbstractAttribute {
57575759
Access(const Access &Other) = default;
57585760

57595761
Access &operator=(const Access &Other) = default;
5762+
#ifndef __swift__
57605763
bool operator==(const Access &R) const {
57615764
return LocalI == R.LocalI && RemoteI == R.RemoteI && Ranges == R.Ranges &&
57625765
Content == R.Content && Kind == R.Kind;
57635766
}
57645767
bool operator!=(const Access &R) const { return !(*this == R); }
5768+
#endif
57655769

57665770
Access &operator&=(const Access &R) {
57675771
assert(RemoteI == R.RemoteI && "Expected same instruction!");

llvm/include/llvm/Transforms/IPO/SampleContextTracker.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,15 @@ class SampleContextTracker {
161161
return *this;
162162
}
163163

164+
#ifndef __swift__
164165
bool operator==(const Iterator &Other) const {
165166
if (NodeQueue.empty() && Other.NodeQueue.empty())
166167
return true;
167168
if (NodeQueue.empty() || Other.NodeQueue.empty())
168169
return false;
169170
return NodeQueue.front() == Other.NodeQueue.front();
170171
}
172+
#endif
171173

172174
ContextTrieNode *operator*() const {
173175
assert(!NodeQueue.empty() && "Invalid access to end iterator");

0 commit comments

Comments
 (0)