Can you just compare CRC32s of the binaries before and after your changes? And then just don’t commit unless they’re the same. You’ll have to do this with debug info disabled, as white space changes will affect debug info.<br><br>That said, I’m not lgtm’ing this, just saying that if the community does decide this is a good plan, let’s make sure generated code is identical <br><div class="gmail_quote"><div dir="ltr">On Tue, Dec 12, 2017 at 5:42 PM Michael Zolotukhin <<a href="mailto:mzolotukhin@apple.com">mzolotukhin@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space">Yes, that’s a valid concern, and that’s why I wanted to review all the changes before committing them (right now I’m going through all of them exactly to catch cases like you mention). It is actually happening sometimes, a good example is include of “config.h” - usually everything compiles even without it, but that’s not what we want.<div><br></div><div>My plan is to go through all the changes, remove undesired (like the ones you mentioned) and commit remaining changes in chunks (e.g. a folder at a time). Then people can do post-commit review, while the changes will get more exposure for testing. I hope it will go smoothly, but the time will show.<div><br></div><div>If there are any objections to my plan, I can put the patches for a pre-commit review first, though I consider them pretty safe.</div><div><br></div><div></div></div></div><div style="word-wrap:break-word;line-break:after-white-space"><div><div>Michael</div></div></div><div style="word-wrap:break-word;line-break:after-white-space"><div><div><div><br><div><blockquote type="cite"><div>On Dec 12, 2017, at 5:11 PM, Zachary Turner <<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>> wrote:</div><br class="m_2997264254210864318Apple-interchange-newline"><div><div dir="ltr">I'm a little late to the party, but one observation that I haven't seen mentioned is that simply removing #includes and testing that the program compiles is not guaranteed to be a correct transformation. Imagine, for example, that a header file provides an overload of a function that is a better match than one found elsewhere. It will compile either way, but without the #include, you will call a different function. Note that I'm not encouraging this kind of pattern, but the point is just to illustrate that this is not necessarily a correct transformation.<div><br></div><div>Another example is in the use of a macro definitions. Suppose a header defines certain macros, and other code uses ifdefs to test for the definition of those macros. If it is defined, one code path is taken, if it is not defined, another code path (which will compile but do the wrong thing) will be taken. Does the tool handle this?<br><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Dec 12, 2017 at 1:38 PM Mikhail Zolotukhin via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><blockquote type="cite"><div>On Dec 12, 2017, at 12:57 PM, James Y Knight <<a href="mailto:jyknight@google.com" target="_blank">jyknight@google.com</a>> wrote:</div><br class="m_2997264254210864318m_-6880181922805187330Apple-interchange-newline"><div><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 11, 2017 at 3:37 PM, Mikhail Zolotukhin via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><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">Hi Kim,<div><br><div><span class="m_2997264254210864318m_-6880181922805187330gmail-"><blockquote type="cite"><div>On Dec 10, 2017, at 7:39 AM, Kim Gräsman <<a href="mailto:kim.grasman@gmail.com" target="_blank">kim.grasman@gmail.com</a>> wrote:</div><br class="m_2997264254210864318m_-6880181922805187330gmail-m_8798084079379340611Apple-interchange-newline"><div><div>Hi Michael,<br><br>On Thu, Dec 7, 2017 at 3:16 AM, Michael Zolotukhin<br><<a href="mailto:mzolotukhin@apple.com" target="_blank">mzolotukhin@apple.com</a>> wrote:<br><blockquote type="cite"><br>Nice to IWYU developers here:) I wonder how hard it would be to run IWYU on<br>LLVM/Clang (or, if it’s supposed to work, I wonder what I did wrong).<br></blockquote><br>There are known problems with running IWYU over LLVM/Clang -- Zachary<br>Turner made an attempt a while back to get it up and running. Since<br>the LLVM tree uses all sorts of modern and moderately complex<br>patterns, we're struggling to keep up.<br></div></div></blockquote></span>I see.<span class="m_2997264254210864318m_-6880181922805187330gmail-"><br><blockquote type="cite"><div><div><br><blockquote type="cite">If we also can tweak it a bit to make it choose more human-like (~more<br>conservative) decisions, we would be able to just apply what it suggests!<br></blockquote><br>Different humans appear to have different preferences :)<br></div></div></blockquote></span>True, what I meant hear is to make the changes more conservative: e.g. if we can replace</div><div><font face="Menlo">#include "MyClass.h"</font></div><div>with </div><div><font face="Menlo">class MyClass;</font></div><div>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><br></div><div>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><br></div><div>Effectively the same reasons why the standard forbids users from forward-declaring std:: names apply to doing so to user-defined names.<br></div><div><br></div><div><a href="https://google.github.io/styleguide/cppguide.html#Forward_Declarations" target="_blank">https://google.github.io/styleguide/cppguide.html#Forward_Declarations</a> lists some of the issues, and a recommendation not to do so.<br></div><div><br></div><div>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></div></div><div style="word-wrap:break-word"><div>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" target="_blank">http://llvm.org/docs/CodingStandards.html#minimal-list-of-includes</a></div><div><br></div><div>Thanks,</div><div>Michael</div><div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div><br></div></div></div></div>
</div></blockquote></div><br></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="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>
</div></blockquote></div><br></div></div></div></div></blockquote></div>