Use symtab_node::get_create for node creation
Replaced specific node creation calls with a unified symtab_node::get_create API.
GCC’s internal code has been refactored to use a more general API for creating symbol table nodes. Instead of checking the type of a declaration (variable or function) and calling specific creation functions like varpool_node::get_create or cgraph_node::get_create, the code now utilizes symtab_node::get_create where applicable. This change improves code consistency and maintainability across various parts of the compiler, including cgraphunit.cc, tree.cc, varasm.cc, and cp/decl.cc.
In Details
Several internal functions across GCC (cgraphunit.cc, tree.cc, varasm.cc, cp/decl.cc) previously performed type checks on declarations (e.g., VAR_DECL, FUNCTION_DECL) and then dispatched to specific node creation routines like varpool_node::get_create or cgraph_node::get_create. This commit consolidates these patterns by calling the more generic symtab_node::get_create function when suitable, simplifying the code and leveraging a unified interface for symbol table node management.
- symbol table
- A data structure used by a compiler to store information about identifiers (such as variable and function names) encountered in the source code.
- symtab_node
- Represents a node within the compiler's symbol table structure.
- varpool_node
- A specific type of node in GCC's internal representation, likely related to variable storage pools.
- cgraph_node
- A node in GCC's call graph representation, used for interprocedural analysis.
- declaration
- A statement in a program that introduces an identifier and specifies its type or properties.
- get_create
- A common pattern in C++ APIs where a method attempts to retrieve an existing object if it matches certain criteria, or creates a new one if it does not.