Skip to content

Avoid mangling name for tpl class member. Fix #68 #69

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
Sep 29, 2016

Conversation

upsuper
Copy link
Contributor

@upsuper upsuper commented Sep 29, 2016

Not sure whether it is the right thing to do.

@highfive
Copy link

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@emilio
Copy link
Contributor

emilio commented Sep 29, 2016

Hmm... So I though this avoided getting the mangling for unspecialized methods, but this also avoids that in specialized methods.

I'm fine with not getting symbols for non-specialized templates, because it makes no particular sense (and I guess are the ones that crash), but I guess we can still parse the ones for specialized templates? (Though I think we don't use them yet?).

TLDR: Does a check like self.is_template() && self.specialized() != self instead of just self.is_template() still make the crash go away?

@emilio
Copy link
Contributor

emilio commented Sep 29, 2016

Otherwise I'm fine with merging this, I guess.

@emilio
Copy link
Contributor

emilio commented Sep 29, 2016

Oh, and thanks for digging into this btw :-)

@upsuper
Copy link
Contributor Author

upsuper commented Sep 29, 2016

The minimal reproduce code is:

template<class M> struct A;
template<class C> struct A<void(C::*)()> { static int v; };

and it crashes at the static variable v. Given A<void(C::*)()> looks like a specialized template (correct me if I'm wrong. I'm not very familiar with these concepts), I suppose checking is_specialized wouldn't fix the crash?

@emilio
Copy link
Contributor

emilio commented Sep 29, 2016

Well, it's not specialized completely, since you still don't know the C type.

Does something like:

template<class M> struct A;
template<>
struct A<int> {
    static int foo;
};

still crash?

@emilio
Copy link
Contributor

emilio commented Sep 29, 2016

Also, even if it still crashes, can you add a comment on the cursor_mangling function saying why we're returning early? I don't want anybody to remove it accidentally :)

@upsuper
Copy link
Contributor Author

upsuper commented Sep 29, 2016

That doesn't crash. But how can we check whether one template is fully specialized? It seems to me specialized() is for finding the less specialized one the template is from.

@emilio
Copy link
Contributor

emilio commented Sep 29, 2016

Hm... that's right. I think you can do:

fn is_complete_template_specialization(&self) -> bool {
    self.is_template() && self.num_template_args() > 0
}

Since the last method only works for complete specializations.

@upsuper upsuper force-pushed the mangling-tpl-member branch from 5936500 to 3f27469 Compare September 29, 2016 11:41
@upsuper upsuper force-pushed the mangling-tpl-member branch from 3f27469 to dd5962b Compare September 29, 2016 11:42
return false;
}
let parent = self.semantic_parent();
(parent.is_template() && !parent.is_fully_specialized_template()) ||
Copy link
Contributor

Choose a reason for hiding this comment

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

You can drop the parent.is_template() check here, since is already part of is_fully_specialized_template().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can't, because is_fully_specialized_template() is negated, so if you remove parent.is_template(), it would return true for non-templates.

@emilio
Copy link
Contributor

emilio commented Sep 29, 2016

r=me with that

@bors-servo: delegate+

@bors-servo
Copy link

✌️ @upsuper can now approve this pull request

@emilio
Copy link
Contributor

emilio commented Sep 29, 2016

You're right,

@bors-servo: r+

@bors-servo
Copy link

📌 Commit dd5962b has been approved by emilio

@bors-servo
Copy link

⚡ Test exempted - status

@bors-servo bors-servo merged commit dd5962b into rust-lang:master Sep 29, 2016
bors-servo pushed a commit that referenced this pull request Sep 29, 2016
Avoid mangling name for tpl class member. Fix #68

Not sure whether it is the right thing to do.
@upsuper upsuper deleted the mangling-tpl-member branch September 29, 2016 14:14
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