Repository navigation
Expand file tree
/
Copy pathexprutil.h
More file actions
3446 lines (2938 loc) · 149 KB
/
Copy pathexprutil.h
File metadata and controls
3446 lines (2938 loc) · 149 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Part of the EDG Compiler Project, under the Apache License v2.0 with LLVM
Exceptions.
See https://edgcpp.org/LICENSE.txt for license information.
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
/*
exprutil.h -- Declarations related to expression parsing.
*/
/* Avoid including these declarations more than once: */
#ifndef EXPRUTIL_H
#define EXPRUTIL_H 1
#ifndef IL_H
#include "il.h"
#endif /* ifndef IL_H */
#ifndef SYMBOL_TBL_H
#include "symbol_tbl.h"
#endif /* ifndef SYMBOL_TBL_H */
#ifndef DECLS_H
#include "decls.h"
#endif /* ifndef DECLS_H */
/* Conditionally open the "edg" namespace. */
BEGIN_EDG_NAMESPACE
/* Include of overload.h comes later. */
/*
Interfaces to add_stop_token and remove_stop_token to be used for matching
closing tokens, like ")" for "(". These mark the beginning and end of
a nested construct.
*/
#define add_matching_stop_token(token) \
{ add_stop_token(token); \
expr_stack->nested_construct_depth++; \
} /* add_matching_stop_token */
#define remove_matching_stop_token(token) \
{ remove_stop_token(token); \
expr_stack->nested_construct_depth--; \
} /* remove_matching_stop_token */
/* Define the categories of expressions that are allowed. */
enum an_expression_kind : a_byte {
/* Note that the constant expression kinds must appear at the beginning
of the list so that one can determine if an expression is constant
by a "<=" comparison instead of several "==" comparisons. See
curr_expr_kind_is_const below. ek_init_constant must be the last constant
expression kind. */
ek_pp, /* Preprocessing expression (see 3.8.1). */
ek_integral_constant, /* Integral constant expression (see 3.4). */
ek_template_arg, /* Nontype template argument (C++). */
ek_init_constant, /* Constant expression allowed in initializers (see
3.4). Limited use in C++, except that in C++11
this implements "core constant expression". */
/* Non-constant expression kinds: */
ek_normal, /* Normal expression, no restrictions. */
ek_sizeof /* The operand of sizeof. This is almost the same
as a normal expression. */
};
/*
Kinds of expressions again, this time as bits in a set used to
record occurrence of constructs that rule out certain expression
kinds. These are used for C and pre-C++11 C++; in C++11 different
rules apply, and a different mechanism is used (see
constant_expr_ruled_out in the expression stack).
*/
typedef a_byte a_ruled_out_expr_kind_set;
#define ROEK_NONE ((a_ruled_out_expr_kind_set)0)
#define ROEK_INTEGRAL_CONSTANT ((a_ruled_out_expr_kind_set)0x1)
/* An integral constant expression is ruled out. */
#define ROEK_CONSTANT ((a_ruled_out_expr_kind_set)0x2)
/* A constant expression is ruled out. */
/*
Kinds of source forms for casts.
*/
enum a_cast_source_form {
csf_none,
csf_old_style, /* Old-style cast, (T)x */
csf_functional, /* Functional-notation cast, T(x) */
csf_static_cast, /* static_cast<T>(x) */
csf_const_cast, /* const_cast<T>(x) */
csf_reinterpret_cast, /* reinterpret_cast<T>(x) */
csf_safe_cast, /* safe_cast<T>(x) -- C++/CLI mode. */
csf_dynamic_cast /* dynamic_cast<T>(x) */
};
/*
The context kinds in which overload resolution functions like
select_overloaded_function and select_and_prepare_to_call_overloaded_function
are called. This determines what kind of error messages might be issued when
overload resolution fails. In some cases it can also decide other aspects of
the call resolution (such as lookup).
*/
enum an_overload_context {
oc_default, /* Ordinary function or member function calls
(e.g., scan_function_call). */
oc_deferred, /* A syntactically-ordinary call in a template
context whose resolution should be deferred
until instantiation. This is used to
emulate a Microsoft bug. */
oc_constructor, /* Calls to constructors (see
scan_ctor_arguments). */
oc_new_expression, /* Calls to allocation functions generated for
new-expressions. */
oc_range_based_for_bounds, /* Calls generated to determine range-based
"for" loop bounds. */
oc_for_each_bounds, /* Calls generated to determine Microsoft C++
"for each" loop bounds. */
#if MICROSOFT_EXTENSIONS_ALLOWED
oc_cppcx_for_each_bounds, /* Calls generated to determine Microsoft C++/CX
"for each" loop bounds. */
oc_property_access, /* See rewrite_property_reference. */
oc_event_access, /* See rewrite_event_operator. */
#endif /* MICROSOFT_EXTENSIONS_ALLOWED */
oc_synthesized_member_call, /* See call_named_member_function. */
oc_ctad, /* See deduce_class_template_args. */
oc_tuple_like_binding, /* "get<N>" for tuple-like binding. */
oc_reversed_cmp_candidate, /* Set when checking the viability of a
"reversed" comparison operator candidate. */
oc_conv_to_class_check, /* Set when doing constructor overload
resolution in a call to function
conversion_to_class_possible. */
oc_multi_subscript, /* A C++23 multi-subscript call. */
oc_call_through_address_of_overload_set,
/* A call of the form "(&func)(args...)". In
this context, no implied object argument is
is added, static member functions do not get
an implicit object parameter, and if the
selected function is an ordinary nonstatic
member, the program is ill-formed. */
oc_last
};
#if BUILTIN_FUNCTIONS_ENABLED
/*
These values are returned by __builtin_classify_type. Order matters;
the values of these enumeration constants must match those used by
GCC.
*/
enum a_type_class_kind {
tck_none = -1,
tck_void, /* void */
tck_integer, /* short, int, long, long long */
tck_char, /* char (currently unused) */
tck_enum, /* enumeration types */
tck_bool, /* bool */
tck_pointer, /* pointers */
tck_reference, /* references */
tck_offset, /* pointer to data member */
tck_float, /* float, double, long double */
tck_complex, /* float complex, double complex, long double
complex */
tck_routine, /* functions */
tck_method, /* Unused in C or C++. */
tck_struct, /* structs or classes */
tck_union, /* unions */
tck_array, /* arrays */
tck_string /* strings (currently unused) */
/* Unused type classes:
tck_set
tck_file
tck_lang
*/
};
#endif /* BUILTIN_FUNCTIONS_ENABLED */
/*
Information on a single reference to a symbol. Used in cases where the kind
of reference can be affected by context and therefore cannot be recorded
immediately. This entry holds the information that must be retained to be
able to record the reference once the kind of reference is known.
*/
typedef struct a_ref_entry *a_ref_entry_ptr;
typedef struct a_ref_entry {
/* Describes one reference to a symbol. */
a_symbol_reference_kind
kind;
/* Kind of reference (modification, address taken,
etc.). */
a_byte_boolean
already_recorded;
/* TRUE if the reference has already been recorded.
Used when modifications are recorded at potential
sequence points. The modification is recorded, but
the symbol pointer has to be kept around in case
the address of the entity is taken for a reference
parameter to an overloaded operator function. */
#if CHECKING
a_byte_boolean
freed;
/* TRUE if the entry has been freed and is on the
available list. */
#endif /* CHECKING */
a_symbol_ptr symbol; /* Pointer to the referenced symbol. */
a_source_correspondence
*specific_il_entry;
/* If non-NULL, a pointer to a specific IL entry
to be used in place of the one pointed to by the
symbol. Used for variadic template pack elements,
where the symbol may be changed to point to a
different IL entry between the time the ref entry
is created and when the symbol reference is
recorded. */
a_source_position
position;
/* Source location of the reference. */
a_ref_entry_ptr
next;
/* Next entry on the list of reference entries
for the current expression, NULL if last. */
a_ref_entry_ptr
next_operand_ref;
/* Next entry on the list of reference entries
that apply to one operand, NULL if last. */
} a_ref_entry;
/* Kinds of operands: */
enum an_operand_kind : a_byte {
ok_error, /* Error. */
ok_expression, /* An expression tree. */
ok_constant, /* A constant value. */
ok_indefinite_function,
/* A function name that's not fully discriminated yet,
i.e., a C++ overloaded function. With state ==
os_function_designator, represents the function
itself and has very limited lifetime. With state ==
os_prvalue, represents the address of an overloaded
function, and survives until it meets a destination
type (which selects a specific function) or until
used in some other way (which is an error). Not
used in C. */
ok_sym_for_member, /* A symbol for a nonstatic data member or nonstatic
member function. Represented in this way because
it's not clear yet how the member is being used --
its address might be taken (e.g., "&A::f"), it
might get bound to an object and called (e.g.,
"p->f(1)"), etc. Not used for overloaded
functions (ok_indefinite_function is used
instead). Used only in C++. */
#if MICROSOFT_EXTENSIONS_ALLOWED
ok_property_ref, /* A reference to a Microsoft property member
of a class (traditional or managed). */
ok_event_ref, /* A reference to a Microsoft event member of a
managed class. */
#endif /* MICROSOFT_EXTENSIONS_ALLOWED */
ok_braced_init_list, /* A C++11 brace-enclosed list. Note that this is
used only in somewhat unusual situations, as most
braced-init-lists are scanned as part of an
expression list and are represented by
an_init_component (aka an_arg_list_elem). */
ok_undefined_symbol /* An undefined symbol encountered while scanning an
expression. Could be an implicit function
declaration or a genuine undefined symbol.
Has a very limited lifetime. */
};
/*
Operand states (lvalue versus rvalue, etc.). In C++, glvalues encompass
lvalues and xvalues, and traditional C rvalues are called prvalues.
In C mode, interpret "glvalue" as "lvalue" and "prvalue" as "rvalue".
A "function designator" is an expression of function type; in C++, those
are lvalues, but is_an_lvalue does not indicate that (see function
is_a_cplusplus_lvalue instead).
*/
enum an_operand_state : a_byte {
os_none,
os_glvalue,
os_prvalue,
os_function_designator
};
/* Data structure used to represent an expression within the expression
routines: */
typedef struct an_operand {
/*lint -e{1401}*/
inline an_operand() {}
inline an_operand(const an_operand &src) { this->copy_from(&src); }
/*lint -e{1529}*/
inline an_operand& operator=(const an_operand &src)
{ this->copy_from(&src); return *this; }
inline void copy_from(an_operand const *src);
a_type_ptr type;
/* Type of this operand. A tk_unknown type if not
applicable (ok_indefinite_function,
ok_undefined_symbol). */
#if OPTIMIZE_VIRTUAL_FUNCTION_CALLS
a_type_ptr orig_routine_type;
/* If this operand is an ok_constant designating a
routine that is an overrider of the
statically-chosen routine (because the type of
the complete object is known and the virtual
call has been optimized to a direct call of the
overrider), this is the type of the overridden
function; NULL in all other cases. */
#endif /* OPTIMIZE_VIRTUAL_FUNCTION_CALLS */
an_operand_kind
kind;
/* The kind of operand. */
an_operand_state
state;
/* Whether the operand is an lvalue, rvalue, or a
function designator. */
a_bit_field bound_function:1;
/* TRUE if the operand is a bound function, i.e.,
another operand is required to give the object
relative to which this function is selected. */
a_bit_field selector_is_object_pointer:1;
/* On the operand bound to one with bound_function
TRUE, this flag indicates that the source form
that created the bound function was "->" or "->*"
rather than "." or ".*". In other words, it
indicates that the selector is an object pointer
rather than a class lvalue or rvalue. Also used
on operands that are intended to be used as
selectors before they get bound to anything. */
a_bit_field virtual_function:1;
/* TRUE if the operand represents a function that
should be called as a virtual function (e.g.,
FALSE for a virtual function referenced using
a qualified name). */
a_bit_field is_id_expression:1;
/* TRUE if this operand was generated from an
id-expression (a qualified or unqualified name).
TRUE even if the id-expression is parenthesized;
use the id_expression_was_parenthesized flag to
exclude that case. */
a_bit_field is_address_of_id_expression:1;
/* TRUE if this operand was generated from an
id-expression prefixed with an ampersand ("&").
TRUE even if the id-expression is parenthesized;
use the id_expression_was_parenthesized flag to
exclude that case. */
a_bit_field id_expression_was_parenthesized:1;
/* TRUE if this operand was generated from a
parenthesized id-expression. */
a_bit_field is_qualified_name:1;
/* TRUE if the operand was generated from a qualified
name. */
a_bit_field is_microsoft_deferred_name:1;
/* TRUE if the operand represents a name that would
normally not be considered template-dependent, but
whose resolution the Microsoft compiler defers until
template instantiation.*/
a_bit_field access_control_error_reported:1;
/* TRUE if an access control error was reported
on the base identifier for this operand. This
remains meaningful only for operands that are
essentially still just a representation for
an identifier, e.g., ok_indefinite_function and
ok_sym_for_member. */
a_bit_field designated_by_splice:1;
/* TRUE if this operand was generated from a
splice-expression designating a class member.
Such a member is accessible from any point, and
the additional protected member access check
(N5046 [class.protected]) does not apply to it.
Like access_control_error_reported, this
remains meaningful only for ok_sym_for_member
operands. */
a_bit_field is_operand_of_address_of:1;
/* TRUE if this operand is the immediate operand
of an "&" address-of operator. This is
used on ok_indefinite_function operands to remember
that a "&" appeared that can't yet be represented
in the IL, because we don't know yet what the
underlying entity will be. Also used on some
constant operands that represent indefinite
functions; see operand_allows_is_operand_address_of.
When this is TRUE, the ampersand_position field
gives the position of the "&" (the normal position
field gives the position of the underlying
identifier). Note that "immediate operand" does
not preclude parentheses in the source form,
as in &(A::f); see also
has_required_ptr_to_member_form. */
a_bit_field has_required_ptr_to_member_form:1;
/* Similar to is_operand_of_address_of, but indicates
that the operand has the correct form for a
pointer-to-member constant, e.g., no parentheses.
TRUE only when is_operand_of_address_of is TRUE.
Doesn't include whether the operand is a qualified
name; see is_qualified_name. */
a_bit_field is_template_id:1;
/* TRUE if an explicit template argument list
applies to variant.symbol. template_arg_list
gives the argument list. */
a_bit_field is_simple_string_literal:1;
/* TRUE if this operand is a simple string literal
or wide string literal, or the result of the
decay of such a literal to a pointer. FALSE
for a string literal that has been subjected to
a cast or other operation. */
a_bit_field conditional_simple_string_literal:1;
/* TRUE if this operand represents a conditional
operand of the form "x ? y : z" where either y or z
is a simple string literal. This is used to emulate
a Microsoft bug. */
a_bit_field is_cfront_null_pointer_constant:1;
/* TRUE if this operand is a simple 0 which is
suitable as a null pointer constant in
overload resolution in cfront mode. */
#if MICROSOFT_EXTENSIONS_ALLOWED
a_bit_field is_microsoft_noop:1;
/* TRUE if the operand came from a Microsoft __noop.
This is used to suppress the warning that the
code has no effect. */
#endif /* MICROSOFT_EXTENSIONS_ALLOWED */
a_bit_field is_name_followed_by_left_paren:1;
/* TRUE if this is a name followed by a left
parenthesis. Needed to know if argument-dependent
lookup applies, and also for C++/CLI hide-by-sig
lookup. */
a_bit_field is_dummy_lvalue:1;
/* TRUE if this operand was created by
make_dummy_lvalue_operand. It could be a dummy
xvalue, in spite of the name. */
a_bit_field is_parenthesized:1;
/* TRUE if the operand is enclosed in one or more sets
of parentheses. */
a_bit_field name_reference_set:1;
/* TRUE if name_reference has been set. */
a_bit_field caused_template_instantiation:1;
/* TRUE if parsing this operand caused a template
to be instantiated. */
#if MICROSOFT_EXTENSIONS_ALLOWED
a_bit_field allow_addr_of_managed_member:1;
/* TRUE if this operand is for a function scanned in
a C++/CLI context where it's okay to take the
address of a member of a managed class. */
#endif /* MICROSOFT_EXTENSIONS_ALLOWED */
a_bit_field pending_capture:1;
/* TRUE for an enk_variable expression that should
potentially be rewritten as a field selection
because the variable being referred to must be
captured. This cannot be decided when the node is
created because constant-valued variables used as
prvalues only don't need to be captured, and we
don't know that it is used as a prvalue until
later. */
a_name_reference
name_reference;
/* Records the form of reference to a name, for
some operands that represent named entities
(e.g., a function name). Valid when
name_reference_set is TRUE. */
a_ruled_out_expr_kind_set
ruled_out_expr_kinds;
/* Bits indicating kinds of expressions ruled out.
For example, if the expression contains something
not allowed in an integral constant expression,
the roek_integral_constant bit will be set.
Of use in checking after a scan whether an
expression scanned in default mode meets the
requirements of a certain expression kind.
Not used for C++11 constant expressions. */
a_source_position
position;
/* The source position for the operand. */
#if EXTRA_SOURCE_POSITIONS_IN_IL
a_source_position
end_position;
/* The source position of the end of the operand. */
#endif /* EXTRA_SOURCE_POSITIONS_IN_IL */
a_ref_entry_ptr
ref_entries_list;
/* A list of reference entries that are related
to the operand. This list includes only entries
for functions and for entities involved in lvalue
address computations, whose reference kinds might
be changed once the full context surrounding the
operand is known. Note that this list does
sometimes have meaning in an operand that is an
rvalue, e.g., for an array name that has decayed
to a pointer. */
a_ref_entry_ptr
saved_ref_entries_list;
/* Saved list of reference entries used for cases
where an rvalue can be turned back into an
lvalue, e.g., in gcc mode. */
a_template_arg_ptr
template_arg_list;
/* When is_template_id is TRUE, a template argument
list to be applied to variant.symbol. */
a_source_position
id_position;
/* Extra source position for an identifier, used
for ok_indefinite_function, ok_undefined_symbol,
and ok_property_ref. If the name is "X::f",
this gives the position of "f", where the field
position above gives the position of the "X". */
a_source_position
ampersand_position;
/* When is_operand_of_address_of is TRUE, this gives
the position of the "&" operator. */
a_pack_expansion_descr_ptr
pack_expansion_descr;
/* If non-NULL, this operand is a pack expansion
(it is followed by "...", as in "T()..."), and this
points to the expansion description. */
/* When kind == ok_indefinite_function, ok_sym_for_member, ok_property_ref,
ok_event_ref, or ok_undefined_symbol, and also ok_expression for
the enk_field case: */
a_symbol_ptr
symbol;
/* Pointer to the symbol. May be a projection
symbol for ok_indefinite_function,
ok_sym_for_member, or ok_expression/enk_field. */
/* The following "variant" union must be the last member of an_operand.
The member function an_operand::copy_from relies on it. */
union {
/* When kind == ok_error, ok_indefinite_function, ok_sym_for_member, or
ok_undefined_symbol: No variant fields. */
/* When kind == ok_expression: */
an_expr_node_ptr
expression;
/* When kind == ok_constant: */
a_constant constant;
#if MICROSOFT_EXTENSIONS_ALLOWED
/* When kind == ok_property_ref: */
/* This is used for a reference to a class member declared with the
Microsoft C++ extension __declspec(property(...)) or with the C++/CLI
property syntax. */
struct {
an_expr_node_ptr
object; /* Expression for the class object pointer. For a
reference to a C++/CLI static property, can be NULL
because there's no object, and if it is non-NULL
indicates an object that is evaluated and discarded
(it won't take part in the overload resolution
used to select the accessor). */
an_arg_list_elem_ptr
subscripts;
/* Optional list of subscript expressions, for cases
like p->x[y][z]. */
} property_ref;
/* When kind == ok_event_ref: */
struct {
an_expr_node_ptr
object; /* Expression for the class object pointer. For a
reference to a C++/CLI static event, can be NULL
because there's no object, and if it is non-NULL
indicates an object that is evaluated and discarded
(it won't take part in the overload resolution
used to select the accessor). */
} event_ref;
#endif /* MICROSOFT_EXTENSIONS_ALLOWED */
/* When kind == ok_braced_init_list: */
an_arg_list_elem_ptr
braced_init_list;
/* Pointer to a brace-enclosed list. The entry pointed
to will always be a single entry (not a list)
of type ick_braced, representing a brace-enclosed
list. Note that this kind of operand is used only
in some unusual situations, as most
braced-init-lists are scanned as part of an
expression list and are represented directly
by an_init_component (aka an_arg_list_elem). */
} variant;
} an_operand;
inline void an_operand::copy_from(an_operand const *src)
/*
Shallowly copy the given operand to *this. (For a "deep copy", see
clone_operand.) This function is used by the copy constructor and the
copy assignment operator.
*/
{
/* Copy everything but the variant. */
memcpy((char*)this, (char*)src, offsetof(an_operand, variant));
/* For the variant, only copy the active field. */
switch (src->kind) {
case ok_expression:
this->variant.expression = src->variant.expression;
break;
case ok_constant:
this->variant.constant = src->variant.constant;
break;
#if MICROSOFT_EXTENSIONS_ALLOWED
case ok_property_ref:
this->variant.property_ref = src->variant.property_ref;
break;
case ok_event_ref:
this->variant.event_ref = src->variant.event_ref;
break;
#endif /* MICROSOFT_EXTENSIONS_ALLOWED */
case ok_braced_init_list:
this->variant.braced_init_list = src->variant.braced_init_list;
break;
default:
/* Nothing to do. */
break;
} /* switch */
} /* copy_from */
EXTERN_THREAD an_operand_ptr
*internal_opnd_array;
/* Pointer to an array of operands available when
scanning internal expressions. */
EXTERN_THREAD int
n_internal_opnds;
/* Length of the array pointed to by
internal_opnd_array. */
/*
Entry describing an expression, in a form that can be dynamically allocated
and linked onto a list.
*/
/* The typedef an_arg_operand_ptr is defined in il_def.h. */
typedef struct an_arg_operand {
an_arg_operand_ptr
next; /* Pointer to the next argument, or NULL if this is the
last argument. */
an_operand operand;
/* The argument value. */
} an_arg_operand;
/*
Entry used to attach front-end-only information to an_expr_node (or a_constant
or a_dynamic_init) for use when the expression is rescanned to do semantic
analysis as part of template deduction.
*/
/* The typedef an_expr_rescan_info_entry_ptr is defined in il_def.h. */
typedef struct an_expr_rescan_info_entry {
an_operand saved_operand;
/* A copy of the operand, which contains the position
information and all the extra flags. Not used for
the basic type/expression/constant values. This
must be the first field (relied upon by function
record_cast_position_in_expr_rescan_info). */
an_expression_kind
expression_kind;
/* Kind of expression we are in, e.g., template
argument. */
a_source_position
operator_position;
/* Position of the expression operator, if there is
one; null_source_position otherwise. */
a_token_sequence_number
operator_token_sequence_number;
/* Token sequence number for the operator, if there
is one. NO_TOKEN_SEQUENCE_NUMBER otherwise.
Not set for operators that can't be overloaded. */
a_source_position
secondary_operator_position;
/* Position of a second operator, e.g., the closing
"]" of a subscript or the ":" of a "?" operator.
Also used for the type position for a cast. */
a_type_ptr type;
/* For a cast, the type cast to. For a "new", the
type being allocated. Otherwise, NULL. */
} an_expr_rescan_info_entry;
/*
Copy the source position from an expression operand into an expression node.
*/
#if EXTRA_SOURCE_POSITIONS_IN_IL
#define copy_operand_position_to_expr(operand, node) \
{ (node)->expr_range.start = (operand)->position; \
(node)->expr_range.end = (operand)->end_position; \
(node)->position = (operand)->position; }
#else /* !EXTRA_SOURCE_POSITIONS_IN_IL */
#define copy_operand_position_to_expr(operand, node) \
((node)->position = (operand)->position)
#endif /* EXTRA_SOURCE_POSITIONS_IN_IL */
/*
Copy the source position from one operand into another.
*/
#if EXTRA_SOURCE_POSITIONS_IN_IL
#define copy_operand_position(source_operand, dest_operand) \
{(dest_operand)->position = (source_operand)->position; \
(dest_operand)->end_position = (source_operand)->end_position;}
#else /* !EXTRA_SOURCE_POSITIONS_IN_IL */
#define copy_operand_position(source_operand, dest_operand) \
{(dest_operand)->position = (source_operand)->position;}
#endif /* EXTRA_SOURCE_POSITIONS_IN_IL */
/*
Used to pass addresses of end positions as call arguments. Substitutes
the address of null_source_position in configurations that don't have extra
source positions.
*/
#if EXTRA_SOURCE_POSITIONS_IN_IL
#define end_position_or_null(end_position) (end_position)
#else /* !EXTRA_SOURCE_POSITIONS_IN_IL */
#define end_position_or_null(end_position) (&null_source_position)
#endif /* EXTRA_SOURCE_POSITIONS_IN_IL */
/*
Get the end position address from an operand if there is one, otherwise return
the address of null_source_position.
*/
#define end_position_of_operand(operand) \
end_position_or_null(&(operand)->end_position)
/*
Get the expression node, if any, associated with an operand. A direct
backing expression in a constant operand is given preference over a
template parameter expression if the constant is a ck_template_param
constant. This just fetches an existing expression node, or returns NULL;
it never creates one.
*/
#define expr_node_from_operand(operand) \
(is_expression_operand(operand) ? \
(operand)->variant.expression : \
is_constant_operand(operand) && (operand)->variant.constant.expr != NULL ? \
(operand)->variant.constant.expr : \
is_template_param_expression_constant_operand(operand) ? \
expr_node_from_tpck_expression(&(operand)->variant.constant) : \
NULL)
/*
Return TRUE if we are in a context in which operations, such as
access checking, are required to produce immediate results (and so are
allowed even in deferred access contexts).
*/
#define in_expr_testing_context() \
(scope_stack_top().is_rescan || \
(expr_stack != NULL && expr_stack->suppress_diagnostics))
/*
Bit flags used in calling do_operand_transformations, to suppress
some of the transformations.
*/
#define TOPT_SUPPRESS_FUNCTION_TO_POINTER_CONVERSION 0x1
/* Functions should not be converted implicitly to
pointer-to-function. */
#define TOPT_SUPPRESS_ARRAY_TO_POINTER_CONVERSION 0x2
/* Arrays should not be converted implicitly to
pointer-to-first-element-of-the-array. */
#define TOPT_SUPPRESS_LVALUE_TO_RVALUE_CONVERSION 0x4
/* Suppress conversion of an lvalue to an rvalue.
(Really, a glvalue to a prvalue, but like the
C++11 standard we keep the traditional
terminology.) */
#define TOPT_SUPPRESS_CHECK_FOR_INDEFINITE_FUNCTION 0x8
/* Suppress the check for indefinite functions. */
#define TOPT_WILL_CALL 0x10
/* The operand is the function being called in a
call. */
#define TOPT_SUPPRESS_MEMBER_FUNC_TO_PM_CONVERSION 0x20
/* Member functions should not be converted implicitly
to pointer-to-member. */
#define TOPT_SUPPRESS_RVALUE_PROPERTY_REWRITE 0x40
/* References to class members that are Microsoft
properties should not be rewritten as calls of
the appropriate "get" function (yet). */
#define TOPT_COPY_CLASS_ON_CONV_TO_RVALUE 0x80
/* When converting a C++ class to an rvalue, make
a copy. This is required by the C++ standard, but
it actually applies only in certain unusual
situations, so we leave the default as no copy. */
#define TOPT_NO_OPTIONS 0
typedef int a_transformation_options_set;
extern a_boolean expr_error_should_be_issued(void);
/* Include overload.h after an_operand has been defined to avoid circular
reference problems. */
#ifndef OVERLOAD_H
END_EDG_NAMESPACE /* Conditionally close the "edg" namespace. */
#include "overload.h"
BEGIN_EDG_NAMESPACE /* Conditionally open the "edg" namespace. */
#endif /* ifndef OVERLOAD_H */
/*
Entry used to record information about a dynamic init entry whose
destructor processing could not be completed when the dynamic init entry
was created because the initialization occurs within the return expression
in a routine that returns its value via a copy constructor. The destructor
call on the topmost initialization is optimized away, but there's no way to
know that when it is generated, so all such initializations are placed on
a list and checked at the end of the expression.
*/
typedef struct a_dynamic_init_dtor_fixup *a_dynamic_init_dtor_fixup_ptr;
typedef struct a_dynamic_init_dtor_fixup {
a_dynamic_init_dtor_fixup_ptr
next; /* Next entry on the list. */
a_dynamic_init_ptr
dynamic_init;
/* The dynamic initialization entry to be checked. */
a_source_position
position;
/* The source position for errors. */
} a_dynamic_init_dtor_fixup;
/* an_initializer_cache is in decls.h because of header ordering reasons. */
typedef struct an_initializer_cache an_initializer_cache_dummy_typedef;
EXTERN_THREAD a_routine_ptr
*p_called_nonconstexpr_routine;
/* Pointer to the location where a non-constexpr
routine should be recorded if it is called (when
the flag record_first_nonceonstexpr_call is TRUE
in the expression stack). */
/*
Entry in a stack used during expression processing to record transitions
into substantially disjunct pieces of the expression (e.g., inside a
sizeof is quite different from a normal expression). These entries are
allocated in the stack.
*/
typedef struct an_expr_stack_entry *an_expr_stack_entry_ptr;
typedef struct an_expr_stack_entry {
an_expr_stack_entry_ptr
prev; /* Previous entry on the stack */
a_ref_entry_ptr
old_ref_entries_list;
/* Saved copy of the global reference entries list
at the time of the push of this entry. */
an_expression_kind
expression_kind;
/* The kind of expression. */
a_bit_field
evaluated:1;
/* Expression is evaluated, e.g., FALSE if it's the
operand of a sizeof or in a "dead" part of a
short-circuiting operation. */
a_bit_field
potentially_evaluated:1;
/* Expression is potentially evaluated, e.g., FALSE
if it's the operand of a sizeof. Always TRUE in
a constant expression, even one inside a not-
evaluated expression. */
a_bit_field
potentially_unevaluated:1;
/* Expression may be an unevaluated operand, i.e.,
TRUE for operands of sizeof and similar
operators and for the operand of typeid, which
is evaluated for polymorphic lvalues and
unevaluated for all other operands. Determines
whether an objectless reference to a nonstatic
data member is allowed. */
a_bit_field
objectless_nonstatic_data_ref_seen:1;
/* Initially FALSE, set to TRUE if an objectless
reference to a nonstatic data member occurs in a
context that permits such constructs. */
a_bit_field
potentially_unevaluated_lambda_seen:1;
/* Initially FALSE, set to TRUE if a lambda definition
occurs in a potentially unevaluated context
(e.g., the operand of a typeid). */
a_bit_field
is_type_operator_arg_expression:1;
/* TRUE if the expression is the argument for a C++11
decltype construct, a GNU typeof construct, or an
__underlying_type construct. */
a_bit_field
is_default_arg_expression:1;
/* TRUE if the expression is or is inside of a
C++ default argument expression in a parameter
list. */
a_bit_field
is_initial_default_arg_scan:1;
/* TRUE the first time a default argument expression is
encountered, FALSE on subsequent occurrences. */
#if MICROSOFT_EXTENSIONS_ALLOWED
a_bit_field
is_cli_attr_arg_expression:1;
/* TRUE if the expression is or is inside of a
C++/CLI attribute argument expression. */
#endif /* MICROSOFT_EXTENSIONS_ALLOWED */
a_bit_field
is_template_arg_expression:1;
/* TRUE if the expression is an argument of a C++
template reference. This is TRUE only for the
top level major expression for a template
argument, e.g., it's not TRUE inside a sizeof
inside a template argument. This flag is mainly
about recognizing ">" as a template closing
bracket. */
a_bit_field
is_vla_dimension_expression:1;
/* TRUE if the expression is the dimension of a
VLA (variable-length array). This is TRUE only
for the top level major expression for a VLA
dimension, e.g., it's not TRUE inside a sizeof
inside a VLA dimension. */
a_bit_field
in_cctor_elision_initializer:1;
/* TRUE if the expression is or is inside of an
initializer expression that is subject to
the copy constructor elision optimization,
for example in a return expression in a
routine that returns its value to the caller by
calling a copy constructor. This has an effect
on destructor calls noted in dynamic initialization
entries for temporaries. See
fix_up_dynamic_init_dtors. */
a_bit_field
favor_constant_result:1;
/* TRUE if a constant result should be produced
if possible. Always TRUE if the expression
is a constant expression; sometimes TRUE for
nonconstant expressions (e.g., initializer
expressions, where it helps in discerning static
initialization cases from others). Among other
things, this controls whether constant addressing
expressions should be folded to constants. */
a_bit_field
inside_conditional_expression:1;
/* TRUE if inside a conditional operand of an
operator like "?". */
a_bit_field
unevaluated_expr_will_be_kept_in_il:1;
/* TRUE if the expression will be kept in the IL even
though it is a not-evaluated expression
(specifically, one with potentially_evaluated
set to FALSE). Normally, such expressions are
discarded. */
a_bit_field
template_deduction_context:1;
/* TRUE if we're currently redoing semantic analysis
on an expression as part of template deduction. */
a_bit_field
suppress_diagnostics:1;
/* TRUE if diagnostics should be suppressed in the
current context. This is set when an expression
is rescanned in a template deduction (SFINAE)
context. */
a_bit_field
any_suppressed_error:1;
/* TRUE if any error was detected and suppressed
because suppress_diagnostics is TRUE. Access
errors may or may not set this flag depending on
cpp11_sfinae_ignore_access. */
a_bit_field
possible_rescan_context:1;
/* TRUE if the expression being scanned is in a context
where it might have to be rescanned later, e.g.,
for template deduction. Extra information is saved
that will be needed to redo the semantic analysis
on the expression. Only set when
cpp11_sfinae_enabled is TRUE. */
a_bit_field
in_static_initializer:1;
/* TRUE if we're inside the initializer of an entity
with static storage duration. */
a_bit_field
next_stack_push_considered_same_expression:1;
/* Signal to transfer_expr_context_if_applicable that
the next expression stack push should consider that
we are still in the same expression even if we went
into declaration processing and came back. */
a_bit_field
record_first_nonconstexpr_call:1;
/* TRUE if the first encountered call to a non-
constexpr function should be recorded (in
*p_called_nonconstexpr_routine). */
a_bit_field
constant_expr_ruled_out:1;
/* TRUE if the expression contains something that
rules it out as a constant expression, even
if the expression is not being scanned as a
constant expression. In C++11, this is the
only thing used to track adherence to the
restrictions of constant expressions. In
other modes, the ruled_out_expr_kinds set in
an operand is also maintained. */
a_bit_field
traditional_const_expr_required:1;
/* TRUE if we're in a constant expression to be
processed with the pre-C++11 rules for constant
expressions. Those are (1) disallowed operators,
types, and constructs are flagged as invalid
immediately when they appear, even in unevaluated
subexpressions; (2) each operation/conversion must
immediately fold to a constant result, except when
unevaluated (e.g., 1 || 1/0 is okay). */
a_bit_field
in_noexcept_operand_expression:1;
/* TRUE if we're in the operand of a noexcept
operator. */
a_bit_field
suppress_constexpr_call_folding:1;
/* TRUE to suppress folding of constexpr calls and
constructions. Used for