[cfe-dev] Question about TreeTransform

Richard Smith via cfe-dev cfe-dev at lists.llvm.org
Tue Feb 21 13:45:07 PST 2017


On 21 February 2017 at 13:36, Andrew Gozillon via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Hi guys,
>
>
> This might be a silly and naive question, but I was wondering if its at
> all possible for a type to change during a TreeTransform (I believe in
> general that's what the TreeTransform code is for but I could be incorrect)?
>
Yes, that's permitted. If you want to do so, you generally need to override
the relevant Transform*Type function, and be sure to populate the
TypeLocBuilder with location information for the new type. (Overriding
Rebuild*Type to produce a different type will in general not work, since
the type location information will be populated for the wrong type, leading
to the assertion you describe below.)

> For example at the moment I have a Type that acts as a wrapper for another
> Type (alongside some extra information), however during transformation for
> the wrapper Type I would like to "transform" it to the contained Type. The
> contained type would be something like a pointer to another type and the
> wrapper in essence is a throw away class.
>
>
> I've given it a try but when I swap out for the contained type I get a
> type size error "incorrect data size provided to CreateTypeSourceInfo!"
> within the TypeLocBuilder.h as the type sizes don't quite match up.
> Basically at this stage the TypeSourceInfo is that of the Wrapper with the
> contained type and the QualType itself is the contained type.
>
>
> So in essence my questions are, is what I'm trying to do possible? If it
> is, am I perhaps missing a step within my own Transform function that's
> required to modify the type source information appropriately?
>
It sounds like you are not populating the type source information for your
wrapper type properly within the TypeLocBuilder.

> As perhaps useful information the TypeLoc class I've based the wrapper
> class off of is the TypeSpecTypeLoc class.
>
>
> I'd be happy to provide more information or explain a little better for
> the sake of clarity, if that's required. As I'm unsure if this is enough
> information to go off of!
>
If the above hints aren't enough to unstick you, a (preferably reduced)
snippet of your code would help.

> Thank you for your time.
>
>
> Best Regards,
>
> Andrew
>
>
>
>
>
> Please consider the environment and think before you print.
>
> The University of the West of Scotland is a registered Scottish charity.
> Charity number SC002520.
>
> This e-mail and any attachment is for authorised use by the intended
> recipient(s) only. It may contain proprietary material, confidential
> information and/or be subject to legal privilege. It should not be copied,
> disclosed to, retained or used by, any other party. If you are not an
> intended recipient then please promptly delete this e-mail and any
> attachment and all copies and inform the sender.
>
> Please note that any views or opinions presented in this email are solely
> those of the author and do not necessarily represent those of the
> University of the West of Scotland.
>
> As a public body, the University of the West of Scotland may be required
> to make available emails as well as other written forms of information as a
> result of a request made under the Freedom of Information (Scotland) Act
> 2002.
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170221/1c47a25e/attachment.html>


More information about the cfe-dev mailing list