title: Clang : What does AST (abstract syntax tree) look like?
body: <p>Hi I am new in Compiler development, and am wondering how AST look like. I have a small section of code, and I use Clang for generating the AST. I don't get much information out of it. 
  From the looks of it, the Syntax tree is exactly the same as the source, except for one struct that is added to almost any sample I test with.</p>
  
  <p>Source:</p>
  
  <pre><code>class A {
  public:
    int *a, *b, *c;
    int i;
    void sum() {
      a = new int[5];
      b = new int[5];
      c = new int[5];
      for (i = 0; i &lt; 5; i++) {
        a[i] = i;
        b[i] = i;
      }
      for (i = 0; i &lt; 5; i++) {
        c[i] = a[i] + b[i];
      }
      delete[] a;   delete[] b;   delete[] c;
    }
  };
  
  class B : public A {
  };
  
  int main() {
    B bclass; 
    bclass.sum();
    return 0;
  } 
  </code></pre>
  
  <p>Command to generate AST:</p>
  
  <pre><code>clang++ -cc1 -ast-print ~/sum.cpp
  </code></pre>
  
  <p>AST output:</p>
  
  <pre><code>struct __va_list_tag {
      unsigned int gp_offset;
      unsigned int fp_offset;
      void *overflow_arg_area;
      void *reg_save_area;
  };
  typedef struct __va_list_tag __va_list_tag;
  class A {
  public:
      int *a;
      int *b;
      int *c;
      int i;
      void sum()     {
          this-&gt;a = new int [5];
          this-&gt;b = new int [5];
          this-&gt;c = new int [5];
          for (this-&gt;i = 0; this-&gt;i &lt; 5; this-&gt;i++) {
              this-&gt;a[this-&gt;i] = this-&gt;i;
              this-&gt;b[this-&gt;i] = this-&gt;i;
          }
          for (this-&gt;i = 0; this-&gt;i &lt; 5; this-&gt;i++) {
              this-&gt;c[this-&gt;i] = this-&gt;a[this-&gt;i] + this-&gt;b[this-&gt;i];
          }
          delete [] this-&gt;a;
          delete [] this-&gt;b;
          delete [] this-&gt;c;
      }
  
  
  };
  class B : public A {
  };
  int main() {
      B bclass;
      bclass.sum();
      return 0;
  }
  </code></pre>
  
  <p>Thanks</p>