<div dir="ltr"><div dir="ltr"><div dir="ltr">On Thu, Jul 18, 2019 at 5:54 AM Дилян Палаузов via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Hello,<br>
<br>
how does scan-build exactly parse its parameters?<br>
<br>
How does “scan-build make” know, that it should just invoke make and not do anything until a compiler is invoked.<br></blockquote><div><br></div><div>My understanding is that scan-build itself merely sets `LD_PRELOAD=some-library.so` for all processes spawned directly or indirectly from scan-build. Then it goes ahead and spawns a child process to run whatever command you gave it — e.g., `make`.</div><div>`make` will eventually spawn a child or grandchild process for `clang`. When that happens, `some-library.so` will notice and cause different behavior. Either it will tell `clang` to invoke the static analyzer, or it will write out "hey, clang is being called!" to an external trace log. This external trace log is what Christian and Paulo are calling a "compilation database." The trace can be used later to re-invoke the static analyzer for each file that was compiled during the build, without having to `make clean` the entire project.</div><div><br></div><div>I confirmed some of my recollections via this documentation:</div><div><a href="https://github.com/rizsotto/scan-build">https://github.com/rizsotto/scan-build</a><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
Does “scan-build cc …” parse in fact the source code, or the generated object files and in the former case, is the<br>
compiler invoked or does scan-build just considers the parameters passed to the compiler?<br></blockquote><div><br></div><div>`scan-build` causes the static analyzer to be invoked. The static analyzer <i><b>must</b></i> parse the C++ source code. There is no way to "static-analyze" an object file.</div><div><br></div><div>–Arthur</div></div></div></div>