[cfe-dev] Patch: reporting the full include graph for a C++ compilation unit

Chandler Carruth chandlerc at google.com
Tue May 10 08:32:17 PDT 2011


A couple of high-level questions:

1) Do you need to output *both* a make-style dependency file and the
inclusion graph? One seems to be a superset of the other.
2) Why did you move away from presumed locations? Those are what appear in
the line table, and those are what would be preserved by the preprocessor.
3) Why can't we share the code with the make-style dependency file output?
You mention basing your escaping on theirs, but you've hand rolled your own
code.

On Tue, May 10, 2011 at 7:57 AM, Lukács T. Berki <lberki at google.com> wrote:

> On second thought, I added line numbers to the output file, so that each
> output line is now in the form of:
>
> <including file> <line number> <included file>
>
> Patch attached.
>
> On Mon, May 9, 2011 at 6:24 PM, Lukács T. Berki <lberki at google.com> wrote:
>
>>
>>
>> On Mon, May 9, 2011 at 4:39 PM, Douglas Gregor <dgregor at apple.com> wrote:
>>
>>>
>>> On May 9, 2011, at 4:25 PM, Lukács T. Berki wrote:
>>>
>>> > Hello happy people,
>>> >
>>> > 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.
>>> >
>>> > The patch is in the attachment. What does it take to get this submitted
>>> to Clang?
>>>
>>> Index: include/clang/Driver/CC1Options.td
>>> ===================================================================
>>> --- include/clang/Driver/CC1Options.td  (revision 131087)
>>> +++ include/clang/Driver/CC1Options.td  (working copy)
>>> @@ -200,6 +200,8 @@
>>>   HelpText<"Filename (or -) to write header include output to">;
>>>  def H : Flag<"-H">,
>>>   HelpText<"Show header includes and nesting depth">;
>>> +def inclusion_graph_file : Separate<"-inclusion-graph-file">,
>>> +  HelpText<"Print the complete header inclusion graph to this file">;
>>>  def MQ : Separate<"-MQ">, HelpText<"Specify target to quote for
>>> dependency">;
>>>  def MT : Separate<"-MT">, HelpText<"Specify target for dependency">;
>>>  def MP : Flag<"-MP">,
>>>
>>>
>>> This is a -cc1-level option. Did you also mean to have it work through
>>> the driver?
>>>
>> 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.
>>
>>
>>> 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.
>>>
>> 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.
>>
>>
>>>
>>> Also, the FileManager doesn't necessarily use full paths. Did you want
>>> the relative paths or full paths?
>>>
>> The same that are output by -dependency-file, so I copied the logic from
>> there.
>>
>> New version of patch attached.
>>
>>
>> Lukács
>>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110510/63499068/attachment.html>


More information about the cfe-dev mailing list