14559860eSchristos/* Interface between GCC C++ FE and GDB -*- c -*- 24559860eSchristos 3*e663ba6eSchristos Copyright (C) 2014-2024 Free Software Foundation, Inc. 44559860eSchristos 54559860eSchristos This file is part of GCC. 64559860eSchristos 74559860eSchristos This program is free software; you can redistribute it and/or modify 84559860eSchristos it under the terms of the GNU General Public License as published by 94559860eSchristos the Free Software Foundation; either version 3 of the License, or 104559860eSchristos (at your option) any later version. 114559860eSchristos 124559860eSchristos This program is distributed in the hope that it will be useful, 134559860eSchristos but WITHOUT ANY WARRANTY; without even the implied warranty of 144559860eSchristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 154559860eSchristos GNU General Public License for more details. 164559860eSchristos 174559860eSchristos You should have received a copy of the GNU General Public License 184559860eSchristos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 194559860eSchristos 204559860eSchristos 214559860eSchristos 224559860eSchristos/* Push namespace NAME as the current binding level, to which 234559860eSchristos newly-introduced decls will be bound. An empty string identifies 244559860eSchristos the global namespace, whereas NULL identifies an anonymous 254559860eSchristos namespace. A namespace named NAME is created in the current scope, 264559860eSchristos if needed. 274559860eSchristos 284559860eSchristos If the newly-created namespace is to be an inline namespace, see 294559860eSchristos make_namespace_inline. */ 304559860eSchristos 314559860eSchristosGCC_METHOD1 (int /* bool */, push_namespace, 324559860eSchristos const char *) /* Argument NAME. */ 334559860eSchristos 344559860eSchristos/* Push TYPE as the current binding level, making its members visible 354559860eSchristos for name lookup. The current scope before the call must be the 364559860eSchristos scope in which the class was declared. This should be used if the 374559860eSchristos definition of a class is already finished, but one wishes to define 384559860eSchristos a nested class, or to enter the scope of one of its member 394559860eSchristos functions. */ 404559860eSchristos 414559860eSchristosGCC_METHOD1 (int /* bool */, push_class, 424559860eSchristos gcc_type) /* Argument TYPE. */ 434559860eSchristos 444559860eSchristos/* Push FUNCTION_DECL as the current (empty) binding level (see 454559860eSchristos reactivate_decl). The current enclosing scope before the call must 464559860eSchristos be the scope in which the function was declared. */ 474559860eSchristos 484559860eSchristosGCC_METHOD1 (int /* bool */, push_function, 494559860eSchristos gcc_decl) /* Argument FUNCTION_DECL. */ 504559860eSchristos 514559860eSchristos/* Make DECL visible (again?) within SCOPE. When SCOPE is NULL, it 524559860eSchristos means the current scope; if it is not NULL, it must name a function 534559860eSchristos that is currently active, even if not at the top of the binding 544559860eSchristos chain. 554559860eSchristos 564559860eSchristos This function can be used to make e.g. a global function or 574559860eSchristos variable visible in a namespace or local scope (overriding another 584559860eSchristos enclosing definition of the same name), but its most common 594559860eSchristos expected use of this primitive, that gives it its name, is to make 604559860eSchristos declarations visible again after reentering a function scope, 614559860eSchristos because when a function is entered with push_function, that does 624559860eSchristos NOT make any of the declarations nested in it visible for name 634559860eSchristos lookup. 644559860eSchristos 654559860eSchristos There is a reason/excuse for that: unlike namespaces and classes, 664559860eSchristos G++ doesn't ever have to reenter function scopes, so its name 674559860eSchristos resolution infrastructure is not prepared to do that. But wait, 684559860eSchristos there is also a good use for this apparent limitation: a function 694559860eSchristos may contain multiple scopes (blocks), and the name may be bound to 704559860eSchristos different symbols in each of these scopes. With this interface, as 714559860eSchristos we reenter a function scope, we may choose which symbols to make 724559860eSchristos visible for the code snippet, or, if there could be template 734559860eSchristos functions in local scopes, for unresolved names in nested template 744559860eSchristos class default arguments, or in nested template function signatures. 754559860eSchristos 764559860eSchristos As for making a local declaration visible for the code snippet, 774559860eSchristos there are two possibilities: a) introduce it upfront, while 784559860eSchristos entering the scope for the user expression (see the enter_scope 794559860eSchristos callback, called by g++ when encountering the push_user_expression 804559860eSchristos pragma), which might save some scope switching and reactivate_decl 814559860eSchristos (though this can't be helped if some declarations have to be 824559860eSchristos introduced and discarded, because of multiple definitions of the 834559860eSchristos same name in different scopes within a function: they have to be 844559860eSchristos defined in discriminator order); or b) introduce it when its name 854559860eSchristos is looked up, entering the scope, introducing the declaration, 864559860eSchristos leaving the scope, and then reactivating the declaration in its 874559860eSchristos local scope. 884559860eSchristos 894559860eSchristos Here's some more detail on how reactivate_decl works. Say there's 904559860eSchristos a function foo whose body looks like this: 914559860eSchristos 924559860eSchristos { 934559860eSchristos { 944559860eSchristos// point 1 954559860eSchristos class c {} o __attribute__ ((__used__)); // c , o 964559860eSchristos } 974559860eSchristos struct c { 984559860eSchristos void f() { 994559860eSchristos// point 2 1004559860eSchristos } 1014559860eSchristos } o __attribute__ ((__used__)); // c_0, o_0 1024559860eSchristos { 1034559860eSchristos class c {} p __attribute__ ((__used__)); // c_1, p 1044559860eSchristos// point 3 1054559860eSchristos o.f(); 1064559860eSchristos } 1074559860eSchristos } 1084559860eSchristos 1094559860eSchristos When we are about to define class c at point 1, we enter the 1104559860eSchristos function foo scope, and since no symbols are visible at point 1, we 1114559860eSchristos proceed to declare class c. We may then define the class right 1124559860eSchristos away, or, if we leave the function scope, and we later wish to 1134559860eSchristos define it, or to define object o, we can reenter the scope and just 1144559860eSchristos use the previously-obtained gcc_decl to define the class, without 1154559860eSchristos having to reactivate the declaration. 1164559860eSchristos 1174559860eSchristos Now, if we are to set up the binding context for point 2, we have 1184559860eSchristos to define c_0::f, and in order to do so, we have to declare and 1194559860eSchristos define c_0. Before we can declare c_0, we MUST at least declare c. 1204559860eSchristos 1214559860eSchristos As a general rule, before we can declare or define any local name 1224559860eSchristos with a discriminator, we have to at least declare any other 1234559860eSchristos occurrences of the same name in the same enclosing entity with 1244559860eSchristos lower or absent discriminator. 1254559860eSchristos 1264559860eSchristos So, we declare c, then we leave the function scope and reenter it 1274559860eSchristos so as to declare c_0 (also with name "c", which is why we have to 1284559860eSchristos leave and reenter the function scope, otherwise we would get an 1294559860eSchristos error because of the duplicate definition; g++ will assign a 1304559860eSchristos discriminator because it still remembers there was an earlier 1314559860eSchristos declaration of c_0 within the function, it's just no longer in 1324559860eSchristos scope), then we can define c_0, including its member function f. 1334559860eSchristos 1344559860eSchristos Likewise, if we wish to define o_0, we have to define o first. If 1354559860eSchristos we wish to declare (and maybe then define) c_1, we have to at least 1364559860eSchristos declare (c and then) c_0 first. 1374559860eSchristos 1384559860eSchristos Then, as we set up the binding context to compile a code snippet at 1394559860eSchristos point 3, we may choose to activate c_1, o_0 and p upfront, 1404559860eSchristos declaring and discarding c, c_0 and o, and then reentering the 1414559860eSchristos funciton scope to declare c_1, o_0 and p; or we can wait for oracle 1424559860eSchristos lookups of c, o or p. If c is looked up, and the debugger resolves 1434559860eSchristos c in the scope to c_1, it is expected to enter the function scope 1444559860eSchristos from the top level, declare c, leave it, reenter it, declare c_0, 1454559860eSchristos leave it, reenter it, declare c_1, leave it, and then reactivate 1464559860eSchristos c_1 in the function scope. If c_1 is needed as a complete type, 1474559860eSchristos the definition may be given right after the declaration, or the 1484559860eSchristos scope will have to be reentered in order to define the class. 1494559860eSchristos 1504559860eSchristos. If the code snippet is at point 2, we don't need to (re)activate 1514559860eSchristos any declaration: nothing from any local scope is visible. Just 1524559860eSchristos entering the scope of the class containing member function f 1534559860eSchristos reactivates the names of its members, including the class name 1544559860eSchristos itself. */ 1554559860eSchristos 1564559860eSchristosGCC_METHOD2 (int /* bool */, reactivate_decl, 1574559860eSchristos gcc_decl, /* Argument DECL. */ 1584559860eSchristos gcc_decl) /* Argument SCOPE. */ 1594559860eSchristos 1604559860eSchristos/* Pop the namespace last entered with push_namespace, or class last 1614559860eSchristos entered with push_class, or function last entered with 1624559860eSchristos push_function, restoring the binding level in effect before the 1634559860eSchristos matching push_* call. */ 1644559860eSchristos 1654559860eSchristosGCC_METHOD0 (int /* bool */, pop_binding_level) 1664559860eSchristos 1674559860eSchristos/* Return the NAMESPACE_DECL, TYPE_DECL or FUNCTION_DECL of the 1684559860eSchristos binding level that would be popped by pop_scope. */ 1694559860eSchristos 1704559860eSchristosGCC_METHOD0 (gcc_decl, get_current_binding_level_decl) 1714559860eSchristos 1724559860eSchristos/* Make the current binding level an inline namespace. It must be a 1734559860eSchristos namespace to begin with. It is safe to call this more than once 1744559860eSchristos for the same namespace, but after the first call, subsequent ones 1754559860eSchristos will not return a success status. */ 1764559860eSchristos 1774559860eSchristosGCC_METHOD0 (int /* bool */, make_namespace_inline) 1784559860eSchristos 1794559860eSchristos/* Add USED_NS to the namespaces used by the current binding level. 1804559860eSchristos Use get_current_binding_level_decl to obtain USED_NS's 1814559860eSchristos gcc_decl. */ 1824559860eSchristos 1834559860eSchristosGCC_METHOD1 (int /* bool */, add_using_namespace, 1844559860eSchristos gcc_decl) /* Argument USED_NS. */ 1854559860eSchristos 1864559860eSchristos/* Introduce a namespace alias declaration, as in: 1874559860eSchristos 1884559860eSchristos namespace foo = [... ::] bar; 1894559860eSchristos 1904559860eSchristos After this call, namespace TARGET will be visible as ALIAS within 1914559860eSchristos the current namespace. Get the declaration for TARGET by calling 1924559860eSchristos get_current_binding_level_decl after pushing into it. */ 1934559860eSchristos 1944559860eSchristosGCC_METHOD2 (int /* bool */, add_namespace_alias, 1954559860eSchristos const char *, /* Argument ALIAS. */ 1964559860eSchristos gcc_decl) /* Argument TARGET. */ 1974559860eSchristos 1984559860eSchristos/* Introduce a using declaration, as in: 1994559860eSchristos 2004559860eSchristos using foo::bar; 2014559860eSchristos 2024559860eSchristos The TARGET decl names the qualifying scope (foo:: above) and the 2034559860eSchristos identifier (bar), but that does not mean that only TARGET will be 2044559860eSchristos brought into the current scope: all bindings of TARGET's identifier 2054559860eSchristos in the qualifying scope will be brought in. 2064559860eSchristos 2074559860eSchristos FLAGS should specify GCC_CP_SYMBOL_USING. If the current scope is 2084559860eSchristos a class scope, visibility flags must be supplied. 2094559860eSchristos 2104559860eSchristos Even when TARGET is template dependent, we don't need to specify 2114559860eSchristos whether or not it is a typename: the supplied declaration (that 2124559860eSchristos could be a template-dependent type converted to declaration by 2134559860eSchristos get_type_decl) indicates so. */ 2144559860eSchristos 2154559860eSchristosGCC_METHOD2 (int /* bool */, add_using_decl, 2164559860eSchristos enum gcc_cp_symbol_kind, /* Argument FLAGS. */ 2174559860eSchristos gcc_decl) /* Argument TARGET. */ 2184559860eSchristos 2194559860eSchristos/* Create a new "decl" in GCC, and bind it in the current binding 2204559860eSchristos level. A decl is a declaration, basically a kind of symbol. 2214559860eSchristos 2224559860eSchristos NAME is the name of the new symbol. SYM_KIND is the kind of 2234559860eSchristos symbol being requested. SYM_TYPE is the new symbol's C++ type; 2244559860eSchristos except for labels, where this is not meaningful and should be 2254559860eSchristos zero. If SUBSTITUTION_NAME is not NULL, then a reference to this 2264559860eSchristos decl in the source will later be substituted with a dereference 2274559860eSchristos of a variable of the given name. Otherwise, for symbols having 2284559860eSchristos an address (e.g., functions), ADDRESS is the address. FILENAME 2294559860eSchristos and LINE_NUMBER refer to the symbol's source location. If this 2304559860eSchristos is not known, FILENAME can be NULL and LINE_NUMBER can be 0. 2314559860eSchristos This function returns the new decl. 2324559860eSchristos 2334559860eSchristos Use this function to register typedefs, functions and variables to 2344559860eSchristos namespace and local binding levels, and typedefs, member functions 2354559860eSchristos (static or not), and static data members to class binding levels. 2364559860eSchristos Class members must have their access controls specified with 2374559860eSchristos GCC_CP_ACCESS_* flags in SYM_KIND. 2384559860eSchristos 2394559860eSchristos Note that, since access controls are disabled, we have no means to 2404559860eSchristos express private, protected and public. 2414559860eSchristos 2424559860eSchristos There are various flags that can be set in SYM_KIND to specify 2434559860eSchristos additional semantics. Look for GCC_CP_FLAGs in the definition of 2444559860eSchristos enum gcc_cp_symbol_kind in gcc-cp-interface.h. 2454559860eSchristos 2464559860eSchristos In order to define member functions, pass GCC_CP_SYMBOL_FUNCTION in 2474559860eSchristos SYM_KIND, and a function_type for static member functions or a 2484559860eSchristos method type for non-static member functions, including constructors 2494559860eSchristos and destructors. Use build_function_type to create a function 2504559860eSchristos type; for a method type, start by creating a function type without 2514559860eSchristos any compiler-introduced artificial arguments (the implicit this 2524559860eSchristos pointer, and the __in_chrg added to constructors and destructors, 2534559860eSchristos and __vtt_parm added to the former), and then use build_method_type 2544559860eSchristos to create the method type out of the class type and the function 2554559860eSchristos type. 2564559860eSchristos 2574559860eSchristos For operator functions, set GCC_CP_FLAG_SPECIAL_FUNCTION in 2584559860eSchristos SYM_KIND, in addition to any other applicable flags, and pass as 2594559860eSchristos NAME a string starting with the two-character mangling for operator 2604559860eSchristos name: "ps" for unary plus, "mL" for multiply and assign, *=; etc. 2614559860eSchristos Use "cv" for type converstion operators (the target type portion 2624559860eSchristos may be omitted, as it is taken from the return type in SYM_TYPE). 2634559860eSchristos For operator"", use "li" followed by the identifier (the mangled 2644559860eSchristos name mandates digits specifying the length of the identifier; if 2654559860eSchristos present, they determine the end of the identifier, otherwise, the 2664559860eSchristos identifier extents to the end of the string, so that "li3_Kme" and 2674559860eSchristos "li_Km" are equivalent). 2684559860eSchristos 2694559860eSchristos Constructors and destructors need special care, because for each 2704559860eSchristos constructor and destructor there may be multiple clones defined 2714559860eSchristos internally by the compiler. With build_decl, you can introduce the 2724559860eSchristos base declaration of a constructor or a destructor, setting 2734559860eSchristos GCC_CP_FLAG_SPECIAL_FUNCTION the flag and using names starting with 2744559860eSchristos capital "C" or "D", respectively, followed by a digit (see below), 2754559860eSchristos a blank, or NUL ('\0'). DO NOT supply an ADDRESS or a 2764559860eSchristos SUBSTITUTION_NAME to build_decl, it would be meaningless (and 2774559860eSchristos rejected) for the base declaration; use define_cdtor_clone to 2784559860eSchristos introduce the address of each clone. For constructor templates, 2794559860eSchristos declare the template with build_decl, and then, for each 2804559860eSchristos specialization, introduce it with 2814559860eSchristos build_function_template_specialization, and then define the 2824559860eSchristos addresses of each of its clones with define_cdtor_clone. 2834559860eSchristos 2844559860eSchristos NAMEs for GCC_CP_FLAG_SPECIAL_FUNCTION: 2854559860eSchristos 2864559860eSchristos NAME meaning 2874559860eSchristos C? constructor base declaration (? may be 1, 2, 4, blank or NUL) 2884559860eSchristos D? destructor base declaration (? may be 0, 1, 2, 4, blank or NUL) 2894559860eSchristos nw operator new 2904559860eSchristos na operator new[] 2914559860eSchristos dl operator delete 2924559860eSchristos da operator delete[] 2934559860eSchristos ps operator + (unary) 2944559860eSchristos ng operator - (unary) 2954559860eSchristos ad operator & (unary) 2964559860eSchristos de operator * (unary) 2974559860eSchristos co operator ~ 2984559860eSchristos pl operator + 2994559860eSchristos mi operator - 3004559860eSchristos ml operator * 3014559860eSchristos dv operator / 3024559860eSchristos rm operator % 3034559860eSchristos an operator & 3044559860eSchristos or operator | 3054559860eSchristos eo operator ^ 3064559860eSchristos aS operator = 3074559860eSchristos pL operator += 3084559860eSchristos mI operator -= 3094559860eSchristos mL operator *= 3104559860eSchristos dV operator /= 3114559860eSchristos rM operator %= 3124559860eSchristos aN operator &= 3134559860eSchristos oR operator |= 3144559860eSchristos eO operator ^= 3154559860eSchristos ls operator << 3164559860eSchristos rs operator >> 3174559860eSchristos lS operator <<= 3184559860eSchristos rS operator >>= 3194559860eSchristos eq operator == 3204559860eSchristos ne operator != 3214559860eSchristos lt operator < 3224559860eSchristos gt operator > 3234559860eSchristos le operator <= 3244559860eSchristos ge operator >= 3254559860eSchristos nt operator ! 3264559860eSchristos aa operator && 3274559860eSchristos oo operator || 3284559860eSchristos pp operator ++ 3294559860eSchristos mm operator -- 3304559860eSchristos cm operator , 3314559860eSchristos pm operator ->* 3324559860eSchristos pt operator -> 3334559860eSchristos cl operator () 3344559860eSchristos ix operator [] 3354559860eSchristos qu operator ? 3364559860eSchristos cv operator <T> (conversion operator) 3374559860eSchristos li<id> operator "" <id> 3384559860eSchristos 3394559860eSchristos FIXME: How about attributes? */ 3404559860eSchristos 3414559860eSchristosGCC_METHOD7 (gcc_decl, build_decl, 3424559860eSchristos const char *, /* Argument NAME. */ 3434559860eSchristos enum gcc_cp_symbol_kind, /* Argument SYM_KIND. */ 3444559860eSchristos gcc_type, /* Argument SYM_TYPE. */ 3454559860eSchristos const char *, /* Argument SUBSTITUTION_NAME. */ 3464559860eSchristos gcc_address, /* Argument ADDRESS. */ 3474559860eSchristos const char *, /* Argument FILENAME. */ 3484559860eSchristos unsigned int) /* Argument LINE_NUMBER. */ 3494559860eSchristos 3504559860eSchristos/* Supply the ADDRESS of one of the multiple clones of constructor or 3514559860eSchristos destructor CDTOR. The clone is specified by NAME, using the 3524559860eSchristos following name mangling conventions: 3534559860eSchristos 3544559860eSchristos C1 in-charge constructor 3554559860eSchristos C2 not-in-charge constructor 3564559860eSchristos C4 unified constructor 3574559860eSchristos D0 deleting destructor 3584559860eSchristos D1 in-charge destructor 3594559860eSchristos D2 not-in-charge destructor 3604559860eSchristos D4 unified destructor 3614559860eSchristos 3624559860eSchristos The following information is not necessary to use the API. 3634559860eSchristos 3644559860eSchristos C1 initializes an instance of the class (rather than of derived 3654559860eSchristos classes), including virtual base classes, whereas C2 initializes a 3664559860eSchristos sub-object (of the given class type) of an instance of some derived 3674559860eSchristos class (or a full object that doesn't have any virtual base 3684559860eSchristos classes). 3694559860eSchristos 3704559860eSchristos D0 and D1 destruct an instance of the class, including virtual base 3714559860eSchristos classes, but only the former calls operator delete to release the 3724559860eSchristos object's storage at the end; D2 destructs a sub-object (of the 3734559860eSchristos given class type) of an instance of a derived class (or a full 3744559860eSchristos object that doesn't have any virtual base classes). 3754559860eSchristos 3764559860eSchristos The [CD]4 manglings (and symbol definitions) are non-standard, but 3774559860eSchristos GCC uses them in some cases: rather than assuming they are 3784559860eSchristos in-charge or not-in-charge, they test the implicit argument that 3794559860eSchristos the others ignore to tell how to behave. These are used instead of 3804559860eSchristos cloning when we just can't use aliases. */ 3814559860eSchristos 3824559860eSchristosGCC_METHOD3 (gcc_decl, define_cdtor_clone, 3834559860eSchristos const char *, /* Argument NAME. */ 3844559860eSchristos gcc_decl, /* Argument CDTOR. */ 3854559860eSchristos gcc_address) /* Argument ADDRESS. */ 3864559860eSchristos 3874559860eSchristos/* Return the type associated with the given declaration. This is 3884559860eSchristos most useful to obtain the type associated with a forward-declared 3894559860eSchristos class, because it is the gcc_type, rather than the gcc_decl, that 3904559860eSchristos has to be used to build other types, but build_decl returns a 3914559860eSchristos gcc_decl rather than a gcc_type. This call can in theory be used 3924559860eSchristos to obtain the type from any other declaration; it is supposed to 3934559860eSchristos return the same type that was supplied when the declaration was 3944559860eSchristos created. */ 3954559860eSchristos 3964559860eSchristosGCC_METHOD1 (gcc_type, get_decl_type, 3974559860eSchristos gcc_decl) /* Argument DECL. */ 3984559860eSchristos 3994559860eSchristos/* Return the declaration for a type. */ 4004559860eSchristos 4014559860eSchristosGCC_METHOD1 (gcc_decl, get_type_decl, 4024559860eSchristos gcc_type) /* Argument TYPE. */ 4034559860eSchristos 4044559860eSchristos/* Declare DECL as a friend of the current class scope, if TYPE is 4054559860eSchristos NULL, or of TYPE itself otherwise. DECL may be a function or a 4064559860eSchristos class, be they template generics, template specializations or not 4074559860eSchristos templates. TYPE must be a class type (not a template generic). 4084559860eSchristos 4094559860eSchristos The add_friend call cannot introduce a declaration; even if the 4104559860eSchristos friend is first declared as a friend in the source code, the 4114559860eSchristos declaration belongs in the enclosing namespace, so it must be 4124559860eSchristos introduced in that namespace, and the resulting declaration can 4134559860eSchristos then be made a friend. 4144559860eSchristos 4154559860eSchristos DECL cannot, however, be a member of a template class generic, 4164559860eSchristos because we have no means to introduce their declarations. This 4174559860eSchristos interface has no notion of definitions for template generics. As a 4184559860eSchristos consequence, users of this interface must introduce each friend 4194559860eSchristos template member specialization separately, i.e., instead of: 4204559860eSchristos 4214559860eSchristos template <typename T> friend struct X<T>::M; 4224559860eSchristos 4234559860eSchristos they must be declared as if they were: 4244559860eSchristos 4254559860eSchristos friend struct X<onetype>::M; 4264559860eSchristos friend struct X<anothertype>::M; 4274559860eSchristos ... for each specialization of X. 4284559860eSchristos 4294559860eSchristos 4304559860eSchristos Specializations of a template can have each others' members as 4314559860eSchristos friends: 4324559860eSchristos 4334559860eSchristos template <typename T> class foo { 4344559860eSchristos int f(); 4354559860eSchristos template <typename U> friend int foo<U>::f(); 4364559860eSchristos }; 4374559860eSchristos 4384559860eSchristos It wouldn't always be possible to define all specializations of a 4394559860eSchristos template class before introducing the friend declarations in their 4404559860eSchristos expanded, per-specialization form. 4414559860eSchristos 4424559860eSchristos In order to simplify such friend declarations, and to enable 4434559860eSchristos incremental friend declarations as template specializations are 4444559860eSchristos introduced, add_friend can be called after the befriending class is 4454559860eSchristos fully defined, passing it a non-NULL TYPE argument naming the 4464559860eSchristos befriending class type. */ 4474559860eSchristos 4484559860eSchristosGCC_METHOD2 (int /* bool */, add_friend, 4494559860eSchristos gcc_decl, /* Argument DECL. */ 4504559860eSchristos gcc_type) /* Argument TYPE. */ 4514559860eSchristos 4524559860eSchristos/* Return the type of a pointer to a given base type. */ 4534559860eSchristos 4544559860eSchristosGCC_METHOD1 (gcc_type, build_pointer_type, 4554559860eSchristos gcc_type) /* Argument BASE_TYPE. */ 4564559860eSchristos 4574559860eSchristos/* Return the type of a reference to a given base type. */ 4584559860eSchristos 4594559860eSchristosGCC_METHOD2 (gcc_type, build_reference_type, 4604559860eSchristos gcc_type, /* Argument BASE_TYPE. */ 4614559860eSchristos enum gcc_cp_ref_qualifiers) /* Argument RQUALS. */ 4624559860eSchristos 4634559860eSchristos/* Create a new pointer-to-member type. MEMBER_TYPE is the data 4644559860eSchristos member type, while CLASS_TYPE is the class type containing the data 4654559860eSchristos member. For pointers to member functions, MEMBER_TYPE must be a 4664559860eSchristos method type, and CLASS_TYPE must be specified even though it might 4674559860eSchristos be possible to extract it from the method type. */ 4684559860eSchristos 4694559860eSchristosGCC_METHOD2 (gcc_type, build_pointer_to_member_type, 4704559860eSchristos gcc_type, /* Argument CLASS_TYPE. */ 4714559860eSchristos gcc_type) /* Argument MEMBER_TYPE. */ 4724559860eSchristos 4734559860eSchristos/* Start a template parameter list scope and enters it, so that 4744559860eSchristos subsequent build_type_template_parameter and 4754559860eSchristos build_value_template_parameter calls create template parameters in 4764559860eSchristos the list. The list is closed by a build_decl call with 4774559860eSchristos GCC_CP_SYMBOL_FUNCTION or GCC_CP_SYMBOL_CLASS, that, when the scope 4784559860eSchristos is a template parameter list, declares a template function or a 4794559860eSchristos template class with the then-closed parameter list. The scope in 4804559860eSchristos which the new declaration is to be introduced by build_decl must be 4814559860eSchristos entered before calling start_template_decl, and build_decl returns 4824559860eSchristos to that scope, from the template parameter list scope, before 4834559860eSchristos introducing the declaration. */ 4844559860eSchristos 4854559860eSchristosGCC_METHOD0 (int /* bool */, start_template_decl) 4864559860eSchristos 4874559860eSchristos/* Build a typename template-parameter (e.g., the T in template 4884559860eSchristos <typename T = X>). Either PACK_P should be nonzero, to indicate an 4894559860eSchristos argument pack (the last argument in a variadic template argument 4904559860eSchristos list, as in template <typename... T>), or DEFAULT_TYPE may be 4914559860eSchristos non-NULL to set the default type argument (e.g. X) for the template 4924559860eSchristos parameter. FILENAME and LINE_NUMBER may specify the source 4934559860eSchristos location in which the template parameter was declared. */ 4944559860eSchristos 4954559860eSchristosGCC_METHOD5 (gcc_type, build_type_template_parameter, 4964559860eSchristos const char *, /* Argument ID. */ 4974559860eSchristos int /* bool */, /* Argument PACK_P. */ 4984559860eSchristos gcc_type, /* Argument DEFAULT_TYPE. */ 4994559860eSchristos const char *, /* Argument FILENAME. */ 5004559860eSchristos unsigned int) /* Argument LINE_NUMBER. */ 5014559860eSchristos 5024559860eSchristos/* Build a template template-parameter (e.g., the T in template 5034559860eSchristos <template <[...]> class T = X>). DEFAULT_TEMPL may be non-NULL to 5044559860eSchristos set the default type-template argument (e.g. X) for the template 5054559860eSchristos template parameter. FILENAME and LINE_NUMBER may specify the 5064559860eSchristos source location in which the template parameter was declared. */ 5074559860eSchristos 5084559860eSchristosGCC_METHOD5 (gcc_utempl, build_template_template_parameter, 5094559860eSchristos const char *, /* Argument ID. */ 5104559860eSchristos int /* bool */, /* Argument PACK_P. */ 5114559860eSchristos gcc_utempl, /* Argument DEFAULT_TEMPL. */ 5124559860eSchristos const char *, /* Argument FILENAME. */ 5134559860eSchristos unsigned int) /* Argument LINE_NUMBER. */ 5144559860eSchristos 5154559860eSchristos/* Build a value template-parameter (e.g., the V in template <typename 5164559860eSchristos T, T V> or in template <int V = X>). DEFAULT_VALUE may be non-NULL 5174559860eSchristos to set the default value argument for the template parameter (e.g., 5184559860eSchristos X). FILENAME and LINE_NUMBER may specify the source location in 5194559860eSchristos which the template parameter was declared. */ 5204559860eSchristos 5214559860eSchristosGCC_METHOD5 (gcc_decl, build_value_template_parameter, 5224559860eSchristos gcc_type, /* Argument TYPE. */ 5234559860eSchristos const char *, /* Argument ID. */ 5244559860eSchristos gcc_expr, /* Argument DEFAULT_VALUE. */ 5254559860eSchristos const char *, /* Argument FILENAME. */ 5264559860eSchristos unsigned int) /* Argument LINE_NUMBER. */ 5274559860eSchristos 5284559860eSchristos/* Build a template-dependent typename (e.g., typename T::bar or 5294559860eSchristos typename T::template bart<X>). ENCLOSING_TYPE should be the 5304559860eSchristos template-dependent nested name specifier (e.g., T), ID should be 5314559860eSchristos the name of the member of the ENCLOSING_TYPE (e.g., bar or bart), 5324559860eSchristos and TARGS should be non-NULL and specify the template arguments 5334559860eSchristos (e.g. <X>) iff ID is to name a class template. 5344559860eSchristos 5354559860eSchristos In this and other calls, a template-dependent nested name specifier 5364559860eSchristos may be a template class parameter (build_type_template_parameter), 5374559860eSchristos a specialization (returned by build_dependent_type_template_id) of 5384559860eSchristos a template template parameter (returned by 5394559860eSchristos build_template_template_parameter) or a member type thereof 5404559860eSchristos (returned by build_dependent_typename itself). */ 5414559860eSchristos 5424559860eSchristosGCC_METHOD3 (gcc_type, build_dependent_typename, 5434559860eSchristos gcc_type, /* Argument ENCLOSING_TYPE. */ 5444559860eSchristos const char *, /* Argument ID. */ 5454559860eSchristos const struct gcc_cp_template_args *) /* Argument TARGS. */ 5464559860eSchristos 5474559860eSchristos/* Build a template-dependent class template (e.g., T::template bart). 5484559860eSchristos ENCLOSING_TYPE should be the template-dependent nested name 5494559860eSchristos specifier (e.g., T), ID should be the name of the class template 5504559860eSchristos member of the ENCLOSING_TYPE (e.g., bart). */ 5514559860eSchristos 5524559860eSchristosGCC_METHOD2 (gcc_utempl, build_dependent_class_template, 5534559860eSchristos gcc_type, /* Argument ENCLOSING_TYPE. */ 5544559860eSchristos const char *) /* Argument ID. */ 5554559860eSchristos 5564559860eSchristos/* Build a template-dependent type template-id (e.g., T<A>). 5574559860eSchristos TEMPLATE_DECL should be a template template parameter (e.g., the T 5584559860eSchristos in template <template <[...]> class T = X>), and TARGS should 5594559860eSchristos specify the template arguments (e.g. <A>). */ 5604559860eSchristos 5614559860eSchristosGCC_METHOD2 (gcc_type, build_dependent_type_template_id, 5624559860eSchristos gcc_utempl, /* Argument TEMPLATE_DECL. */ 5634559860eSchristos const struct gcc_cp_template_args *) /* Argument TARGS. */ 5644559860eSchristos 5654559860eSchristos/* Build a template-dependent expression (e.g., S::val or S::template 5664559860eSchristos mtf<X>, or unqualified f or template tf<X>). 5674559860eSchristos 5684559860eSchristos ENCLOSING_SCOPE should be a template-dependent nested name 5694559860eSchristos specifier (e.g., T), a resolved namespace or class decl, or NULL 5704559860eSchristos for unqualified names; ID should be the name of the member of the 5714559860eSchristos ENCLOSING_SCOPE (e.g., val or mtf) or unqualified overloaded 5724559860eSchristos function; and TARGS should list template arguments (e.g. <X>) when 5734559860eSchristos mtf or tf are to name a template function, or be NULL otherwise. 5744559860eSchristos 5754559860eSchristos Unqualified names and namespace- or class-qualified names can only 5764559860eSchristos resolve to overloaded functions, to be used in contexts that 5774559860eSchristos involve overload resolution that cannot be resolved because of 5784559860eSchristos template-dependent argument or return types, such as call 5794559860eSchristos expressions with template-dependent arguments, conversion 5804559860eSchristos expressions to function types with template-dependent argument 5814559860eSchristos types or the like. Other cases of unqualified or 5824559860eSchristos non-template-dependent-qualified names should NOT use this 5834559860eSchristos function, and use decl_expr to convert the appropriate function or 5844559860eSchristos object declaration to an expression. 5854559860eSchristos 5864559860eSchristos If ID is the name of a special member function, FLAGS should be 5874559860eSchristos GCC_CP_SYMBOL_FUNCTION|GCC_CP_FLAG_SPECIAL_FUNCTION, and ID should 5884559860eSchristos be one of the encodings for special member functions documented in 5894559860eSchristos build_decl. Otherwise, FLAGS should be GCC_CP_SYMBOL_MASK, which 5904559860eSchristos suggests the symbol kind is not known (though we know it is not a 5914559860eSchristos type). 5924559860eSchristos 5934559860eSchristos If ID denotes a conversion operator, CONV_TYPE should name the 5944559860eSchristos target type of the conversion. Otherwise, CONV_TYPE must be 5954559860eSchristos NULL. */ 5964559860eSchristos 5974559860eSchristosGCC_METHOD5 (gcc_expr, build_dependent_expr, 5984559860eSchristos gcc_decl, /* Argument ENCLOSING_SCOPE. */ 5994559860eSchristos enum gcc_cp_symbol_kind, /* Argument FLAGS. */ 6004559860eSchristos const char *, /* Argument NAME. */ 6014559860eSchristos gcc_type, /* Argument CONV_TYPE. */ 6024559860eSchristos const struct gcc_cp_template_args *) /* Argument TARGS. */ 6034559860eSchristos 6044559860eSchristos/* Build a gcc_expr for the value VALUE in type TYPE. */ 6054559860eSchristos 6064559860eSchristosGCC_METHOD2 (gcc_expr, build_literal_expr, 6074559860eSchristos gcc_type, /* Argument TYPE. */ 6084559860eSchristos unsigned long) /* Argument VALUE. */ 6094559860eSchristos 6104559860eSchristos/* Build a gcc_expr that denotes DECL, the declaration of a variable 6114559860eSchristos or function in namespace scope, or of a static member variable or 6124559860eSchristos function. Use QUALIFIED_P to build the operand of unary & so as to 6134559860eSchristos compute a pointer-to-member, rather than a regular pointer. */ 6144559860eSchristos 6154559860eSchristosGCC_METHOD2 (gcc_expr, build_decl_expr, 6164559860eSchristos gcc_decl, /* Argument DECL. */ 6174559860eSchristos int /* bool */) /* Argument QUALIFIED_P. */ 6184559860eSchristos 6194559860eSchristos/* Build a gcc_expr that denotes the unary operation UNARY_OP applied 6204559860eSchristos to the gcc_expr OPERAND. For non-expr operands, see 6214559860eSchristos unary_type_expr. Besides the UNARY_OP encodings used for operator 6224559860eSchristos names, we support "pp_" for preincrement, and "mm_" for 6234559860eSchristos predecrement, "nx" for noexcept, "tw" for throw, "tr" for rethrow 6244559860eSchristos (pass NULL as the operand), "te" for typeid, "sz" for sizeof, "az" 6254559860eSchristos for alignof, "dl" for delete, "gsdl" for ::delete, "da" for 6264559860eSchristos delete[], "gsda" for ::delete[], "sp" for pack expansion, "sZ" for 6274559860eSchristos sizeof...(function argument pack). */ 6284559860eSchristos 6294559860eSchristosGCC_METHOD2 (gcc_expr, build_unary_expr, 6304559860eSchristos const char *, /* Argument UNARY_OP. */ 6314559860eSchristos gcc_expr) /* Argument OPERAND. */ 6324559860eSchristos 6334559860eSchristos/* Build a gcc_expr that denotes the binary operation BINARY_OP 6344559860eSchristos applied to gcc_exprs OPERAND1 and OPERAND2. Besides the BINARY_OP 6354559860eSchristos encodings used for operator names, we support "ds" for the operator 6364559860eSchristos token ".*" and "dt" for the operator token ".". When using 6374559860eSchristos operators that take a name as their second operand ("." and "->") 6384559860eSchristos use decl_expr to convert the gcc_decl of the member name to a 6394559860eSchristos gcc_expr, if the member name wasn't created with 6404559860eSchristos e.g. build_dependent_expr. */ 6414559860eSchristos 6424559860eSchristosGCC_METHOD3 (gcc_expr, build_binary_expr, 6434559860eSchristos const char *, /* Argument BINARY_OP. */ 6444559860eSchristos gcc_expr, /* Argument OPERAND1. */ 6454559860eSchristos gcc_expr) /* Argument OPERAND2. */ 6464559860eSchristos 6474559860eSchristos/* Build a gcc_expr that denotes the ternary operation TERNARY_OP 6484559860eSchristos applied to gcc_exprs OPERAND1, OPERAND2 and OPERAND3. The only 6494559860eSchristos supported TERNARY_OP is "qu", for the "?:" operator. */ 6504559860eSchristos 6514559860eSchristosGCC_METHOD4 (gcc_expr, build_ternary_expr, 6524559860eSchristos const char *, /* Argument TERNARY_OP. */ 6534559860eSchristos gcc_expr, /* Argument OPERAND1. */ 6544559860eSchristos gcc_expr, /* Argument OPERAND2. */ 6554559860eSchristos gcc_expr) /* Argument OPERAND3. */ 6564559860eSchristos 6574559860eSchristos/* Build a gcc_expr that denotes the unary operation UNARY_OP applied 6584559860eSchristos to the gcc_type OPERAND. Supported unary operations taking types 6594559860eSchristos are "ti" for typeid, "st" for sizeof, "at" for alignof, and "sZ" 6604559860eSchristos for sizeof...(template argument pack). */ 6614559860eSchristos 6624559860eSchristosGCC_METHOD2 (gcc_expr, build_unary_type_expr, 6634559860eSchristos const char *, /* Argument UNARY_OP. */ 6644559860eSchristos gcc_type) /* Argument OPERAND. */ 6654559860eSchristos 6664559860eSchristos/* Build a gcc_expr that denotes the binary operation BINARY_OP 6674559860eSchristos applied to gcc_type OPERAND1 and gcc_expr OPERAND2. Use this for 6684559860eSchristos all kinds of (single-argument) type casts ("dc", "sc", "cc", "rc" 6694559860eSchristos for dynamic, static, const and reinterpret casts, respectively; 6704559860eSchristos "cv" for functional or C-style casts). */ 6714559860eSchristos 6724559860eSchristosGCC_METHOD3 (gcc_expr, build_cast_expr, 6734559860eSchristos const char *, /* Argument BINARY_OP. */ 6744559860eSchristos gcc_type, /* Argument OPERAND1. */ 6754559860eSchristos gcc_expr) /* Argument OPERAND2. */ 6764559860eSchristos 6774559860eSchristos/* Build a gcc_expr that denotes the conversion of an expression list 6784559860eSchristos VALUES to TYPE, with ("tl") or without ("cv") braces, or a braced 6794559860eSchristos initializer list of unspecified type (e.g., a component of another 6804559860eSchristos braced initializer list; pass "il" for CONV_OP, and NULL for 6814559860eSchristos TYPE). */ 6824559860eSchristos 6834559860eSchristosGCC_METHOD3 (gcc_expr, build_expression_list_expr, 6844559860eSchristos const char *, /* Argument CONV_OP. */ 6854559860eSchristos gcc_type, /* Argument TYPE. */ 6864559860eSchristos const struct gcc_cp_function_args *) /* Argument VALUES. */ 6874559860eSchristos 6884559860eSchristos/* Build a gcc_expr that denotes a new ("nw") or new[] ("na") 6894559860eSchristos expression of TYPE, with or without a GLOBAL_NS qualifier (prefix 6904559860eSchristos the NEW_OP with "gs"), with or without PLACEMENT, with or without 6914559860eSchristos INITIALIZER. If it's not a placement new, PLACEMENT must be NULL 6924559860eSchristos (rather than a zero-length placement arg list). If there's no 6934559860eSchristos specified initializer, INITIALIZER must be NULL; a zero-length arg 6944559860eSchristos list stands for a default initializer. */ 6954559860eSchristos 6964559860eSchristosGCC_METHOD4 (gcc_expr, build_new_expr, 6974559860eSchristos const char *, /* Argument NEW_OP. */ 6984559860eSchristos const struct gcc_cp_function_args *, /* Argument PLACEMENT. */ 6994559860eSchristos gcc_type, /* Argument TYPE. */ 7004559860eSchristos const struct gcc_cp_function_args *) /* Argument INITIALIZER. */ 7014559860eSchristos 7024559860eSchristos/* Return a call expression that calls CALLABLE with arguments ARGS. 7034559860eSchristos CALLABLE may be a function, a callable object, a pointer to 7044559860eSchristos function, an unresolved expression, an unresolved overload set, an 7054559860eSchristos object expression combined with a member function overload set or a 7064559860eSchristos pointer-to-member. If QUALIFIED_P, CALLABLE will be interpreted as 7074559860eSchristos a qualified name, preventing virtual function dispatch. */ 7084559860eSchristos 7094559860eSchristosGCC_METHOD3 (gcc_expr, build_call_expr, 7104559860eSchristos gcc_expr, /* Argument CALLABLE. */ 7114559860eSchristos int /* bool */, /* Argument QUALIFIED_P. */ 7124559860eSchristos const struct gcc_cp_function_args *) /* Argument ARGS. */ 7134559860eSchristos 7144559860eSchristos/* Return the type of the gcc_expr OPERAND. 7154559860eSchristos Use this for decltype. 7164559860eSchristos For decltype (auto), pass a NULL OPERAND. 7174559860eSchristos 7184559860eSchristos Note: for template-dependent expressions, the result is NULL, 7194559860eSchristos because the type is only computed when template argument 7204559860eSchristos substitution is performed. */ 7214559860eSchristos 7224559860eSchristosGCC_METHOD1 (gcc_type, get_expr_type, 7234559860eSchristos gcc_expr) /* Argument OPERAND. */ 7244559860eSchristos 7254559860eSchristos/* Introduce a specialization of a template function. 7264559860eSchristos 7274559860eSchristos TEMPLATE_DECL is the template function, and TARGS are the arguments 7284559860eSchristos for the specialization. ADDRESS is the address of the 7294559860eSchristos specialization. FILENAME and LINE_NUMBER specify the source 7304559860eSchristos location associated with the template function specialization. */ 7314559860eSchristos 7324559860eSchristosGCC_METHOD5 (gcc_decl, build_function_template_specialization, 7334559860eSchristos gcc_decl, /* Argument TEMPLATE_DECL. */ 7344559860eSchristos const struct gcc_cp_template_args *, /* Argument TARGS. */ 7354559860eSchristos gcc_address, /* Argument ADDRESS. */ 7364559860eSchristos const char *, /* Argument FILENAME. */ 7374559860eSchristos unsigned int) /* Argument LINE_NUMBER. */ 7384559860eSchristos 7394559860eSchristos/* Specialize a template class as an incomplete type. A definition 7404559860eSchristos can be supplied later, with start_class_type. 7414559860eSchristos 7424559860eSchristos TEMPLATE_DECL is the template class, and TARGS are the arguments 7434559860eSchristos for the specialization. FILENAME and LINE_NUMBER specify the 7444559860eSchristos source location associated with the template class 7454559860eSchristos specialization. */ 7464559860eSchristos 7474559860eSchristosGCC_METHOD4 (gcc_decl, build_class_template_specialization, 7484559860eSchristos gcc_decl, /* Argument TEMPLATE_DECL. */ 7494559860eSchristos const struct gcc_cp_template_args *, /* Argument TARGS. */ 7504559860eSchristos const char *, /* Argument FILENAME. */ 7514559860eSchristos unsigned int) /* Argument LINE_NUMBER. */ 7524559860eSchristos 7534559860eSchristos/* Start defining a 'class', 'struct' or 'union' type, entering its 7544559860eSchristos own binding level. Initially it has no fields. 7554559860eSchristos 7564559860eSchristos TYPEDECL is the forward-declaration of the type, returned by 7574559860eSchristos build_decl. BASE_CLASSES indicate the base classes of class NAME. 7584559860eSchristos FILENAME and LINE_NUMBER specify the source location associated 7594559860eSchristos with the class definition, should they be different from those of 7604559860eSchristos the forward declaration. */ 7614559860eSchristos 7624559860eSchristosGCC_METHOD4 (gcc_type, start_class_type, 7634559860eSchristos gcc_decl, /* Argument TYPEDECL. */ 7644559860eSchristos const struct gcc_vbase_array *,/* Argument BASE_CLASSES. */ 7654559860eSchristos const char *, /* Argument FILENAME. */ 7664559860eSchristos unsigned int) /* Argument LINE_NUMBER. */ 7674559860eSchristos 7684559860eSchristos/* Create a new closure class type, record it as the 7694559860eSchristos DISCRIMINATOR-numbered closure type in the current scope (or 7704559860eSchristos associated with EXTRA_SCOPE, if non-NULL), and enter the closure 7714559860eSchristos type's own binding level. This primitive would sort of combine 7724559860eSchristos build_decl and start_class_type, if they could be used to introduce 7734559860eSchristos a closure type. Initially it has no fields. 7744559860eSchristos 7754559860eSchristos FILENAME and LINE_NUMBER specify the source location associated 7764559860eSchristos with the class. EXTRA_SCOPE, if non-NULL, must be a PARM_DECL of 7774559860eSchristos the current function, or a FIELD_DECL of the current class. If it 7784559860eSchristos is NULL, the current scope must be a function. */ 7794559860eSchristos 7804559860eSchristosGCC_METHOD5 (gcc_type, start_closure_class_type, 7814559860eSchristos int, /* Argument DISCRIMINATOR. */ 7824559860eSchristos gcc_decl, /* Argument EXTRA_SCOPE. */ 7834559860eSchristos enum gcc_cp_symbol_kind, /* Argument FLAGS. */ 7844559860eSchristos const char *, /* Argument FILENAME. */ 7854559860eSchristos unsigned int) /* Argument LINE_NUMBER. */ 7864559860eSchristos 7874559860eSchristos/* Add a non-static data member to the most-recently-started 7884559860eSchristos unfinished struct or union type. FIELD_NAME is the field's name. 7894559860eSchristos FIELD_TYPE is the type of the field. BITSIZE and BITPOS indicate 7904559860eSchristos where in the struct the field occurs. */ 7914559860eSchristos 7924559860eSchristosGCC_METHOD5 (gcc_decl, build_field, 7934559860eSchristos const char *, /* Argument FIELD_NAME. */ 7944559860eSchristos gcc_type, /* Argument FIELD_TYPE. */ 7954559860eSchristos enum gcc_cp_symbol_kind, /* Argument FIELD_FLAGS. */ 7964559860eSchristos unsigned long, /* Argument BITSIZE. */ 7974559860eSchristos unsigned long) /* Argument BITPOS. */ 7984559860eSchristos 7994559860eSchristos/* After all the fields have been added to a struct, class or union, 8004559860eSchristos the struct or union type must be "finished". This does some final 8014559860eSchristos cleanups in GCC, and pops to the binding level that was in effect 8024559860eSchristos before the matching start_class_type or 8034559860eSchristos start_closure_class_type. */ 8044559860eSchristos 8054559860eSchristosGCC_METHOD1 (int /* bool */, finish_class_type, 8064559860eSchristos unsigned long) /* Argument SIZE_IN_BYTES. */ 8074559860eSchristos 8084559860eSchristos/* Create a new 'enum' type, and record it in the current binding 8094559860eSchristos level. The new type initially has no associated constants. 8104559860eSchristos 8114559860eSchristos NAME is the enum name. FILENAME and LINE_NUMBER specify its source 8124559860eSchristos location. */ 8134559860eSchristos 8144559860eSchristosGCC_METHOD5 (gcc_type, start_enum_type, 8154559860eSchristos const char *, /* Argument NAME. */ 8164559860eSchristos gcc_type, /* Argument UNDERLYING_INT_TYPE. */ 8174559860eSchristos enum gcc_cp_symbol_kind, /* Argument FLAGS. */ 8184559860eSchristos const char *, /* Argument FILENAME. */ 8194559860eSchristos unsigned int) /* Argument LINE_NUMBER. */ 8204559860eSchristos 8214559860eSchristos/* Add a new constant to an enum type. NAME is the constant's name 8224559860eSchristos and VALUE is its value. Returns a gcc_decl for the constant. */ 8234559860eSchristos 8244559860eSchristosGCC_METHOD3 (gcc_decl, build_enum_constant, 8254559860eSchristos gcc_type, /* Argument ENUM_TYPE. */ 8264559860eSchristos const char *, /* Argument NAME. */ 8274559860eSchristos unsigned long) /* Argument VALUE. */ 8284559860eSchristos 8294559860eSchristos/* After all the constants have been added to an enum, the type must 8304559860eSchristos be "finished". This does some final cleanups in GCC. */ 8314559860eSchristos 8324559860eSchristosGCC_METHOD1 (int /* bool */, finish_enum_type, 8334559860eSchristos gcc_type) /* Argument ENUM_TYPE. */ 8344559860eSchristos 8354559860eSchristos/* Create a new function type. RETURN_TYPE is the type returned by 8364559860eSchristos the function, and ARGUMENT_TYPES is a vector, of length NARGS, of 8374559860eSchristos the argument types. IS_VARARGS is true if the function is 8384559860eSchristos varargs. */ 8394559860eSchristos 8404559860eSchristosGCC_METHOD3 (gcc_type, build_function_type, 8414559860eSchristos gcc_type, /* Argument RETURN_TYPE. */ 8424559860eSchristos const struct gcc_type_array *,/* Argument ARGUMENT_TYPES. */ 8434559860eSchristos int /* bool */) /* Argument IS_VARARGS. */ 8444559860eSchristos 8454559860eSchristos/* Create a variant of a function type with an exception 8464559860eSchristos specification. FUNCTION_TYPE is a function or method type. 8474559860eSchristos EXCEPT_TYPES is an array with the list of exception types. Zero as 8484559860eSchristos the array length implies throw() AKA noexcept(true); NULL as the 8494559860eSchristos pointer to gcc_type_array implies noexcept(false), which is almost 8504559860eSchristos equivalent (but distinguishable by the compiler) to an unspecified 8514559860eSchristos exception list. */ 8524559860eSchristos 8534559860eSchristosGCC_METHOD2 (gcc_type, build_exception_spec_variant, 8544559860eSchristos gcc_type, /* Argument FUNCTION_TYPE. */ 8554559860eSchristos const struct gcc_type_array *)/* Argument EXCEPT_TYPES. */ 8564559860eSchristos 8574559860eSchristos/* Create a new non-static member function type. FUNC_TYPE is the 8584559860eSchristos method prototype, without the implicit THIS pointer, added as a 8594559860eSchristos pointer to the QUALS-qualified CLASS_TYPE. If CLASS_TYPE is NULL, 8604559860eSchristos this creates a cv-qualified (member) function type not associated 8614559860eSchristos with any specific class, as needed to support "typedef void f(int) 8624559860eSchristos const;", which can later be used to declare member functions and 8634559860eSchristos pointers to member functions. */ 8644559860eSchristos 8654559860eSchristosGCC_METHOD4 (gcc_type, build_method_type, 8664559860eSchristos gcc_type, /* Argument CLASS_TYPE. */ 8674559860eSchristos gcc_type, /* Argument FUNC_TYPE. */ 8684559860eSchristos enum gcc_cp_qualifiers, /* Argument QUALS. */ 8694559860eSchristos enum gcc_cp_ref_qualifiers) /* Argument RQUALS. */ 8704559860eSchristos 8714559860eSchristos/* Return a declaration for the (INDEX - 1)th argument of 8724559860eSchristos FUNCTION_DECL, i.e., for the first argument, use zero as the index. 8734559860eSchristos If FUNCTION_DECL is a non-static member function, use -1 to get the 8744559860eSchristos implicit THIS parameter. */ 8754559860eSchristos 8764559860eSchristosGCC_METHOD2 (gcc_decl, get_function_parameter_decl, 8774559860eSchristos gcc_decl, /* Argument FUNCTION_DECL. */ 8784559860eSchristos int) /* Argument INDEX. */ 8794559860eSchristos 8804559860eSchristos/* Return a lambda expr that constructs an instance of CLOSURE_TYPE. 8814559860eSchristos Only lambda exprs without any captures can be correctly created 8824559860eSchristos through these mechanisms; that's all we need to support lambdas 8834559860eSchristos expressions in default parameters, the only kind that may have to 8844559860eSchristos be introduced through this interface. */ 8854559860eSchristos 8864559860eSchristosGCC_METHOD1 (gcc_expr, build_lambda_expr, 8874559860eSchristos gcc_type) /* Argument CLOSURE_TYPE. */ 8884559860eSchristos 8894559860eSchristos/* Return an integer type with the given properties. If BUILTIN_NAME 8904559860eSchristos is non-NULL, it must name a builtin integral type with the given 8914559860eSchristos signedness and size, and that is the type that will be returned. */ 8924559860eSchristos 8934559860eSchristosGCC_METHOD3 (gcc_type, get_int_type, 8944559860eSchristos int /* bool */, /* Argument IS_UNSIGNED. */ 8954559860eSchristos unsigned long, /* Argument SIZE_IN_BYTES. */ 8964559860eSchristos const char *) /* Argument BUILTIN_NAME. */ 8974559860eSchristos 8984559860eSchristos/* Return the 'char' type, a distinct type from both 'signed char' and 8994559860eSchristos 'unsigned char' returned by int_type. */ 9004559860eSchristos 9014559860eSchristosGCC_METHOD0 (gcc_type, get_char_type) 9024559860eSchristos 9034559860eSchristos/* Return a floating point type with the given properties. If BUILTIN_NAME 9044559860eSchristos is non-NULL, it must name a builtin integral type with the given 9054559860eSchristos signedness and size, and that is the type that will be returned. */ 9064559860eSchristos 9074559860eSchristosGCC_METHOD2 (gcc_type, get_float_type, 9084559860eSchristos unsigned long, /* Argument SIZE_IN_BYTES. */ 9094559860eSchristos const char *) /* Argument BUILTIN_NAME. */ 9104559860eSchristos 9114559860eSchristos/* Return the 'void' type. */ 9124559860eSchristos 9134559860eSchristosGCC_METHOD0 (gcc_type, get_void_type) 9144559860eSchristos 9154559860eSchristos/* Return the 'bool' type. */ 9164559860eSchristos 9174559860eSchristosGCC_METHOD0 (gcc_type, get_bool_type) 9184559860eSchristos 9194559860eSchristos/* Return the std::nullptr_t type. */ 9204559860eSchristos 9214559860eSchristosGCC_METHOD0 (gcc_type, get_nullptr_type) 9224559860eSchristos 9234559860eSchristos/* Return the nullptr constant. */ 9244559860eSchristos 9254559860eSchristosGCC_METHOD0 (gcc_expr, get_nullptr_constant) 9264559860eSchristos 9274559860eSchristos/* Create a new array type. If NUM_ELEMENTS is -1, then the array 9284559860eSchristos is assumed to have an unknown length. */ 9294559860eSchristos 9304559860eSchristosGCC_METHOD2 (gcc_type, build_array_type, 9314559860eSchristos gcc_type, /* Argument ELEMENT_TYPE. */ 9324559860eSchristos int) /* Argument NUM_ELEMENTS. */ 9334559860eSchristos 9344559860eSchristos/* Create a new array type. NUM_ELEMENTS is a template-dependent 9354559860eSchristos expression. */ 9364559860eSchristos 9374559860eSchristosGCC_METHOD2 (gcc_type, build_dependent_array_type, 9384559860eSchristos gcc_type, /* Argument ELEMENT_TYPE. */ 9394559860eSchristos gcc_expr) /* Argument NUM_ELEMENTS. */ 9404559860eSchristos 9414559860eSchristos/* Create a new variably-sized array type. UPPER_BOUND_NAME is the 9424559860eSchristos name of a local variable that holds the upper bound of the array; 9434559860eSchristos it is one less than the array size. */ 9444559860eSchristos 9454559860eSchristosGCC_METHOD2 (gcc_type, build_vla_array_type, 9464559860eSchristos gcc_type, /* Argument ELEMENT_TYPE. */ 9474559860eSchristos const char *) /* Argument UPPER_BOUND_NAME. */ 9484559860eSchristos 9494559860eSchristos/* Return a qualified variant of a given base type. QUALIFIERS says 9504559860eSchristos which qualifiers to use; it is composed of or'd together 9514559860eSchristos constants from 'enum gcc_cp_qualifiers'. */ 9524559860eSchristos 9534559860eSchristosGCC_METHOD2 (gcc_type, build_qualified_type, 9544559860eSchristos gcc_type, /* Argument UNQUALIFIED_TYPE. */ 9554559860eSchristos enum gcc_cp_qualifiers) /* Argument QUALIFIERS. */ 9564559860eSchristos 9574559860eSchristos/* Build a complex type given its element type. */ 9584559860eSchristos 9594559860eSchristosGCC_METHOD1 (gcc_type, build_complex_type, 9604559860eSchristos gcc_type) /* Argument ELEMENT_TYPE. */ 9614559860eSchristos 9624559860eSchristos/* Build a vector type given its element type and number of 9634559860eSchristos elements. */ 9644559860eSchristos 9654559860eSchristosGCC_METHOD2 (gcc_type, build_vector_type, 9664559860eSchristos gcc_type, /* Argument ELEMENT_TYPE. */ 9674559860eSchristos int) /* Argument NUM_ELEMENTS. */ 9684559860eSchristos 9694559860eSchristos/* Build a constant. NAME is the constant's name and VALUE is its 9704559860eSchristos value. FILENAME and LINE_NUMBER refer to the type's source 9714559860eSchristos location. If this is not known, FILENAME can be NULL and 9724559860eSchristos LINE_NUMBER can be 0. */ 9734559860eSchristos 9744559860eSchristosGCC_METHOD5 (int /* bool */, build_constant, 9754559860eSchristos gcc_type, /* Argument TYPE. */ 9764559860eSchristos const char *, /* Argument NAME. */ 9774559860eSchristos unsigned long, /* Argument VALUE. */ 9784559860eSchristos const char *, /* Argument FILENAME. */ 9794559860eSchristos unsigned int) /* Argument LINE_NUMBER. */ 9804559860eSchristos 9814559860eSchristos/* Emit an error and return an error type object. */ 9824559860eSchristos 9834559860eSchristosGCC_METHOD1 (gcc_type, error, 9844559860eSchristos const char *) /* Argument MESSAGE. */ 9854559860eSchristos 9864559860eSchristos/* Declare a static_assert with the given CONDITION and ERRORMSG at 9874559860eSchristos FILENAME:LINE_NUMBER. */ 9884559860eSchristos 9894559860eSchristosGCC_METHOD4 (int /* bool */, add_static_assert, 9904559860eSchristos gcc_expr, /* Argument CONDITION. */ 9914559860eSchristos const char *, /* Argument ERRORMSG. */ 9924559860eSchristos const char *, /* Argument FILENAME. */ 9934559860eSchristos unsigned int) /* Argument LINE_NUMBER. */ 9944559860eSchristos 9954559860eSchristos#if 0 9964559860eSchristos 9974559860eSchristos/* FIXME: We don't want to expose the internal implementation detail 9984559860eSchristos that default parms are stored in function types, and it's not clear 9994559860eSchristos how this or other approaches would interact with the type sharing 10004559860eSchristos of e.g. ctor clones, so we're leaving this out, since default args 10014559860eSchristos are not even present in debug information anyway. Besides, the set 10024559860eSchristos of default args for a function may grow within its scope, and vary 10034559860eSchristos independently in other scopes. */ 10044559860eSchristos 10054559860eSchristos/* Create a modified version of a function type that has default 10064559860eSchristos values for some of its arguments. The returned type should ONLY be 10074559860eSchristos used to define functions or methods, never to declare parameters, 10084559860eSchristos variables, types or the like. 10094559860eSchristos 10104559860eSchristos DEFAULTS must have at most as many N_ELEMENTS as there are 10114559860eSchristos arguments without default values in FUNCTION_TYPE. Say, if 10124559860eSchristos FUNCTION_TYPE has an argument list such as (T1, T2, T3, T4 = V0) 10134559860eSchristos and DEFAULTS has 2 elements (V1, V2), the returned type will have 10144559860eSchristos the following argument list: (T1, T2 = V1, T3 = V2, T4 = V0). 10154559860eSchristos 10164559860eSchristos Any NULL expressions in DEFAULTS will be marked as deferred, and 10174559860eSchristos they should be filled in with set_deferred_function_default_args. */ 10184559860eSchristos 10194559860eSchristosGCC_METHOD2 (gcc_type, add_function_default_args, 10204559860eSchristos gcc_type, /* Argument FUNCTION_TYPE. */ 10214559860eSchristos const struct gcc_cp_function_args *) /* Argument DEFAULTS. */ 10224559860eSchristos 10234559860eSchristos/* Fill in the first deferred default args in FUNCTION_DECL with the 10244559860eSchristos expressions given in DEFAULTS. This can be used when the 10254559860eSchristos declaration of a parameter is needed to create a default 10264559860eSchristos expression, such as taking the size of an earlier parameter, or 10274559860eSchristos building a lambda expression in the parameter's context. */ 10284559860eSchristos 10294559860eSchristosGCC_METHOD2 (int /* bool */, set_deferred_function_default_args, 10304559860eSchristos gcc_decl, /* Argument FUNCTION_DECL. */ 10314559860eSchristos const struct gcc_cp_function_args *) /* Argument DEFAULTS. */ 10324559860eSchristos 10334559860eSchristos#endif 10344559860eSchristos 10354559860eSchristos 10364559860eSchristos/* When you add entry points, add them at the end, so that the new API 10374559860eSchristos version remains compatible with the old version. 10384559860eSchristos 10394559860eSchristos The following conventions have been observed as to naming entry points: 10404559860eSchristos 10414559860eSchristos - build_* creates (and maybe records) something and returns it; 10424559860eSchristos - add_* creates and records something, but doesn't return it; 10434559860eSchristos - get_* obtains something without creating it; 10444559860eSchristos - start_* marks the beginning of a compound (type, list, ...); 10454559860eSchristos - finish_* completes the compound when needed. 10464559860eSchristos 10474559860eSchristos Entry points that return an int (bool) and don't have a return value 10484559860eSchristos specification return nonzero (true) on success and zero (false) on 10494559860eSchristos failure. This is in line with libcc1's conventions of returning a 10504559860eSchristos zero-initialized value in case of e.g. a transport error. */ 1051