<div class="gmail_quote">On Mon, Jun 11, 2012 at 4:04 PM, Preston Briggs <span dir="ltr"><<a href="mailto:preston.briggs@gmail.com" target="_blank">preston.briggs@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The LLVM Coding Standards discuss include files at some length.<div>Suggests that the minimal list of includes be listed.</div><div>Experimenting, I find the list is much shorter that used by most passes,</div><div>perhaps only 3 or 4 files, probably because the necessary declarations</div>

<div>are included indirectly. For example, I might get away with</div><div>a .h file including only</div><div><br></div><div><div>#include "llvm/Analysis/AliasAnalysis.h"</div><div>#include "llvm/Analysis/LoopInfo.h"</div>

<div>#include "llvm/ADT/SmallBitVector.h"</div></div><div><br></div><div>and a .cpp file including only</div><div><br></div><div><div>#include "myHeader.h"</div><div>#include "llvm/Analysis/ScalarEvolutionExpressions.h"</div>

<div>#include "llvm/Analysis/ValueTracking.h"</div><div>#include "llvm/Support/InstIterator.h"</div></div><div><br></div><div>Is it good style to cut the list down to the bare minimum like this?</div>
</blockquote><div><br></div><div>Personally, I don't think so. But then personally, I don't like this bit of the LLVM coding conventions.</div><div><br></div><div>I think that instead it should emphasize not trying to explicitly include-what-you-use, or find the minimal number of include lines. Instead, it should emphasize two things:</div>
<div><br></div><div>1) Include enough for your code to compile. If you're writing a header, that should be enough for your header to be self sufficient.</div><div>2) Don't include more than you need to. If you don't use any part of a header, don't include it.</div>
<div><br></div><div>Optimizing either above or below this seems like busy work and pointless given the current scale and maintenance burden of the LLVM codebase.</div></div>