<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">Hi all,</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">I would like to ask for feedback on an idea of compilation logging.</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">You can find PoC implementation here:</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class=""><a href="https://reviews.llvm.org/D65187" class="">https://reviews.llvm.org/D65187</a></div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class=""># Motivation</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">Despite programming models being fairly complex (esp. C++) clang provides only limited insight into what happens during semantic analysis. I am aware of just a couple of diagnostics (e. g. -fshow-overloads). Although other tools might help in specific cases I consider it sub-optimal:</div>
<ol class="">
<li style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">For some cases there's no tool.</li>
<li style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">Compiler is ultimately the source of truth and it seems like a waste of effort to replicate its logic in an external tool.</li>
</ol><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">For example to understand the following simple piece of code developers need to recall rules for special class members implicit definitions and rules for implicit conversions.</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">struct foo { };</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">struct bar : foo { };</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">int main() {</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class=""> bar b;</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class=""> const foo f = b;</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">}</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">The point is - although none of these rules are overly complicated and for a seasoned C++ developer they are just natural, it still seems easier to not have to model these in one's head.</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class=""># PoC implementation</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">For the above example the PoC implementation generates these remarks:</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">example.cpp:1:8: remark: implicit default constructor was generated for class 'foo' [-Rspecial-member-generated]</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">example.cpp:1:8: remark: implicit destructor was generated for class 'foo' [-Rspecial-member-generated]</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">example.cpp:1:8: remark: implicit copy constructor was generated for class 'foo' [-Rspecial-member-generated]</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">example.cpp:1:8: remark: implicit move constructor was generated for class 'foo' [-Rspecial-member-generated]</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">example.cpp:2:8: remark: implicit default constructor was generated for class 'bar' [-Rspecial-member-generated]</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">example.cpp:2:8: remark: implicit copy constructor was generated for class 'bar' [-Rspecial-member-generated]</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">example.cpp:2:8: remark: implicit move constructor was generated for class 'bar' [-Rspecial-member-generated]</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">example.cpp:6:19: remark: using implicit conversion from 'bar' to 'const bar' [-Rimplicit-conversion]</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">example.cpp:6:19: remark: using implicit conversion from 'const bar' to 'const foo' [-Rimplicit-conversion]</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">So far I selected just a handful of use-cases where additional information might be useful. Since this potentially generates loads of diagnostic output I also added an option for source range filtering.</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">Please see the provided tests to learn how to use the functionality.</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">For the PoC I decided to output this information directly from Sema but maybe it is possible to create a better user experience with more interactive/on-demand workflow (maybe as part of clangd or some other tool?). Two things should be considered for such approaches: </div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">1. For certain interesting use-cases, the state of Sema during compilation-time is necessary and AST on it's own is not sufficient - for example for function name resolution.</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">2. If such feature is kept in compilation codepath in clang it is less likely for the feature and the actual working of clang to diverge.</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">Thanks.</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" class="">Jan</div></body></html>