aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.h
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2023-04-24 10:33:49 -0400
committerPatrick Palka <ppalka@redhat.com>2023-04-24 10:33:49 -0400
commitb9ee7c6bfdbfcc722f3e4c8bd8378cccd4311740 (patch)
treeb956bca919e19eabba0e3ece188d32854d8f30dc /gcc/tree.h
parentb6d8e2975a9e1b9c3e839c09f265cd40426d23c1 (diff)
downloadgcc-b9ee7c6bfdbfcc722f3e4c8bd8378cccd4311740.zip
gcc-b9ee7c6bfdbfcc722f3e4c8bd8378cccd4311740.tar.gz
gcc-b9ee7c6bfdbfcc722f3e4c8bd8378cccd4311740.tar.bz2
c++, tree: declare some basic functions inline
The functions strip_array_types, is_typedef_decl, typedef_variant_p and cp_expr_location are used throughout the C++ front end including in some fairly hot parts (e.g. in the tsubst routines and cp_walk_subtree) and they're small enough that the overhead of calling them out-of-line is relatively significant. So this patch moves their definitions into the appropriate headers to enable inlining them. gcc/cp/ChangeLog: * cp-tree.h (cp_expr_location): Define here. * tree.cc (cp_expr_location): Don't define here. gcc/ChangeLog: * tree.cc (strip_array_types): Don't define here. (is_typedef_decl): Don't define here. (typedef_variant_p): Don't define here. * tree.h (strip_array_types): Define here. (is_typedef_decl): Define here. (typedef_variant_p): Define here.
Diffstat (limited to 'gcc/tree.h')
-rw-r--r--gcc/tree.h32
1 files changed, 29 insertions, 3 deletions
diff --git a/gcc/tree.h b/gcc/tree.h
index 8e67e70..dc94c17 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -4821,9 +4821,20 @@ tree_to_poly_uint64 (const_tree t)
extern int tree_int_cst_sgn (const_tree);
extern int tree_int_cst_sign_bit (const_tree);
extern unsigned int tree_int_cst_min_precision (tree, signop);
-extern tree strip_array_types (tree);
extern tree excess_precision_type (tree);
+/* Recursively examines the array elements of TYPE, until a non-array
+ element type is found. */
+
+inline tree
+strip_array_types (tree type)
+{
+ while (TREE_CODE (type) == ARRAY_TYPE)
+ type = TREE_TYPE (type);
+
+ return type;
+}
+
/* Desription of the reason why the argument of valid_constant_size_p
is not a valid size. */
enum cst_size_error {
@@ -5374,8 +5385,6 @@ extern tree create_artificial_label (location_t);
extern const char *get_name (tree);
extern bool stdarg_p (const_tree);
extern bool prototype_p (const_tree);
-extern bool is_typedef_decl (const_tree x);
-extern bool typedef_variant_p (const_tree);
extern bool auto_var_p (const_tree);
extern bool auto_var_in_fn_p (const_tree, const_tree);
extern tree build_low_bits_mask (tree, unsigned);
@@ -5391,6 +5400,23 @@ extern void error_unavailable_use (tree, tree);
extern tree cache_integer_cst (tree, bool might_duplicate = false);
extern const char *combined_fn_name (combined_fn);
+/* Returns true if X is a typedef decl. */
+
+inline bool
+is_typedef_decl (const_tree x)
+{
+ return (x && TREE_CODE (x) == TYPE_DECL
+ && DECL_ORIGINAL_TYPE (x) != NULL_TREE);
+}
+
+/* Returns true iff TYPE is a type variant created for a typedef. */
+
+inline bool
+typedef_variant_p (const_tree type)
+{
+ return is_typedef_decl (TYPE_NAME (type));
+}
+
/* Compare and hash for any structure which begins with a canonical
pointer. Assumes all pointers are interchangeable, which is sort
of already assumed by gcc elsewhere IIRC. */