On second thought, I added line numbers to the output file, so that each output line is now in the form of:<div><br></div><div><including file> <line number> <included file></div><div><br></div><div>Patch attached.</div>
<div><br><div class="gmail_quote">On Mon, May 9, 2011 at 6:24 PM, Lukács T. Berki <span dir="ltr"><<a href="mailto:lberki@google.com">lberki@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br><br><div class="gmail_quote"><div class="im">On Mon, May 9, 2011 at 4:39 PM, Douglas Gregor <span dir="ltr"><<a href="mailto:dgregor@apple.com" target="_blank">dgregor@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div></div><div><br>
On May 9, 2011, at 4:25 PM, Lukács T. Berki wrote:<br>
<br>
> Hello happy people,<br>
><br>
> I created a small patch to Clang to allow the compiler to report the full inclusion graph (i.e. a list of including file - included file) pairs. Note that this is quite similar to the functionality of -H, with the difference that this one reports also inclusions that are skipped because it would have no effect due to include guards and that the output is written to a file instead of stderr.<br>
><br>
> The patch is in the attachment. What does it take to get this submitted to Clang?<br>
<br>
</div></div>Index: include/clang/Driver/CC1Options.td<br>
===================================================================<br>
--- include/clang/Driver/CC1Options.td (revision 131087)<br>
+++ include/clang/Driver/CC1Options.td (working copy)<br>
@@ -200,6 +200,8 @@<br>
HelpText<"Filename (or -) to write header include output to">;<br>
def H : Flag<"-H">,<br>
HelpText<"Show header includes and nesting depth">;<br>
+def inclusion_graph_file : Separate<"-inclusion-graph-file">,<br>
+ HelpText<"Print the complete header inclusion graph to this file">;<br>
def MQ : Separate<"-MQ">, HelpText<"Specify target to quote for dependency">;<br>
def MT : Separate<"-MT">, HelpText<"Specify target for dependency">;<br>
def MP : Flag<"-MP">,<br>
<br>
<br>
This is a -cc1-level option. Did you also mean to have it work through the driver?<br></blockquote></div><div>Yes! I admit I am quite unfamiliar with how Clang works, so I assumed that it was enough to do it only there. I threaded it through Driver, too.</div>
<div class="im">
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If a path has spaces in it, you won't be able to tell where the first path ends and the second path begins. You'll need to perform some escaping here.<br></blockquote></div><div>Done. Note that there is small bug in DependencyFileCallback, whereupon backslashes in the file names are not escaped correctly (see DependencyFile:122). I guess this is to mimic GCC's behavior, though.</div>
<div class="im">
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Also, the FileManager doesn't necessarily use full paths. Did you want the relative paths or full paths?<br></blockquote></div><div>The same that are output by -dependency-file, so I copied the logic from there. </div>
<div>
<br></div><div>New version of patch attached.</div><div><br></div><font color="#888888"><div><br></div><div>Lukács</div></font></div>
</blockquote></div><br></div>