aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2017-07-10 21:08:04 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2017-07-10 15:08:04 -0600
commitb2221d2bc678887616b5517c2e935480528556f0 (patch)
treed61dc35b728598ea412e3bde0b0f779e7d35b815
parent281ac396d1715da56e1098032de9d0b747fcace9 (diff)
downloadgcc-b2221d2bc678887616b5517c2e935480528556f0.zip
gcc-b2221d2bc678887616b5517c2e935480528556f0.tar.gz
gcc-b2221d2bc678887616b5517c2e935480528556f0.tar.bz2
cp-tree.h (cp_operator_id, [...]): Document.
gcc/cp/ChangeLog: * cp-tree.h (cp_operator_id, cp_assignment_operator_id): Document. From-SVN: r250105
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/cp-tree.h32
2 files changed, 29 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 3af0c43..56c2448 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,7 @@
+2017-07-10 Martin Sebor <msebor@redhat.com>
+
+ * cp-tree.h (cp_operator_id, cp_assignment_operator_id): Document.
+
2017-07-06 Jason Merrill <jason@redhat.com>
PR c++/81204 - parse error with dependent template-name
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 50f4235e..b58cfce 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -206,8 +206,19 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
/* std::align_val_t */
#define align_type_node cp_global_trees[CPTI_ALIGN_TYPE]
-/* We cache these tree nodes so as to call get_identifier less
- frequently. */
+/* We cache these tree nodes so as to call get_identifier less frequently.
+ For identifiers for functions, including special member functions such
+ as ctors and assignment operators, the nodes can be used (among other
+ things) to iterate over their overloads defined by/for a type. For
+ example:
+
+ tree ovlid = cp_assignment_operator_id (NOP_EXPR);
+ tree overloads = lookup_fnfields_slot (type, ovlid);
+ for (ovl_iterator it (overloads); it; ++it) { ... }
+
+ iterates over the set of implicitly and explicitly defined overloads
+ of the assignment operator for type (including the copy and move
+ assignment operators, whether deleted or not). */
/* The name of a constructor that takes an in-charge parameter to
decide whether or not to construct virtual base classes. */
@@ -228,6 +239,18 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
/* The name of a destructor that destroys virtual base classes, and
then deletes the entire object. */
#define deleting_dtor_identifier cp_global_trees[CPTI_DELETING_DTOR_IDENTIFIER]
+
+/* The name of the identifier used internally to represent operator CODE. */
+#define cp_operator_id(CODE) \
+ (operator_name_info[(int) (CODE)].identifier)
+
+/* The name of the identifier used to represent assignment operator CODE,
+ both simple (i.e., operator= with CODE == NOP_EXPR) and compound (e.g.,
+ operator+= with CODE == PLUS_EXPR). Includes copy and move assignment.
+ Use copy_fn_p() to test specifically for copy assignment. */
+#define cp_assignment_operator_id(CODE) \
+ (assignment_operator_name_info[(int) (CODE)].identifier)
+
#define delta_identifier cp_global_trees[CPTI_DELTA_IDENTIFIER]
#define in_charge_identifier cp_global_trees[CPTI_IN_CHARGE_IDENTIFIER]
/* The name of the parameter that contains a pointer to the VTT to use
@@ -1768,11 +1791,6 @@ struct GTY(()) language_function {
#define current_function_auto_return_pattern \
(cp_function_chain->x_auto_return_pattern)
-#define cp_operator_id(CODE) \
- (operator_name_info[(int) (CODE)].identifier)
-#define cp_assignment_operator_id(CODE) \
- (assignment_operator_name_info[(int) (CODE)].identifier)
-
/* In parser.c. */
extern tree cp_literal_operator_id (const char *);