-
Notifications
You must be signed in to change notification settings - Fork 23
Description
Consider the following code:
struct X;
struct X
{
void m();
};It will produce the following IPR:
Namespace 'namespace '
|-Typedecl 'class' X
\-Typedecl 'class' X
\-Class 'class X'
\-Fundecl 'void (X *)' m
\-Parameter 'X *' this
Currently, we are building this representation the following way:
- We create a
Typedeclnode with the nameXand the typeclass(Typedecl(X) : class) for the forward declaration (theinitof thisTypedeclis null). - We create a new
Typedeclnode for the definition, which has the same name and type (Typedecl(X) : class) but theinitfield is the actual class type with all the info from the definiton.
This approach is problematic, for the following reason. We get different types for the forward declaration, and the definition.
The type of the forward declaration: AsType(Typedecl(X))
The type of the definition: class X (from the init field of the second Typedecl)
Ideally, we want both the forward declaration and the definition to have the same type. One option would be, to also create an empty class for the forward declaration, but in that case we would either end up having two class types of the same name, or (in case they both refer to the same type that has all its details filled) we cannot tell which declaration is a forward declaration and which one is a definition.
Alternatively, I could also use AsType(Typedecl(X)) for the definition to have the same type, but it would also end up producing different types as we are talking about different Typedecl nodes.
How should we solve this? Do I miss something?