<div dir="ltr"><div>Having a server that provides syntax trees (and such other elements) has been investigated and developed by zapcc <a href="https://github.com/yrnkrn/zapcc">https://github.com/yrnkrn/zapcc</a> in the past. IIRC AFAIK they start N threads in the build system in the background and the real compiler called produces results using this background server. Not sure if "sockets" are used, however...</div><div><br></div><div>Maybe it was discussed earlier, but isn't there a way to split SA from the clang binary somehow? I know we have "CLANG_ENABLE_STATIC_ANALYZER=OFF".<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Endre Fülöp via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> ezt írta (időpont: 2020. ápr. 29., Sze, 10:15):<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div lang="HU">
<div class="gmail-m_-2449378435781695877WordSection1">
<p class="MsoNormal"><span lang="EN-US">Hi!<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">In order to not overburden the previous discussion about Analyzer and Tooling, I would like to ask you opinions on a related but slightly orthogonal matter.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Gabor and I had a brainstorming session about the issues CTU analysis and compilation command handling (previous topic) brought up recently.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Note that these points are to be regarded as cursory expeditions into the hypothetical (at best).<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">The train of thought regarding CTU analysis had the following outline:<u></u><u></u></span></p>
<ul type="disc">
<li class="MsoNormal">
<span lang="EN-US">We need a tool that gets a `FunctionDecl` (the function which we would like to inline) and returns with an AST to its TU.<u></u><u></u></span></li><ul type="circle">
<li class="MsoNormal">
<span lang="EN-US">the fitting abstraction level of the result seems to be the TU level<u></u><u></u></span></li><li class="MsoNormal">
<span lang="EN-US">`externalDefMapping.txt` is just an implementation detail, actually we don't need that.<u></u><u></u></span></li></ul>
<li class="MsoNormal">
<span lang="EN-US">Let's call this tool `<b>ASTServer</b>`.<u></u><u></u></span></li><li class="MsoNormal">
<span lang="EN-US">ASTServer has some resemblance to `clangd`.<u></u><u></u></span></li><ul type="circle">
<li class="MsoNormal">
<span lang="EN-US">Works on the whole project<u></u><u></u></span></li><li class="MsoNormal">
<span lang="EN-US">Uses compilation DB<u></u><u></u></span></li><li class="MsoNormal">
<span lang="EN-US">Persists already parsed ASTs in its memory (up to a limit)<u></u><u></u></span></li><ul type="square">
<li class="MsoNormal">
<span lang="EN-US">(Cache eviction strategies? LRU?)<u></u><u></u></span></li></ul>
</ul>
<li class="MsoNormal">
<span lang="EN-US">The AST would be returned on a socket and in a serialized form (ASTReader/Writer).<u></u><u></u></span></li><ul type="circle">
<li class="MsoNormal">
<span lang="EN-US">could also work over the network, promoting distribution<u></u><u></u></span></li></ul>
<li class="MsoNormal">
<span lang="EN-US">We need another tool: `<b>clang-analyzer</b>` !!!<u></u><u></u></span></li><ul type="circle">
<li class="MsoNormal">
<span lang="EN-US">Actually we should have done this earlier<u></u><u></u></span></li><li class="MsoNormal">
<span lang="EN-US">Utilizes clang for analysis purposes<u></u><u></u></span></li><li class="MsoNormal">
<span lang="EN-US">Handles comm with `ASTServer`<u></u><u></u></span></li><ul type="square">
<li class="MsoNormal">
<span lang="EN-US">Caches ASTs from the server<u></u><u></u></span></li></ul>
</ul>
<li class="MsoNormal">
<span lang="EN-US">external orchestrator tool CodeChecker tool would launch ASTServer and then would call clang-analyzer tool for each TU, thus conducting the analysis.<u></u><u></u></span></li></ul>
<p class="MsoNormal"><span lang="EN-US">The reasoning behind the separation:<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">The analyzer is a complex subsystem of Clang. The valid concern of clang binary growing out of proportion, and the increasing need for<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">tooling dependencies surfacing due to CTU analysis indicate the need reorganizing facilities.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">The point is further backed by the argument that a complex functionality of interprocess communication (over sockets in our example)<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">is even less desirable inside the clang binary than binary size bloat.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Also the complexity of the whole solution could be distributed, and concerns of build system management, build configuration formats<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">can be separated from the analyzer itself (but allows for a wide variety of build-system vs analysis cooperation schemes to be implemented).<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Again, the scope of these ideas is not trivial to assess, and would probably require a considerable amount of effort,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">but I hope an open discussion would outline a solution that benefits the structure of the whole project.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Cheers,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Endre<u></u><u></u></span></p>
</div>
</div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>