]> git.ipfire.org Git - thirdparty/gcc.git/commit
libcpp: Fix incorrect line numbers in large files [PR108900]
authorJeremy Bettis <jbettis@google.com>
Thu, 17 Apr 2025 04:00:00 +0000 (21:00 -0700)
committerJason Merrill <jason@redhat.com>
Wed, 23 Apr 2025 21:07:15 +0000 (17:07 -0400)
commit8a884140c2bcb738122e71d8d1c680f234de9843
tree956b54288a81559967de941b419920303db2576f
parent70eaec53f3284488ee2e58991aa38a86748d8a24
libcpp: Fix incorrect line numbers in large files [PR108900]

This patch addresses an issue in the C preprocessor where incorrect
line number information is generated when processing files with a
large number of lines. The problem arises from improper handling
of location intervals in the line map, particularly when locations
exceed LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES.

By ensuring that the highest location is not decremented if it
would move to a different ordinary map, this fix resolves
the line number discrepancies observed in certain test cases.
This change improves the accuracy of line number reporting, benefiting
users relying on precise code coverage and debugging information.

Tested x86_64-linux.

libcpp/ChangeLog:

PR preprocessor/108900
* files.cc (_cpp_stack_file): Do not decrement highest_location
across distinct maps.

Signed-off-by: Jeremy Bettis <jbettis@google.com>
Signed-off-by: Yash Shinde <Yash.Shinde@windriver.com>
(cherry picked from commit d9b56c65a2697e0d7a6c0f15f1977803dc94579b)
libcpp/files.cc