'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'
};
-static int decl_is_template_id (const tree, tree* const);
+static tree maybe_template_info (const tree);
/* Functions for handling substitutions. */
write_number ((NUMBER), /*unsigned_p=*/1, 10)
/* If DECL is a template instance (including the uninstantiated template
- itself), return nonzero and, if TEMPLATE_INFO is non-NULL, set
- *TEMPLATE_INFO to its template info. Otherwise return zero. */
+ itself), return its TEMPLATE_INFO. Otherwise return NULL. */
-static int
-decl_is_template_id (const tree decl, tree* const template_info)
+static tree
+maybe_template_info (const tree decl)
{
if (TREE_CODE (decl) == TYPE_DECL)
{
const tree type = TREE_TYPE (decl);
if (CLASS_TYPE_P (type) && CLASSTYPE_TEMPLATE_ID_P (type))
- {
- if (template_info != NULL)
- /* For a templated TYPE_DECL, the template info is hanging
- off the type. */
- *template_info = TYPE_TEMPLATE_INFO (type);
- return 1;
- }
+ return TYPE_TEMPLATE_INFO (type);
}
else
{
- /* Check if this is a primary template. */
+ /* Check if the template is a primary template. */
if (DECL_LANG_SPECIFIC (decl) != NULL
&& VAR_OR_FUNCTION_DECL_P (decl)
&& DECL_TEMPLATE_INFO (decl)
- && PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (decl))
- && TREE_CODE (decl) != TEMPLATE_DECL)
- {
- if (template_info != NULL)
- /* For most templated decls, the template info is hanging
- off the decl. */
- *template_info = DECL_TEMPLATE_INFO (decl);
- return 1;
- }
+ && PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (decl)))
+ return DECL_TEMPLATE_INFO (decl);
}
/* It's not a template id. */
- return 0;
+ return NULL_TREE;
}
/* Produce debugging output of current substitution candidates. */
{
tree args = CLASSTYPE_TI_ARGS (type);
if (TREE_VEC_LENGTH (args) == 3
- && (TREE_CODE (TREE_VEC_ELT (args, 0))
- == TREE_CODE (char_type_node))
- && same_type_p (TREE_VEC_ELT (args, 0), char_type_node)
+ && template_args_equal (TREE_VEC_ELT (args, 0), char_type_node)
&& is_std_substitution_char (TREE_VEC_ELT (args, 1),
SUBID_CHAR_TRAITS)
&& is_std_substitution_char (TREE_VEC_ELT (args, 2),
args <char, std::char_traits<char> > . */
tree args = CLASSTYPE_TI_ARGS (type);
if (TREE_VEC_LENGTH (args) == 2
- && TREE_CODE (TREE_VEC_ELT (args, 0)) == TREE_CODE (char_type_node)
- && same_type_p (TREE_VEC_ELT (args, 0), char_type_node)
+ && template_args_equal (TREE_VEC_ELT (args, 0), char_type_node)
&& is_std_substitution_char (TREE_VEC_ELT (args, 1),
SUBID_CHAR_TRAITS))
{
return (!DECL_CONSTRUCTOR_P (decl)
&& !DECL_DESTRUCTOR_P (decl)
&& !DECL_CONV_FN_P (decl)
- && decl_is_template_id (decl, NULL));
+ && maybe_template_info (decl));
}
/* <encoding> ::= <function name> <bare-function-type>
{
tree fn_type;
tree d;
- bool tmpl = decl_is_template_id (decl, NULL);
- if (tmpl)
+ if (maybe_template_info (decl))
{
fn_type = get_mostly_instantiated_function_type (decl);
/* FN_TYPE will not have parameter types for in-charge or
|| (abi_version_at_least (7)
&& TREE_CODE (context) == PARM_DECL))))
{
- tree template_info;
/* Is this a template instance? */
- if (decl_is_template_id (decl, &template_info))
+ if (tree info = maybe_template_info (decl))
{
/* Yes: use <unscoped-template-name>. */
- write_unscoped_template_name (TI_TEMPLATE (template_info));
- write_template_args (TI_ARGS (template_info));
+ write_unscoped_template_name (TI_TEMPLATE (info));
+ write_template_args (TI_ARGS (info));
}
else
/* Everything else gets an <unqualified-name>. */
static void
write_nested_name (const tree decl)
{
- tree template_info;
-
MANGLE_TRACE_TREE ("nested-name", decl);
write_char ('N');
}
/* Is this a template instance? */
- if (decl_is_template_id (decl, &template_info))
+ if (tree info = maybe_template_info (decl))
{
/* Yes, use <template-prefix>. */
write_template_prefix (decl);
- write_template_args (TI_ARGS (template_info));
+ write_template_args (TI_ARGS (info));
}
else if ((!abi_version_at_least (10) || TREE_CODE (decl) == TYPE_DECL)
&& TREE_CODE (TREE_TYPE (decl)) == TYPENAME_TYPE)
write_prefix (const tree node)
{
tree decl;
- /* Non-NULL if NODE represents a template-id. */
- tree template_info = NULL;
if (node == NULL
|| node == global_namespace)
if (find_substitution (node))
return;
+ tree template_info = NULL_TREE;
if (DECL_P (node))
{
/* If this is a function or parm decl, that means we've hit function
return;
decl = node;
- decl_is_template_id (decl, &template_info);
+ template_info = maybe_template_info (decl);
}
else
{
/* Node is a type. */
decl = TYPE_NAME (node);
+ /* The DECL might not point at the node. */
if (CLASSTYPE_TEMPLATE_ID_P (node))
template_info = TYPE_TEMPLATE_INFO (node);
}
if (TREE_CODE (node) == TEMPLATE_TYPE_PARM)
write_template_param (node);
- else if (template_info != NULL)
+ else if (template_info)
/* Templated. */
{
write_template_prefix (decl);
tree decl = DECL_P (node) ? node : TYPE_NAME (node);
tree type = DECL_P (node) ? TREE_TYPE (node) : node;
tree context = decl_mangling_context (decl);
- tree template_info;
tree templ;
tree substitution;
MANGLE_TRACE_TREE ("template-prefix", node);
/* Find the template decl. */
- if (decl_is_template_id (decl, &template_info))
- templ = TI_TEMPLATE (template_info);
+ if (tree info = maybe_template_info (decl))
+ templ = TI_TEMPLATE (info);
else if (TREE_CODE (type) == TYPENAME_TYPE)
/* For a typename type, all we have is the name. */
templ = DECL_NAME (decl);
/* Conversion operator. Handle it right here.
<operator> ::= cv <type> */
tree type;
- if (decl_is_template_id (decl, NULL))
+ if (maybe_template_info (decl))
{
tree fn_type;
fn_type = get_mostly_instantiated_function_type (decl);
if (TREE_CODE (decl) == TYPE_DECL
&& TYPE_UNNAMED_P (type))
write_unnamed_type_name (type);
- else if (TREE_CODE (decl) == TYPE_DECL
- && LAMBDA_TYPE_P (type))
+ else if (TREE_CODE (decl) == TYPE_DECL && LAMBDA_TYPE_P (type))
write_closure_type_name (type);
else
write_source_name (DECL_NAME (decl));