<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Jack,<div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 20, 2015, at 8:31 PM, via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:</div><div class=""><p class="">Recently I need to generate AST files while using clang static analyzer. I found that the option "-emit-ast" could not work with static analyzer. I used the command like this: clang -emit-ast --analyze -Xanalyzer -analyzer-checker=core.DivideZero a.c. Then I got a warning: argument unused during compilation: '-emit-ast'. I can only compile the source code once for some reason, so I have to generate ast file and use static analyzer at the same time. How can I manage that?</p></div></blockquote><div>I don’t believe there is a good way to do this. The driver will only perform a single job action for the ‘compile' phase and in this case --analyze takes precedence over -emit-ast.</div><div><br class=""></div><div>If you really can only call ‘clang’ once with your build process, one hacky possibility (depending on your build system) is to replace the environmental variables $CC and $CPP with a script that that calls the real clang twice, once with --analyze and once with -emit-ast, forwarding all other arguments. We do this with ‘scan-build’, which interposes with this trick to run the static analyzer while also compiling the program. You can see how this is done in tools/scan-build.</div><div><br class=""></div><div>Devin</div></div><br class=""></div></body></html>