Skip to content

[cxx-interop] Various code cleanups, no functional change intended#87574

Merged
Xazax-hun merged 1 commit intoswiftlang:mainfrom
Xazax-hun:cleanups
Feb 28, 2026
Merged

[cxx-interop] Various code cleanups, no functional change intended#87574
Xazax-hun merged 1 commit intoswiftlang:mainfrom
Xazax-hun:cleanups

Conversation

@Xazax-hun
Copy link
Contributor

  • Remove some unused includes
  • Simplify conditionals
  • Simplify loops
  • Use llvm:: algorithms
  • Simplify use of isa
  • Deduplicate some code
  • Other minor simplifications

@Xazax-hun Xazax-hun added the c++ interop Feature: Interoperability with C++ label Feb 27, 2026
@Xazax-hun Xazax-hun requested a review from hnrklssn as a code owner February 27, 2026 19:17
@Xazax-hun
Copy link
Contributor Author

@swift-ci please smoke test

Copy link
Contributor

@j-hui j-hui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole patch sparks joy.


/// Check whether the given declaration context is from a system module.
inline bool isInSystemModule(const DeclContext *D) {
return cast<ClangModuleUnit>(D->getModuleScopeContext())->isSystemModule();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this cast still valid if D's module scope context is not a clang module?

Given that this is in the swift namespace, maybe it should be a bit more defense.

And is there any reason not to put this in the swift::importer namespace?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it matters because this is a private header that is only available in the importer. Do you still prefer to have changes to this function?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's all good, I only noticed afterward that this helper function was de-duplicated from two separate .cpp files, fine to keep it as is!

Copy link
Member

@hnrklssn hnrklssn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

* Simplify conditionals
* Simplify loops
* Use llvm:: algorithms
* Simplify use of isa
* Deduplicate some code
* Other minor simplifications
@Xazax-hun
Copy link
Contributor Author

@swift-ci please smoke test

@Xazax-hun
Copy link
Contributor Author

@swift-ci please smoke test Windows

@Xazax-hun Xazax-hun merged commit a25e5b7 into swiftlang:main Feb 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ interop Feature: Interoperability with C++

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants