<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 12, 2017, at 12:57 PM, James Y Knight <<a href="mailto:jyknight@google.com" class="">jyknight@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Dec 11, 2017 at 3:37 PM, Mikhail Zolotukhin via cfe-dev <span dir="ltr" class=""><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank" class="">cfe-dev@lists.llvm.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word" class="">Hi Kim,<div class=""><br class=""><div class=""><span class="gmail-"><blockquote type="cite" class=""><div class="">On Dec 10, 2017, at 7:39 AM, Kim Gräsman <<a href="mailto:kim.grasman@gmail.com" target="_blank" class="">kim.grasman@gmail.com</a>> wrote:</div><br class="gmail-m_8798084079379340611Apple-interchange-newline"><div class=""><div class="">Hi Michael,<br class=""><br class="">On Thu, Dec 7, 2017 at 3:16 AM, Michael Zolotukhin<br class=""><<a href="mailto:mzolotukhin@apple.com" target="_blank" class="">mzolotukhin@apple.com</a>> wrote:<br class=""><blockquote type="cite" class=""><br class="">Nice to IWYU developers here:) I wonder how hard it would be to run IWYU on<br class="">LLVM/Clang (or, if it’s supposed to work, I wonder what I did wrong).<br class=""></blockquote><br class="">There are known problems with running IWYU over LLVM/Clang -- Zachary<br class="">Turner made an attempt a while back to get it up and running. Since<br class="">the LLVM tree uses all sorts of modern and moderately complex<br class="">patterns, we're struggling to keep up.<br class=""></div></div></blockquote></span>I see.<span class="gmail-"><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class=""><blockquote type="cite" class="">If we also can tweak it a bit to make it choose more human-like (~more<br class="">conservative) decisions, we would be able to just apply what it suggests!<br class=""></blockquote><br class="">Different humans appear to have different preferences :)<br class=""></div></div></blockquote></span>True, what I meant hear is to make the changes more conservative: e.g. if we can replace</div><div class=""><font face="Menlo" class="">#include "MyClass.h"</font></div><div class="">with </div><div class=""><font face="Menlo" class="">class MyClass;</font></div><div class="">then this change is probably desirable in every way: it documents the code better, it decreases coupling, it improves compile time.</div></div></div></blockquote><div class=""><br class=""></div><div class="">This is not a transform which is clearly "desirable in every way", because it _increases_ coupling between the user of the class and the implementation. The owner of the class can't add optional template arguments, change a class into a typedef, change the namespace, or other such refactorings. It also introduces the possibility of code which changes behavior depending on whether the full or forward decl are available (which, then, may be an ODR-violation).</div><div class=""><br class=""></div><div class="">Effectively the same reasons why the standard forbids users from forward-declaring std:: names apply to doing so to user-defined names.<br class=""></div><div class=""><br class=""></div><div class=""><a href="https://google.github.io/styleguide/cppguide.html#Forward_Declarations" class="">https://google.github.io/styleguide/cppguide.html#Forward_Declarations</a> lists some of the issues, and a recommendation not to do so.<br class=""></div><div class=""><br class=""></div><div class="">Of course you do have the upside is that it can improve compile time. Which is certainly of value, and perhaps that's a worthwhile trade-off when the implementation and forward-declare are both within a single project and thus easy to coordinate. But, it's not by any means a _pure_ win.</div></div></div></div></div></blockquote>That's correct. I was speaking about the LLVM codebase though (I should've stated that clearer), and in LLVM I don't remember many occasions of refactorings you mentioned. For LLVM forward declaration is recommended by the style guide:</div><div><a href="http://llvm.org/docs/CodingStandards.html#minimal-list-of-includes" class="">http://llvm.org/docs/CodingStandards.html#minimal-list-of-includes</a></div><div><br class=""></div><div>Thanks,</div><div>Michael</div><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><div class=""><br class=""></div></div></div></div>
</div></blockquote></div><br class=""></body></html>