<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p></p>
<div>Hi,</div>
<div><br>
</div>
<div>I have following C code</div>
<div><br>
</div>
<div>    typedef struct</div>
<div>    {</div>
<div>       unsigned int    speed;</div>
<div>       int             len;</div>
<div>       snake_segment_t body[100];</div>
<div>    } snake_t;</div>
<div><br>
</div>
<div>    void f(snake_t snake) {}</div>
<div><br>
</div>
<div>And I want to iterate over function `f`'s arguments and in case if they are of struct type (like here), over fields of the struct too.</div>
<div><br>
</div>
<div>In Clang AST the structure looks like this:</div>
<div><br>
</div>
<div>    |-RecordDecl 0x5611f85ce6c0 <line:45:9, line:52:1> line:45:9 struct definition</div>
<div>    | |-FieldDecl 0x5611f85ce788 <line:47:4, col:20> col:20 referenced speed 'unsigned int'</div>
<div>    | |-FieldDecl 0x5611f85ce860 <line:50:4, col:20> col:20 referenced len 'int'</div>
<div>    | `-FieldDecl 0x5611f85ce9d8 <line:51:4, col:28> col:20 referenced body 'snake_segment_t [100]'</div>
<div><br>
</div>
<div>    |-TypedefDecl 0x5611f85cea70 <line:45:1, line:52:3> col:3 referenced snake_t 'struct snake_t':'snake_t'</div>
<div>    | `-ElaboratedType 0x5611f85cea20 'struct snake_t' sugar</div>
<div>    |   `-RecordType 0x5611f85ce750 'snake_t'</div>
<div>    |     `-Record 0x5611f85ce6c0 ''</div>
<div><br>
</div>
<div><br>
</div>
<div> First I find <i>FunctionDecl</i> for f, then iterate over its' <i>ParamDecls</i> to find all arguments. But when I retrieve
<i>Decl</i> from <i>ParamDecl->getType()</i> to iterate over struct fields, I get the
<i>TypedefDecl</i> (in AST). How can I get the real <i>RecordDecl</i>, the one that also has
<i>FieldDecl</i>s for struct?</div>
<div><br>
</div>
<div>Best,</div>
<div>Anahit.</div>
<br>
<p></p>
</div>
</body>
</html>