How to get original parameter type and not an expanded typedef
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 620
- Forks
- 79
- Avg merge
- 14h 27m
- Merged PRs (30d)
- 1
Description
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"
};
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by examining how the parser options, especially AutoSquashTypedef, affect parameter types and compare the library's output with Clang's C interface and canonical-type behavior. The change would need to preserve the original typedef spelling and template arguments for the three example method parameters while retaining access to their expanded types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, csharp
- Domain
- compilers, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100