Skip to content
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

cppexp: map member function pointers #4

Closed
wants to merge 1 commit into from

Conversation

wilsonk
Copy link

@wilsonk wilsonk commented Feb 24, 2015

This is c++11 specific, but including files like require c++11 support. This moves things along a little further.

@Syniurge
Copy link
Owner

Thanks Kelly. The UO_Deref mapping looks correct, I'll check the other two this evening. DelegateFuncptrExp sounds strange tbh, but I don't know much about member function pointers. I'll wrap my head around them by checking occurrences of BO_PtrMemD and BO_PtrMemI in Clang's Parse and Sema, see when they are generated and follow what Clang does with them.

@Syniurge
Copy link
Owner

Hey Kelly I had a tiring week and still haven't looked properly at member function pointers.

Do the latest commits break anything in your tests?

@wilsonk
Copy link
Author

wilsonk commented Feb 27, 2015

Hello Elie,

No, none of the tests break…things seem to get a little further along with a couple of them that use ‘-std=c++11’ (so algorithm and array, etc.), but they don’t even compile completely even with that fix. So I can just keep working on getting things further along here with c++11 specific stuff, when needed.

It really isn’t a big deal, I can just keep it in my local repo. I understand those tiring weeks…had a few of them doing my degrees :). Just get to it whenever you can as it isn’t a core C++ item anyways.

I will pull your TypeQualifiedBuilder changes sometime today and test them here. Need to do some other work first though, :)

Thanks,

Kelly

From: Elie Morisse [mailto:[email protected]]
Sent: Friday, February 27, 2015 11:37 AM
To: Syniurge/Calypso
Cc: wilsonk
Subject: Re: [Calypso] cppexp: map member function pointers (#4)

Hey Kelly I had a tiring week and still haven't looked properly at member function pointers.

Do the latest commits break anything in your tests?


Reply to this email directly or view it on GitHub #4 (comment) .

@Syniurge
Copy link
Owner

Syniurge commented Mar 1, 2015

Hey Kelly,

I learned today that BO_PtrMemD and BO_PtrMemI aren't for member function pointers, they're for any "member pointer type", and a value with a "member pointer type" is just an offset.

What the spec says:
http://www.open-std.org/jtc1/sc22/open/n2356/expr.html#expr.mptr.oper

And Clang has some examples:
https://github.com/llvm-mirror/clang/blob/master/test/SemaCXX/member-pointer.cpp
https://github.com/llvm-mirror/clang/blob/master/test/SemaCXX/member-pointers-2.cpp

@wilsonk
Copy link
Author

wilsonk commented Mar 2, 2015

Hello Elie,

I didn’t see the specifics below when I was looking at this. I just saw the clang error and a post on a newsgroup that seemed to indicate these were for pointers to member functions. I guess I should have looked into this further, sorry.

So now the question is…is there a D equivalent to these?

Point 6 in the spec seems to indicate that a pointer to a function could be the result of this pointer-to-member operator, does it not? With an opCall being used on the result? I guess that is what the newsgroup post was referring to. In this single case can we just translate to an opCall with the result as the operand?

Thanks,

Kelly

From: Elie Morisse [mailto:[email protected]]
Sent: Saturday, February 28, 2015 6:00 PM
To: Syniurge/Calypso
Cc: wilsonk
Subject: Re: [Calypso] cppexp: map member function pointers (#4)

Hey Kelly,

I learned today that BO_PtrMemD and BO_PtrMemI aren't for member function pointers, they're for any "member pointer type", and a value with a "member pointer type" is just an offset.

What the spec says:
http://www.open-std.org/jtc1/sc22/open/n2356/expr.html#expr.mptr.oper

And Clang has some examples:
https://github.com/llvm-mirror/clang/blob/master/test/SemaCXX/member-pointer.cpp
https://github.com/llvm-mirror/clang/blob/master/test/SemaCXX/member-pointers-2.cpp


Reply to this email directly or view it on GitHub #4 (comment) .

@Syniurge
Copy link
Owner

Syniurge commented Mar 3, 2015

BO_PtrMemD is for « LHS.*RHS » and BO_PtrMemI is for « LHS->*RHS », where LHS is an object/pointer and RHS is a "member pointer" value, which is basically an offset. AFAIK there is no equivalent in D to "member pointer types":

http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html

so in cpptypes.cpp they are mapped to ptrdiff_t. Since you still have access to the MemberPointerType when mapping expression the type of the result of the BO_PtrMemD/I expression is known (it's RHS.getPointeeType()). Other than that I'm not sure what would be the appropriate mapping for these expressions but you don't need opCall, it's not related.

@wilsonk
Copy link
Author

wilsonk commented Mar 16, 2015

Hello Elie,

I added a pull request for that extra build script I talked about a couple weeks back. Let me know if you want me to add some notes to the readme on how it works, if anything is unclear. I named it BUILD so that it wouldn’t be confused with the build.sh file in the root testing dir. Maybe BUILD_STL would be better? Or something else? Anyways, change as you see fit…I am just used to BUILD for my testing scripts :)

Sorry, I haven’t had much time lately to look into anything else. Hopefully I can find some more time soon.

Thanks,

Kelly

From: Elie Morisse [mailto:[email protected]]
Sent: Tuesday, March 03, 2015 8:48 AM
To: Syniurge/Calypso
Cc: wilsonk
Subject: Re: [Calypso] cppexp: map member function pointers (#4)

BO_PtrMemD is for « LHS.RHS » and BO_PtrMemI is for « LHS->RHS », where LHS is an object/pointer and RHS is a "member pointer" value, which is basically an offset. AFAIK there is no equivalent in D to "member pointer types":

http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html

so in cpptypes.cpp they are mapped to ptrdiff_t. Since you still have access to the MemberPointerType when mapping expression the type of the result of the BO_PtrMemD/I expression is known (it's RHS.getPointeeType()). Other than that I'm not sure what would be the appropriate mapping for these expressions but you don't need opCall, it's not related.


Reply to this email directly or view it on GitHub #4 (comment) .

@Syniurge
Copy link
Owner

Mapping and sending back member function pointers are fully implemented for the Itanium ABI.

They join C++ vtable generation as features that need to be ported to the MSVC ABI.

@Syniurge Syniurge closed this Feb 18, 2016
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.

2 participants