title: Create a C struct with fields, using LLVM libclang | LibTooling?
body: <p><a href="https://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html" rel="nofollow noreferrer"><code>clang::RecordDecl</code></a> seems to be the right construct, called with <a href="https://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html#a957a762e592b7b843f84f9249edf9d3d" rel="nofollow noreferrer"><code>clang::RecordDecl::Create</code></a>. But that requires <a href="https://clang.llvm.org/doxygen/classclang_1_1ASTContext.html" rel="nofollow noreferrer"><code>clang::ASTContext</code></a>, <a href="https://clang.llvm.org/doxygen/classclang_1_1DeclContext.html" rel="nofollow noreferrer"><code>clang::DeclContext</code></a>, &amp;etc.</p>
  <p>What I want to represent is this:</p>
  <pre class="lang-c prettyprint-override"><code>struct Haz {
    const char *bzr;
  };
      
  struct Foo {
    const char *bar;
    int can;
    struct Haz *haz;
  };
  </code></pre>
  <p><code>-ast-dump</code> doesn't give me runnable C++ code. Later I want to walk this AST and generate <a href="https://pubs.opengroup.org/onlinepubs/009604499/functions/free.html" rel="nofollow noreferrer"><code>free</code></a> code.</p>
  <p>How do I construct these <a href="https://en.wikipedia.org/wiki/Struct_(C_programming_language)" rel="nofollow noreferrer"><code>struct</code></a>s using <a href="https://clang.llvm.org/doxygen/group__CINDEX.html" rel="nofollow noreferrer">libclang</a> or <a href="https://clang.llvm.org/docs/LibTooling.html" rel="nofollow noreferrer">LibTooling</a>?</p>