[cfe-dev] get FieldDecl from FunctionDecl

Alejandro Jimenez Martinez whilealex at gmail.com
Wed Nov 6 00:26:08 PST 2013


Oh yes, thank you that is exactly what I was looking for :)

 

 

From: Richard Trieu [mailto:rtrieu at google.com] 
Sent: Tuesday, November 5, 2013 4:39 PM
To: Alejandro Jimenez
Cc: cfe-dev
Subject: Re: [cfe-dev] get FieldDecl from FunctionDecl

 

You want to go FunctionDecl to ParmVarDecl to Type to RecordType to
RecordDecl to FieldDecl.

 

FunctionDecl has param_begin() and param_end() methods to iterate over the
function parameters.

With a ParmVarDecl, call getType() to get the Type.  (Actually a QualType,
but when used as a pointer, it forwards calls to Type).

Call getAsStructureType() on the Type.  If the RecordType returned is not
null, then you've found your struct.

Use getDecl() on the RecordType to get the RecordDecl.

In RecordDecl, there is field_begin() and field_end() for iterating over the
FieldDecl's.

 

Hope that helps.

 

On Tue, Nov 5, 2013 at 1:23 PM, Alejandro Jimenez <whilealex at gmail.com
<mailto:whilealex at gmail.com> > wrote:

Hello!

 

I got lost on documentation about FunctionDecl.

 

If I have 

 

struct myStruct

{

   int param; <--- this is stored in a FieldDecl object

};

Question1?

in which Decl Object this structure is stored?

 

Now when I have 

 

int foo(myStruct X) <--- this is stored in FunctionDecl

 

 

My problem is that I want to validate the FieldDecl object on a function
signature, so I want to iterate over this FieldDecl objects if possible when
reading a FunctionDecl class. Any ideas or examples how this FieldDecl can
be accessed from a FunctionDecl object.

 

Alejandro


_______________________________________________
cfe-dev mailing list
cfe-dev at cs.uiuc.edu <mailto:cfe-dev at cs.uiuc.edu> 
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131106/752e97db/attachment.html>


More information about the cfe-dev mailing list