Skip to content
Snippets Groups Projects
Commit 95c7d589 authored by Lewis Hyatt's avatar Lewis Hyatt
Browse files

pch: Fix the reconstruction of adhoc data hash table

The function rebuild_location_adhoc_htab() was meant to reconstruct the
adhoc location hash map after restoring a line_maps instance from a
PCH. However, the function has never performed as intended because it
missed the last step of adding the data into the newly reconstructed hash
map. This patch fixes that.

It does not seem possible to construct a test case such that the current
incorrect behavior is observable as a compiler issue. It would be
observable, if it were possible for a precompiled header to contain an
adhoc location with a non-zero custom data pointer. But currently, such
data pointers are used only by the middle end to track inlining
information, and this happens later, too late to show up in a PCH.

I also noted that location_adhoc_data_update, which updates the hash map
pointers in a different scenario, was relying on undefined pointer
arithmetic behavior. I'm not aware of this having caused any issue in
practice, but in this patch I have also changed it to use defined pointer
operations instead.

libcpp/ChangeLog:

	* line-map.cc (location_adhoc_data_update): Remove reliance on
	undefined behavior.
	(get_combined_adhoc_loc): Likewise.
	(rebuild_location_adhoc_htab): Fix issue where the htab was not
	properly updated.
parent f25a6767
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment