title: Getting the source behind clang's AST
body: <p>Given an AST object in clang, how can I get the code behind it? I tried editing the code in the <a href="https://github.com/loarabia/Clang-tutorial/blob/master/CIBasicRecursiveASTVisitor.cpp#L37" rel="noreferrer">tutorial</a>, and added:</p>
  
  <pre><code>clang::SourceLocation _b = d-&gt;getLocStart(), _e = d-&gt;getLocEnd();
  char *b = sourceManager-&gt;getCharacterData(_b),
        e = sourceManager-&gt;getCharacterData(_E);
  llvm:errs() &lt;&lt; std::string(b, e-b) &lt;&lt; "\n";
  </code></pre>
  
  <p>but alas, it didn't print the whole typedef declaration, only about half of it! The same phenomena happened when printing <code>Expr</code>.</p>
  
  <p>How can I print and see the whole original string constituting the declaration?</p>