This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [libcpp] maybe canonicalize system paths in line-map


On 26 April 2012 12:12, Dodji Seketeli <dodji@seketeli.org> wrote:
> Manuel López-Ibáñez <lopezibanez@gmail.com> a écrit:
>
>> On 21 April 2012 14:56, Jason Merrill <jason@redhat.com> wrote:
>>> It seems like we'll do this for every line in the header, which could lead
>>> to a lot of leaked memory. ?Instead, we should canonicalize when setting
>>> ORDINARY_MAP_FILE_NAME.
>>
>> Hum, my understanding of the code is that this is exactly what I
>> implemented. That is, at most we leak every time
>> ORDINARY_MAP_FILE_NAME is set to a system header file (if the realpath
>> is shorter than the original path). This is a bit inefficient because
>> this happens two times per #include (when entering and when leaving).
>> But I honestly don't know how to avoid this.
>
> My understanding is that by the time we are about to deal with the
> ORDINARY_MAP_FILE_NAME property of a given map, it's too late; we have
> lost the "memory leak game" because that property just points to the
> path carried by the instance _cpp_file::path that is current when the
> map is built. ?So the lifetime of that property is tied to the lifetime
> of the relevant instance of _cpp_file.
>
> So maybe it'd be better to canonicalize the _cpp_file::path when it's
> first build? ?One drawback of that approach would be that
> _cpp_file::path will then permanently loose the information about the
> current directory, that is indirectly encoded into the way the file path
> is originally built. ?But do we really need that information?

Another drawback I didn't realize until now is that in this way the
canonicalize every path, instead of only touching those that belong to
system headers.

I am not sure if it is important or not.

Comments?

Cheers,

Manuel.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]