Skip to content

ir: Fix is_in_non_fully_specialized_template check. #466

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
Feb 2, 2017

Conversation

emilio
Copy link
Contributor

@emilio emilio commented Feb 1, 2017

Fixes #462

r? @upsuper

@upsuper
Copy link
Contributor

upsuper commented Feb 1, 2017

I didn't write the patch because I'm not fully sure how this should be handled. I guess is_template_like is the right way, but I'm not confident enough on what does that mean. Do we have a reliably way to detect whether one is a template (rather than a template specialization)?

@upsuper
Copy link
Contributor

upsuper commented Feb 1, 2017

Probably we should add a new method called is_template and check whether kind is one of CXCursor_FunctionTemplate, CXCursor_ClassTemplate, CXCursor_ClassTemplatePartialSpecialization, and CXCursor_TypeAliasTemplateDecl.

is_template_like sounds vague here as well... And I'm not sure whether the lack of function template there could be a problem here.

src/clang.rs Outdated
}

if !parent.is_template_like() {
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose we should still check recursively whether parent is_in_non_fully_specialized_template, otherwise something like

template<typename... T>
struct Outer {
  struct Inner {
    static constexpr int value[] = { T::value, ... };
  };
};

may crash again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, great catch.

Copy link
Contributor Author

@emilio emilio left a comment

Choose a reason for hiding this comment

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

The lack of function templates doesn't matter at all because we don't inspect their bodies.

src/clang.rs Outdated
}

if !parent.is_template_like() {
return false;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, great catch.

Copy link
Contributor

@upsuper upsuper left a comment

Choose a reason for hiding this comment

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

Yeah, I agree lack of that doesn't matter here. I just feel is_template_like sounds vague... anyway, this looks fine.

@upsuper
Copy link
Contributor

upsuper commented Feb 2, 2017

@bors-servo r+ (if I can)

@bors-servo
Copy link

@upsuper: 🔑 Insufficient privileges: Not in reviewers

@emilio
Copy link
Contributor Author

emilio commented Feb 2, 2017

@bors-servo r=upsuper

@bors-servo
Copy link

📌 Commit eb0a8af has been approved by upsuper

@emilio
Copy link
Contributor Author

emilio commented Feb 2, 2017

@bors-servo retry

  • Travis is drunk lately

@emilio
Copy link
Contributor Author

emilio commented Feb 2, 2017

@bors-servo r=upsuper

@bors-servo
Copy link

📌 Commit 993a959 has been approved by upsuper

@bors-servo
Copy link

⌛ Testing commit 993a959 with merge 44119eb...

bors-servo pushed a commit that referenced this pull request Feb 2, 2017
ir: Fix is_in_non_fully_specialized_template check.

Fixes #462

r? @upsuper
@bors-servo
Copy link

☀️ Test successful - status-travis
Approved by: upsuper
Pushing 44119eb to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants