Skip to content

Commit 801be96

Browse files
committed
NFC: Work around 'cycle detected while resolving' warning.
When building the Swift sources of the compiler many instances of the following warning are emitted: ``` .../swift-project/swift/include/swift/AST/Attr.h:3075:10: warning: cycle detected while resolving 'iterator' in swift_name attribute for 'operator==' bool operator==(iterator x) const { return x.attr == attr; } ^ ``` These warnings were implemented in #37940 and they indicate that Swift compiler is failing to import a clang decl because of circular references. Something about the structure of some operator declarations in C++ headers triggers this warning. I'm not sure what the correct long term fix for this is, but in the meantime the build log for the compiler is getting drowned in these warnings which makes it difficult to notice and find other diagnostics. Since these declarations are getting dropped instead of imported, we can simply hide them from the Swift compiler in the first place by guarding the declarations with `#ifdef __swift__`.
1 parent a1a975f commit 801be96

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

include/swift/AST/Attr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3072,8 +3072,10 @@ class TypeAttributes {
30723072
return *this;
30733073
}
30743074

3075+
#ifndef __swift__
30753076
bool operator==(iterator x) const { return x.attr == attr; }
30763077
bool operator!=(iterator x) const { return x.attr != attr; }
3078+
#endif // __swift__
30773079

30783080
CustomAttr *operator*() const { return attr; }
30793081
CustomAttr &operator->() const { return *attr; }

0 commit comments

Comments
 (0)