Getting Stmt's parent, striping a QualType from CVR Qualifiers, eclipse & llvm

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting Stmt's parent, striping a QualType from CVR Qualifiers, eclipse & llvm

Ilya Mirsky
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!

I'm working on a program that does a src-2-src transformations, and I have the following issues:
  1.  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?

  2. 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?

  3. 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?

Thanks in advance,
Ilya


--
Best Regards,
Ilya Mirsky
www.cs.bgu.ac.il/~mirskyil


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Getting Stmt's parent, striping a QualType from CVR Qualifiers, eclipse & llvm

Douglas Gregor

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:
  1.  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.
  1. 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).
  1. 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

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev