analyzer: Use std::map for symbol consolidation to improve stability
Replaces hash_map with std::map in the GCC analyzer for symbol consolidation, enhancing debuggability and reducing profiling overhead.
This commit refactors the GCC analyzer’s symbol consolidation mechanism by replacing hash_map with std::map. The author found hash_map usage to be error-prone and the associated hash calculations to be a performance concern in profiling. By switching to std::map, the goal is to simplify the code, improve debuggability, and reduce the overhead from hashing, without introducing any functional changes to the analyzer’s behavior.
In Details
The GCC analyzer's internal symbol consolidation, used in various region_model_manager methods (e.g., get_or_create_constant_svalue), previously relied on hash_map. This commit replaces all instances of hash_map with std::map. The motivation is to address perceived error-proneness of hash_map and to mitigate profiling hotspots related to hash computations. The replacement aims for simplicity and debuggability, acknowledging that the analyzer does not support garbage collection, which might otherwise complicate memory management with standard containers.
- analyzer
- A static analysis tool, integrated into GCC, that attempts to detect potential bugs and vulnerabilities in C/C++ code without executing it.
- symbol consolidation
- A process within static analysis where equivalent symbols or values are identified and represented by a single canonical instance, simplifying the analysis state.
- hash_map
- A C++ associative container that stores key-value pairs, using a hash table for efficient average-case lookups, insertions, and deletions.
- std::map
- A C++ associative container that stores key-value pairs, typically implemented as a balanced binary search tree, providing ordered iteration and logarithmic time complexity for operations.
- profiling
- The process of measuring the performance of a program, often by counting execution times or frequencies of certain operations.