This is the mail archive of the
mailing list for the GCC project.
Re: [libcpp] maybe canonicalize system paths in line-map
On 26 April 2012 12:12, Dodji Seketeli <email@example.com> wrote:
> Manuel López-Ibáñez <firstname.lastname@example.org> a écrit:
>> On 21 April 2012 14:56, Jason Merrill <email@example.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
>> 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
I am not sure if it is important or not.