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

How to get original parameter type and not an expanded typedef #50

Open
MarcelVersteeg opened this issue Jul 9, 2021 · 1 comment
Open
Labels
question Further information is requested

Comments

@MarcelVersteeg
Copy link

Let's say I have the following code

template<class T>
class MyTemplateClass
{
    ....
};

typedef unsigned int MyInt;
typedef ::MyTemplateClass<char> MyCharClass;
typedef ::MyTemplateClass<::MyInt> MyMyIntClass;

class MyTestClass
{
    void TestMethod1(::MyInt param);
    void TestMethod2(::MyCharClass& param);
    void TestMethod3(::MyMyIntClass& param);
};

When I parse this, I get the following parameter information for the methods:
TestMethod1 -> param type is unsigned int
TestMethod2 -> param type is MyTemplateClass (wihtout the template arguments!)
TestMethod3 -> param type is MyTemplateClass (wihtout the template arguments!)

When I look at the C interface of clang, it seems that this is solved by using the canonical types, where the original (non-expanded type) is the actual type and holds a pointer to the underlying expanded type (not tested as I am writing C# code using this library).
However using this library, I am not able to get the original type as it is declared in the method signature.

I would like to know the original parameter type as it is written in the code and not the already expanded typedef. My parse configuration is as follows:

new CppParserOptions
{
    AutoSquashTypedef = false,
    ParseAsCpp = true,
    ParseAttributes = false,
    ParseComments = false,
    ParseMacros = true,
    ParseSystemIncludes = false,
    TargetCpu = CppTargetCpu.X86,
    TargetSystem = @"windows",
    TargetVendor = @"pc"
};
@xoofx xoofx added the question Further information is requested label Jul 9, 2021
@xoofx
Copy link
Owner

xoofx commented Jul 9, 2021

This library was not meant to support C++ and templates, also because libclang is sometimes not exposing everything, which is bringing more complications because we need to re-parse things CppAst.
But PR welcome if you find a way to expose this properly.

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

No branches or pull requests

2 participants