Repository navigation
Take function pointer types from the AST instead of parsing type strings - #152
Open
guitargeek wants to merge 1 commit into
Open
guitargeek wants to merge 1 commit into
guitargeek wants to merge 1 commit into
Conversation
The function pointer branches of CreateExecutor() and CreateConverter() sliced the printed type string (e.g. "int (*)(double, char)") to recover the return type and the argument list, as flagged by a "find better way of finding the type" TODO. Replace this with a new interop::GetFnTypeSigAsString(), built on GetFnTypeSig(), which asks clang for the pointee function prototype's return and parameter types. GetFnTypeSig() now guards against non-prototype types, as Cpp::GetFnTypeSignature() crashes on those. This fixes two bugs of the string parsing: - the type-based executor path removed all spaces before slicing, so any multi-word return type such as `unsigned int (*)()` broke with an attempt to compile `std::function<unsignedint()>`; - member function pointers matched the "::*)" check and produced a bogus std::function. They are not function pointers and are now rejected (returning one yields None as before, a data member of that type is reported as unconvertible). The string-based overloads keep the type from the lookup that ResolveName() performed anyway, and the regex used by the string-based CreateConverter() is dropped.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The function pointer branches of CreateExecutor() and CreateConverter() sliced the printed type string (e.g. "int (*)(double, char)") to recover the return type and the argument list, as flagged by a "find better way of finding the type" TODO. Replace this with a new interop::GetFnTypeSigAsString(), built on GetFnTypeSig(), which asks clang for the pointee function prototype's return and parameter types. GetFnTypeSig() now guards against non-prototype types, as Cpp::GetFnTypeSignature() crashes on those.
This fixes two bugs of the string parsing:
unsigned int (*)()broke with an attempt to compilestd::function<unsignedint()>;The string-based overloads keep the type from the lookup that ResolveName() performed anyway, and the regex used by the string-based CreateConverter() is dropped.