[cfe-dev] Getting Stmt's parent, striping a QualType from CVR Qualifiers, eclipse & llvm

Douglas Gregor dgregor at apple.com
Thu Aug 26 08:25:24 PDT 2010


On Aug 26, 2010, at 6:53 AM, Ilya Mirsky wrote:

> Hi clang developers,
> 
> First, I would like to thank Douglas Gregor, who consistently helps and answers questions. I learn a lot from his replies, so Doug, I really appreciate it!

You don't need to CC me with your questions, though; I'll see them on the list ;)

> I'm working on a program that does a src-2-src transformations, and I have the following issues:
>  For some Stmt, how can I get its parent Stmt. i.e. when Replacing a Stmt which forms an IF body, sometimes it requires placing the new code inside brackets (replacement of a single Stmt with a block of Stmts), or if I'm replacing a Stmt which is part of a compound expression I want to get the location of the semicolon, in order to insert some code right afterward.
> How can I achieve this?

This information isn't encoded directly in the AST. However, you can use the ParentMap (in include/clang/AST/ParentMap.h) to construct a mapping from child statements to parent statements.
> Calling ParmVarDecl::getType::getAsString on the src code "const char *str" returns "TODO".
> How can I get just the "char*", without the const?
> I've tried to apply QualType::removeConst, QualType::removeCVRQualifiers but none seems to do any change.
> What is the right way to get the stripped type, without the CVR Qualifiers?
Removing qualifiers from a QualType only removes the top-level qualifiers, e.g., it would turn "const char * const" into "const char *". There is no convenience method to remove cv-qualifiers at all levels... you'll have to recursively decompose the type and rebuild it without any qualifiers (at each level).
> Currently I'm working on VS, but I want to switch to eclipse (minGW), unfortunately I'm having problems with llvm in eclipse. I run cmake with eclipse CDT configuration, but when I try to compile in eclipse I get errors. When I try to link an llvm client to existing llvm libraries (built with VS) I also get multiple compilation errors (the include lib is specified).
> My assumption is that minGW is more strict than VS. Is this really the problem, or am I missing something?
> Can anybody help me work it out?
I have no idea how to get Eclipse + MinGW to build Clang, sorry!

	- Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100826/32c1e226/attachment.html>


More information about the cfe-dev mailing list