<div dir="ltr">LLVM's IR is not the same thing as Clang's AST. Do you want the AST, which has all the tree-structure and scopes of the original source program, or do you want LLVM IR, which is basic block soup? Alternatively, if you want to keep source level information you can try to use the static analysis CFG, which is layered on top of the Clang AST.<div><br></div><div>If you want the AST, you want to use libTooling or libclang to programmatically examine the AST. The -ast-dump flag will print the AST for debugging purposes, but it cannot be deserialized.</div><div><br></div><div>If you want a low-level view of the program, use 'clang -emit-llvm -S' to get LLVM IR instead of -ast-dump. This will be usable with other LLVM tools like opt.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 13, 2015 at 3:30 AM, yaduveer singh <span dir="ltr"><<a href="mailto:yaduveer99@gmail.com" target="_blank">yaduveer99@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Hi All,</div><div><br></div><div>I tried seeing the AST contents in by using following command:</div><div><br></div><div>clang -Xclang -ast-dump -fsyntax-only loop.c</div><div><br></div><div>This is giving me some AST output( I believe so) but I am having two issue:</div><div><br></div><div>1. I am not able to put this output in a file as Its showing following error:</div><div><br></div><div>yaduveer@yaduveer-Inspiron-3542:~/RP$ clang -Xclang -ast-dump -fsyntax-only loop1d.c | llvm-dis -o ast.txt</div><div>llvm-dis: Invalid bitcode signature</div><div>clang: error: unable to execute command: Broken pipe</div><div>clang: error: clang frontend command failed due to signal (use -v to see invocation)</div><div>clang version 3.6.0 (trunk 225627) (llvm/trunk 225626)</div><div>Target: x86_64-unknown-linux-gnu</div><div>Thread model: posix</div><div>clang: note: diagnostic msg: PLEASE submit a bug report to <a href="http://llvm.org/bugs/" target="_blank">http://llvm.org/bugs/</a> and include the crash backtrace, preprocessed source, and associated run script.</div><div>clang: note: diagnostic msg: </div><div>********************</div><div><br></div><div>PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:</div><div>Preprocessed source(s) and associated run script(s) are located at:</div><div>clang: note: diagnostic msg: /tmp/loop1d-71cd19.c</div><div>clang: note: diagnostic msg: /tmp/loop1d-71cd19.sh</div><div>clang: note: diagnostic msg: </div><div><br></div><div>********************</div><div><br></div><div><div style="font-size:12.8000001907349px">Could someone please advise me on following queries:</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">a) Is there some way so that I can get dependency analysis of AST and  Basic Blocks. </div><div style="font-size:12.8000001907349px">b) How can I modify an existing pass by writing a new Pass just like  "Hello" pass but the dependencies involved in that pass must not show error like "redeclaration".</div></div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">Regards,</div><div style="font-size:12.8000001907349px">Yaduveer</div></div></div>
</div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>