Skip to content

[cxx-interop] Support nested templates for conditional escapability #77678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

Xazax-hun
Copy link
Contributor

rdar://140115862

@Xazax-hun Xazax-hun added the c++ interop Feature: Interoperability with C++ label Nov 18, 2024
@Xazax-hun
Copy link
Contributor Author

@swift-ci please smoke test

Copy link
Contributor

@egorzhdan egorzhdan left a comment

Choose a reason for hiding this comment

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

I only have one question, otherwise LGTM

auto &argList = specDecl->getTemplateArgs();
for (auto argToCheck : argumentsToCheck) {
auto arg = argList[argToCheck.first];
if (arg.getKind() != clang::TemplateArgument::Type) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if this would work with variadic templates, e.g. std::tuple? But that's out of scope of this patch 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! I think this would not work for that. I'd address that in a follow-up PR.

}
clang::DeclContext *rec = specDecl;
specDecl = nullptr;
while ((rec = rec->getParent())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this loop stop once rec->isTranslationUnit()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When rec->isTranslationUnit() is true, rec->getParent() returns null and the loop terminates. That being said, I just realized rec is a bit confusing name here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, that makes sense.

@Xazax-hun Xazax-hun merged commit d3064c5 into main Nov 20, 2024
3 checks passed
@Xazax-hun Xazax-hun deleted the gaborh/conditional-escapability branch November 20, 2024 13:59
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.

2 participants