1 1.1 christos /* Interface between GCC C++ FE and GDB -*- c -*- 2 1.1 christos 3 1.1.1.4 christos Copyright (C) 2014-2024 Free Software Foundation, Inc. 4 1.1 christos 5 1.1 christos This file is part of GCC. 6 1.1 christos 7 1.1 christos This program is free software; you can redistribute it and/or modify 8 1.1 christos it under the terms of the GNU General Public License as published by 9 1.1 christos the Free Software Foundation; either version 3 of the License, or 10 1.1 christos (at your option) any later version. 11 1.1 christos 12 1.1 christos This program is distributed in the hope that it will be useful, 13 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of 14 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 1.1 christos GNU General Public License for more details. 16 1.1 christos 17 1.1 christos You should have received a copy of the GNU General Public License 18 1.1 christos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 19 1.1 christos 20 1.1 christos 21 1.1 christos 22 1.1 christos /* Push namespace NAME as the current binding level, to which 23 1.1 christos newly-introduced decls will be bound. An empty string identifies 24 1.1 christos the global namespace, whereas NULL identifies an anonymous 25 1.1 christos namespace. A namespace named NAME is created in the current scope, 26 1.1 christos if needed. 27 1.1 christos 28 1.1 christos If the newly-created namespace is to be an inline namespace, see 29 1.1 christos make_namespace_inline. */ 30 1.1 christos 31 1.1 christos GCC_METHOD1 (int /* bool */, push_namespace, 32 1.1 christos const char *) /* Argument NAME. */ 33 1.1 christos 34 1.1 christos /* Push TYPE as the current binding level, making its members visible 35 1.1 christos for name lookup. The current scope before the call must be the 36 1.1 christos scope in which the class was declared. This should be used if the 37 1.1 christos definition of a class is already finished, but one wishes to define 38 1.1 christos a nested class, or to enter the scope of one of its member 39 1.1 christos functions. */ 40 1.1 christos 41 1.1 christos GCC_METHOD1 (int /* bool */, push_class, 42 1.1 christos gcc_type) /* Argument TYPE. */ 43 1.1 christos 44 1.1 christos /* Push FUNCTION_DECL as the current (empty) binding level (see 45 1.1 christos reactivate_decl). The current enclosing scope before the call must 46 1.1 christos be the scope in which the function was declared. */ 47 1.1 christos 48 1.1 christos GCC_METHOD1 (int /* bool */, push_function, 49 1.1 christos gcc_decl) /* Argument FUNCTION_DECL. */ 50 1.1 christos 51 1.1 christos /* Make DECL visible (again?) within SCOPE. When SCOPE is NULL, it 52 1.1 christos means the current scope; if it is not NULL, it must name a function 53 1.1 christos that is currently active, even if not at the top of the binding 54 1.1 christos chain. 55 1.1 christos 56 1.1 christos This function can be used to make e.g. a global function or 57 1.1 christos variable visible in a namespace or local scope (overriding another 58 1.1 christos enclosing definition of the same name), but its most common 59 1.1 christos expected use of this primitive, that gives it its name, is to make 60 1.1 christos declarations visible again after reentering a function scope, 61 1.1 christos because when a function is entered with push_function, that does 62 1.1 christos NOT make any of the declarations nested in it visible for name 63 1.1 christos lookup. 64 1.1 christos 65 1.1 christos There is a reason/excuse for that: unlike namespaces and classes, 66 1.1 christos G++ doesn't ever have to reenter function scopes, so its name 67 1.1 christos resolution infrastructure is not prepared to do that. But wait, 68 1.1 christos there is also a good use for this apparent limitation: a function 69 1.1 christos may contain multiple scopes (blocks), and the name may be bound to 70 1.1 christos different symbols in each of these scopes. With this interface, as 71 1.1 christos we reenter a function scope, we may choose which symbols to make 72 1.1 christos visible for the code snippet, or, if there could be template 73 1.1 christos functions in local scopes, for unresolved names in nested template 74 1.1 christos class default arguments, or in nested template function signatures. 75 1.1 christos 76 1.1 christos As for making a local declaration visible for the code snippet, 77 1.1 christos there are two possibilities: a) introduce it upfront, while 78 1.1 christos entering the scope for the user expression (see the enter_scope 79 1.1 christos callback, called by g++ when encountering the push_user_expression 80 1.1 christos pragma), which might save some scope switching and reactivate_decl 81 1.1 christos (though this can't be helped if some declarations have to be 82 1.1 christos introduced and discarded, because of multiple definitions of the 83 1.1 christos same name in different scopes within a function: they have to be 84 1.1 christos defined in discriminator order); or b) introduce it when its name 85 1.1 christos is looked up, entering the scope, introducing the declaration, 86 1.1 christos leaving the scope, and then reactivating the declaration in its 87 1.1 christos local scope. 88 1.1 christos 89 1.1 christos Here's some more detail on how reactivate_decl works. Say there's 90 1.1 christos a function foo whose body looks like this: 91 1.1 christos 92 1.1 christos { 93 1.1 christos { 94 1.1 christos // point 1 95 1.1 christos class c {} o __attribute__ ((__used__)); // c , o 96 1.1 christos } 97 1.1 christos struct c { 98 1.1 christos void f() { 99 1.1 christos // point 2 100 1.1 christos } 101 1.1 christos } o __attribute__ ((__used__)); // c_0, o_0 102 1.1 christos { 103 1.1 christos class c {} p __attribute__ ((__used__)); // c_1, p 104 1.1 christos // point 3 105 1.1 christos o.f(); 106 1.1 christos } 107 1.1 christos } 108 1.1 christos 109 1.1 christos When we are about to define class c at point 1, we enter the 110 1.1 christos function foo scope, and since no symbols are visible at point 1, we 111 1.1 christos proceed to declare class c. We may then define the class right 112 1.1 christos away, or, if we leave the function scope, and we later wish to 113 1.1 christos define it, or to define object o, we can reenter the scope and just 114 1.1 christos use the previously-obtained gcc_decl to define the class, without 115 1.1 christos having to reactivate the declaration. 116 1.1 christos 117 1.1 christos Now, if we are to set up the binding context for point 2, we have 118 1.1 christos to define c_0::f, and in order to do so, we have to declare and 119 1.1 christos define c_0. Before we can declare c_0, we MUST at least declare c. 120 1.1 christos 121 1.1 christos As a general rule, before we can declare or define any local name 122 1.1 christos with a discriminator, we have to at least declare any other 123 1.1 christos occurrences of the same name in the same enclosing entity with 124 1.1 christos lower or absent discriminator. 125 1.1 christos 126 1.1 christos So, we declare c, then we leave the function scope and reenter it 127 1.1 christos so as to declare c_0 (also with name "c", which is why we have to 128 1.1 christos leave and reenter the function scope, otherwise we would get an 129 1.1 christos error because of the duplicate definition; g++ will assign a 130 1.1 christos discriminator because it still remembers there was an earlier 131 1.1 christos declaration of c_0 within the function, it's just no longer in 132 1.1 christos scope), then we can define c_0, including its member function f. 133 1.1 christos 134 1.1 christos Likewise, if we wish to define o_0, we have to define o first. If 135 1.1 christos we wish to declare (and maybe then define) c_1, we have to at least 136 1.1 christos declare (c and then) c_0 first. 137 1.1 christos 138 1.1 christos Then, as we set up the binding context to compile a code snippet at 139 1.1 christos point 3, we may choose to activate c_1, o_0 and p upfront, 140 1.1 christos declaring and discarding c, c_0 and o, and then reentering the 141 1.1 christos funciton scope to declare c_1, o_0 and p; or we can wait for oracle 142 1.1 christos lookups of c, o or p. If c is looked up, and the debugger resolves 143 1.1 christos c in the scope to c_1, it is expected to enter the function scope 144 1.1 christos from the top level, declare c, leave it, reenter it, declare c_0, 145 1.1 christos leave it, reenter it, declare c_1, leave it, and then reactivate 146 1.1 christos c_1 in the function scope. If c_1 is needed as a complete type, 147 1.1 christos the definition may be given right after the declaration, or the 148 1.1 christos scope will have to be reentered in order to define the class. 149 1.1 christos 150 1.1 christos . If the code snippet is at point 2, we don't need to (re)activate 151 1.1 christos any declaration: nothing from any local scope is visible. Just 152 1.1 christos entering the scope of the class containing member function f 153 1.1 christos reactivates the names of its members, including the class name 154 1.1 christos itself. */ 155 1.1 christos 156 1.1 christos GCC_METHOD2 (int /* bool */, reactivate_decl, 157 1.1 christos gcc_decl, /* Argument DECL. */ 158 1.1 christos gcc_decl) /* Argument SCOPE. */ 159 1.1 christos 160 1.1 christos /* Pop the namespace last entered with push_namespace, or class last 161 1.1 christos entered with push_class, or function last entered with 162 1.1 christos push_function, restoring the binding level in effect before the 163 1.1 christos matching push_* call. */ 164 1.1 christos 165 1.1 christos GCC_METHOD0 (int /* bool */, pop_binding_level) 166 1.1 christos 167 1.1 christos /* Return the NAMESPACE_DECL, TYPE_DECL or FUNCTION_DECL of the 168 1.1 christos binding level that would be popped by pop_scope. */ 169 1.1 christos 170 1.1 christos GCC_METHOD0 (gcc_decl, get_current_binding_level_decl) 171 1.1 christos 172 1.1 christos /* Make the current binding level an inline namespace. It must be a 173 1.1 christos namespace to begin with. It is safe to call this more than once 174 1.1 christos for the same namespace, but after the first call, subsequent ones 175 1.1 christos will not return a success status. */ 176 1.1 christos 177 1.1 christos GCC_METHOD0 (int /* bool */, make_namespace_inline) 178 1.1 christos 179 1.1 christos /* Add USED_NS to the namespaces used by the current binding level. 180 1.1 christos Use get_current_binding_level_decl to obtain USED_NS's 181 1.1 christos gcc_decl. */ 182 1.1 christos 183 1.1 christos GCC_METHOD1 (int /* bool */, add_using_namespace, 184 1.1 christos gcc_decl) /* Argument USED_NS. */ 185 1.1 christos 186 1.1 christos /* Introduce a namespace alias declaration, as in: 187 1.1 christos 188 1.1 christos namespace foo = [... ::] bar; 189 1.1 christos 190 1.1 christos After this call, namespace TARGET will be visible as ALIAS within 191 1.1 christos the current namespace. Get the declaration for TARGET by calling 192 1.1 christos get_current_binding_level_decl after pushing into it. */ 193 1.1 christos 194 1.1 christos GCC_METHOD2 (int /* bool */, add_namespace_alias, 195 1.1 christos const char *, /* Argument ALIAS. */ 196 1.1 christos gcc_decl) /* Argument TARGET. */ 197 1.1 christos 198 1.1 christos /* Introduce a using declaration, as in: 199 1.1 christos 200 1.1 christos using foo::bar; 201 1.1 christos 202 1.1 christos The TARGET decl names the qualifying scope (foo:: above) and the 203 1.1 christos identifier (bar), but that does not mean that only TARGET will be 204 1.1 christos brought into the current scope: all bindings of TARGET's identifier 205 1.1 christos in the qualifying scope will be brought in. 206 1.1 christos 207 1.1 christos FLAGS should specify GCC_CP_SYMBOL_USING. If the current scope is 208 1.1 christos a class scope, visibility flags must be supplied. 209 1.1 christos 210 1.1 christos Even when TARGET is template dependent, we don't need to specify 211 1.1 christos whether or not it is a typename: the supplied declaration (that 212 1.1 christos could be a template-dependent type converted to declaration by 213 1.1 christos get_type_decl) indicates so. */ 214 1.1 christos 215 1.1 christos GCC_METHOD2 (int /* bool */, add_using_decl, 216 1.1 christos enum gcc_cp_symbol_kind, /* Argument FLAGS. */ 217 1.1 christos gcc_decl) /* Argument TARGET. */ 218 1.1 christos 219 1.1 christos /* Create a new "decl" in GCC, and bind it in the current binding 220 1.1 christos level. A decl is a declaration, basically a kind of symbol. 221 1.1 christos 222 1.1 christos NAME is the name of the new symbol. SYM_KIND is the kind of 223 1.1 christos symbol being requested. SYM_TYPE is the new symbol's C++ type; 224 1.1 christos except for labels, where this is not meaningful and should be 225 1.1 christos zero. If SUBSTITUTION_NAME is not NULL, then a reference to this 226 1.1 christos decl in the source will later be substituted with a dereference 227 1.1 christos of a variable of the given name. Otherwise, for symbols having 228 1.1 christos an address (e.g., functions), ADDRESS is the address. FILENAME 229 1.1 christos and LINE_NUMBER refer to the symbol's source location. If this 230 1.1 christos is not known, FILENAME can be NULL and LINE_NUMBER can be 0. 231 1.1 christos This function returns the new decl. 232 1.1 christos 233 1.1 christos Use this function to register typedefs, functions and variables to 234 1.1 christos namespace and local binding levels, and typedefs, member functions 235 1.1 christos (static or not), and static data members to class binding levels. 236 1.1 christos Class members must have their access controls specified with 237 1.1 christos GCC_CP_ACCESS_* flags in SYM_KIND. 238 1.1 christos 239 1.1 christos Note that, since access controls are disabled, we have no means to 240 1.1 christos express private, protected and public. 241 1.1 christos 242 1.1 christos There are various flags that can be set in SYM_KIND to specify 243 1.1 christos additional semantics. Look for GCC_CP_FLAGs in the definition of 244 1.1 christos enum gcc_cp_symbol_kind in gcc-cp-interface.h. 245 1.1 christos 246 1.1 christos In order to define member functions, pass GCC_CP_SYMBOL_FUNCTION in 247 1.1 christos SYM_KIND, and a function_type for static member functions or a 248 1.1 christos method type for non-static member functions, including constructors 249 1.1 christos and destructors. Use build_function_type to create a function 250 1.1 christos type; for a method type, start by creating a function type without 251 1.1 christos any compiler-introduced artificial arguments (the implicit this 252 1.1 christos pointer, and the __in_chrg added to constructors and destructors, 253 1.1 christos and __vtt_parm added to the former), and then use build_method_type 254 1.1 christos to create the method type out of the class type and the function 255 1.1 christos type. 256 1.1 christos 257 1.1 christos For operator functions, set GCC_CP_FLAG_SPECIAL_FUNCTION in 258 1.1 christos SYM_KIND, in addition to any other applicable flags, and pass as 259 1.1 christos NAME a string starting with the two-character mangling for operator 260 1.1 christos name: "ps" for unary plus, "mL" for multiply and assign, *=; etc. 261 1.1 christos Use "cv" for type converstion operators (the target type portion 262 1.1 christos may be omitted, as it is taken from the return type in SYM_TYPE). 263 1.1 christos For operator"", use "li" followed by the identifier (the mangled 264 1.1 christos name mandates digits specifying the length of the identifier; if 265 1.1 christos present, they determine the end of the identifier, otherwise, the 266 1.1 christos identifier extents to the end of the string, so that "li3_Kme" and 267 1.1 christos "li_Km" are equivalent). 268 1.1 christos 269 1.1 christos Constructors and destructors need special care, because for each 270 1.1 christos constructor and destructor there may be multiple clones defined 271 1.1 christos internally by the compiler. With build_decl, you can introduce the 272 1.1 christos base declaration of a constructor or a destructor, setting 273 1.1 christos GCC_CP_FLAG_SPECIAL_FUNCTION the flag and using names starting with 274 1.1 christos capital "C" or "D", respectively, followed by a digit (see below), 275 1.1 christos a blank, or NUL ('\0'). DO NOT supply an ADDRESS or a 276 1.1 christos SUBSTITUTION_NAME to build_decl, it would be meaningless (and 277 1.1 christos rejected) for the base declaration; use define_cdtor_clone to 278 1.1 christos introduce the address of each clone. For constructor templates, 279 1.1 christos declare the template with build_decl, and then, for each 280 1.1 christos specialization, introduce it with 281 1.1 christos build_function_template_specialization, and then define the 282 1.1 christos addresses of each of its clones with define_cdtor_clone. 283 1.1 christos 284 1.1 christos NAMEs for GCC_CP_FLAG_SPECIAL_FUNCTION: 285 1.1 christos 286 1.1 christos NAME meaning 287 1.1 christos C? constructor base declaration (? may be 1, 2, 4, blank or NUL) 288 1.1 christos D? destructor base declaration (? may be 0, 1, 2, 4, blank or NUL) 289 1.1 christos nw operator new 290 1.1 christos na operator new[] 291 1.1 christos dl operator delete 292 1.1 christos da operator delete[] 293 1.1 christos ps operator + (unary) 294 1.1 christos ng operator - (unary) 295 1.1 christos ad operator & (unary) 296 1.1 christos de operator * (unary) 297 1.1 christos co operator ~ 298 1.1 christos pl operator + 299 1.1 christos mi operator - 300 1.1 christos ml operator * 301 1.1 christos dv operator / 302 1.1 christos rm operator % 303 1.1 christos an operator & 304 1.1 christos or operator | 305 1.1 christos eo operator ^ 306 1.1 christos aS operator = 307 1.1 christos pL operator += 308 1.1 christos mI operator -= 309 1.1 christos mL operator *= 310 1.1 christos dV operator /= 311 1.1 christos rM operator %= 312 1.1 christos aN operator &= 313 1.1 christos oR operator |= 314 1.1 christos eO operator ^= 315 1.1 christos ls operator << 316 1.1 christos rs operator >> 317 1.1 christos lS operator <<= 318 1.1 christos rS operator >>= 319 1.1 christos eq operator == 320 1.1 christos ne operator != 321 1.1 christos lt operator < 322 1.1 christos gt operator > 323 1.1 christos le operator <= 324 1.1 christos ge operator >= 325 1.1 christos nt operator ! 326 1.1 christos aa operator && 327 1.1 christos oo operator || 328 1.1 christos pp operator ++ 329 1.1 christos mm operator -- 330 1.1 christos cm operator , 331 1.1 christos pm operator ->* 332 1.1 christos pt operator -> 333 1.1 christos cl operator () 334 1.1 christos ix operator [] 335 1.1 christos qu operator ? 336 1.1 christos cv operator <T> (conversion operator) 337 1.1 christos li<id> operator "" <id> 338 1.1 christos 339 1.1 christos FIXME: How about attributes? */ 340 1.1 christos 341 1.1 christos GCC_METHOD7 (gcc_decl, build_decl, 342 1.1 christos const char *, /* Argument NAME. */ 343 1.1 christos enum gcc_cp_symbol_kind, /* Argument SYM_KIND. */ 344 1.1 christos gcc_type, /* Argument SYM_TYPE. */ 345 1.1 christos const char *, /* Argument SUBSTITUTION_NAME. */ 346 1.1 christos gcc_address, /* Argument ADDRESS. */ 347 1.1 christos const char *, /* Argument FILENAME. */ 348 1.1 christos unsigned int) /* Argument LINE_NUMBER. */ 349 1.1 christos 350 1.1 christos /* Supply the ADDRESS of one of the multiple clones of constructor or 351 1.1 christos destructor CDTOR. The clone is specified by NAME, using the 352 1.1 christos following name mangling conventions: 353 1.1 christos 354 1.1 christos C1 in-charge constructor 355 1.1 christos C2 not-in-charge constructor 356 1.1 christos C4 unified constructor 357 1.1 christos D0 deleting destructor 358 1.1 christos D1 in-charge destructor 359 1.1 christos D2 not-in-charge destructor 360 1.1 christos D4 unified destructor 361 1.1 christos 362 1.1 christos The following information is not necessary to use the API. 363 1.1 christos 364 1.1 christos C1 initializes an instance of the class (rather than of derived 365 1.1 christos classes), including virtual base classes, whereas C2 initializes a 366 1.1 christos sub-object (of the given class type) of an instance of some derived 367 1.1 christos class (or a full object that doesn't have any virtual base 368 1.1 christos classes). 369 1.1 christos 370 1.1 christos D0 and D1 destruct an instance of the class, including virtual base 371 1.1 christos classes, but only the former calls operator delete to release the 372 1.1 christos object's storage at the end; D2 destructs a sub-object (of the 373 1.1 christos given class type) of an instance of a derived class (or a full 374 1.1 christos object that doesn't have any virtual base classes). 375 1.1 christos 376 1.1 christos The [CD]4 manglings (and symbol definitions) are non-standard, but 377 1.1 christos GCC uses them in some cases: rather than assuming they are 378 1.1 christos in-charge or not-in-charge, they test the implicit argument that 379 1.1 christos the others ignore to tell how to behave. These are used instead of 380 1.1 christos cloning when we just can't use aliases. */ 381 1.1 christos 382 1.1 christos GCC_METHOD3 (gcc_decl, define_cdtor_clone, 383 1.1 christos const char *, /* Argument NAME. */ 384 1.1 christos gcc_decl, /* Argument CDTOR. */ 385 1.1 christos gcc_address) /* Argument ADDRESS. */ 386 1.1 christos 387 1.1 christos /* Return the type associated with the given declaration. This is 388 1.1 christos most useful to obtain the type associated with a forward-declared 389 1.1 christos class, because it is the gcc_type, rather than the gcc_decl, that 390 1.1 christos has to be used to build other types, but build_decl returns a 391 1.1 christos gcc_decl rather than a gcc_type. This call can in theory be used 392 1.1 christos to obtain the type from any other declaration; it is supposed to 393 1.1 christos return the same type that was supplied when the declaration was 394 1.1 christos created. */ 395 1.1 christos 396 1.1 christos GCC_METHOD1 (gcc_type, get_decl_type, 397 1.1 christos gcc_decl) /* Argument DECL. */ 398 1.1 christos 399 1.1 christos /* Return the declaration for a type. */ 400 1.1 christos 401 1.1 christos GCC_METHOD1 (gcc_decl, get_type_decl, 402 1.1 christos gcc_type) /* Argument TYPE. */ 403 1.1 christos 404 1.1 christos /* Declare DECL as a friend of the current class scope, if TYPE is 405 1.1 christos NULL, or of TYPE itself otherwise. DECL may be a function or a 406 1.1 christos class, be they template generics, template specializations or not 407 1.1 christos templates. TYPE must be a class type (not a template generic). 408 1.1 christos 409 1.1 christos The add_friend call cannot introduce a declaration; even if the 410 1.1 christos friend is first declared as a friend in the source code, the 411 1.1 christos declaration belongs in the enclosing namespace, so it must be 412 1.1 christos introduced in that namespace, and the resulting declaration can 413 1.1 christos then be made a friend. 414 1.1 christos 415 1.1 christos DECL cannot, however, be a member of a template class generic, 416 1.1 christos because we have no means to introduce their declarations. This 417 1.1 christos interface has no notion of definitions for template generics. As a 418 1.1 christos consequence, users of this interface must introduce each friend 419 1.1 christos template member specialization separately, i.e., instead of: 420 1.1 christos 421 1.1 christos template <typename T> friend struct X<T>::M; 422 1.1 christos 423 1.1 christos they must be declared as if they were: 424 1.1 christos 425 1.1 christos friend struct X<onetype>::M; 426 1.1 christos friend struct X<anothertype>::M; 427 1.1 christos ... for each specialization of X. 428 1.1 christos 429 1.1 christos 430 1.1 christos Specializations of a template can have each others' members as 431 1.1 christos friends: 432 1.1 christos 433 1.1 christos template <typename T> class foo { 434 1.1 christos int f(); 435 1.1 christos template <typename U> friend int foo<U>::f(); 436 1.1 christos }; 437 1.1 christos 438 1.1 christos It wouldn't always be possible to define all specializations of a 439 1.1 christos template class before introducing the friend declarations in their 440 1.1 christos expanded, per-specialization form. 441 1.1 christos 442 1.1 christos In order to simplify such friend declarations, and to enable 443 1.1 christos incremental friend declarations as template specializations are 444 1.1 christos introduced, add_friend can be called after the befriending class is 445 1.1 christos fully defined, passing it a non-NULL TYPE argument naming the 446 1.1 christos befriending class type. */ 447 1.1 christos 448 1.1 christos GCC_METHOD2 (int /* bool */, add_friend, 449 1.1 christos gcc_decl, /* Argument DECL. */ 450 1.1 christos gcc_type) /* Argument TYPE. */ 451 1.1 christos 452 1.1 christos /* Return the type of a pointer to a given base type. */ 453 1.1 christos 454 1.1 christos GCC_METHOD1 (gcc_type, build_pointer_type, 455 1.1 christos gcc_type) /* Argument BASE_TYPE. */ 456 1.1 christos 457 1.1 christos /* Return the type of a reference to a given base type. */ 458 1.1 christos 459 1.1 christos GCC_METHOD2 (gcc_type, build_reference_type, 460 1.1 christos gcc_type, /* Argument BASE_TYPE. */ 461 1.1 christos enum gcc_cp_ref_qualifiers) /* Argument RQUALS. */ 462 1.1 christos 463 1.1 christos /* Create a new pointer-to-member type. MEMBER_TYPE is the data 464 1.1 christos member type, while CLASS_TYPE is the class type containing the data 465 1.1 christos member. For pointers to member functions, MEMBER_TYPE must be a 466 1.1 christos method type, and CLASS_TYPE must be specified even though it might 467 1.1 christos be possible to extract it from the method type. */ 468 1.1 christos 469 1.1 christos GCC_METHOD2 (gcc_type, build_pointer_to_member_type, 470 1.1 christos gcc_type, /* Argument CLASS_TYPE. */ 471 1.1 christos gcc_type) /* Argument MEMBER_TYPE. */ 472 1.1 christos 473 1.1 christos /* Start a template parameter list scope and enters it, so that 474 1.1 christos subsequent build_type_template_parameter and 475 1.1 christos build_value_template_parameter calls create template parameters in 476 1.1 christos the list. The list is closed by a build_decl call with 477 1.1 christos GCC_CP_SYMBOL_FUNCTION or GCC_CP_SYMBOL_CLASS, that, when the scope 478 1.1 christos is a template parameter list, declares a template function or a 479 1.1 christos template class with the then-closed parameter list. The scope in 480 1.1 christos which the new declaration is to be introduced by build_decl must be 481 1.1 christos entered before calling start_template_decl, and build_decl returns 482 1.1 christos to that scope, from the template parameter list scope, before 483 1.1 christos introducing the declaration. */ 484 1.1 christos 485 1.1 christos GCC_METHOD0 (int /* bool */, start_template_decl) 486 1.1 christos 487 1.1 christos /* Build a typename template-parameter (e.g., the T in template 488 1.1 christos <typename T = X>). Either PACK_P should be nonzero, to indicate an 489 1.1 christos argument pack (the last argument in a variadic template argument 490 1.1 christos list, as in template <typename... T>), or DEFAULT_TYPE may be 491 1.1 christos non-NULL to set the default type argument (e.g. X) for the template 492 1.1 christos parameter. FILENAME and LINE_NUMBER may specify the source 493 1.1 christos location in which the template parameter was declared. */ 494 1.1 christos 495 1.1 christos GCC_METHOD5 (gcc_type, build_type_template_parameter, 496 1.1 christos const char *, /* Argument ID. */ 497 1.1 christos int /* bool */, /* Argument PACK_P. */ 498 1.1 christos gcc_type, /* Argument DEFAULT_TYPE. */ 499 1.1 christos const char *, /* Argument FILENAME. */ 500 1.1 christos unsigned int) /* Argument LINE_NUMBER. */ 501 1.1 christos 502 1.1 christos /* Build a template template-parameter (e.g., the T in template 503 1.1 christos <template <[...]> class T = X>). DEFAULT_TEMPL may be non-NULL to 504 1.1 christos set the default type-template argument (e.g. X) for the template 505 1.1 christos template parameter. FILENAME and LINE_NUMBER may specify the 506 1.1 christos source location in which the template parameter was declared. */ 507 1.1 christos 508 1.1 christos GCC_METHOD5 (gcc_utempl, build_template_template_parameter, 509 1.1 christos const char *, /* Argument ID. */ 510 1.1 christos int /* bool */, /* Argument PACK_P. */ 511 1.1 christos gcc_utempl, /* Argument DEFAULT_TEMPL. */ 512 1.1 christos const char *, /* Argument FILENAME. */ 513 1.1 christos unsigned int) /* Argument LINE_NUMBER. */ 514 1.1 christos 515 1.1 christos /* Build a value template-parameter (e.g., the V in template <typename 516 1.1 christos T, T V> or in template <int V = X>). DEFAULT_VALUE may be non-NULL 517 1.1 christos to set the default value argument for the template parameter (e.g., 518 1.1 christos X). FILENAME and LINE_NUMBER may specify the source location in 519 1.1 christos which the template parameter was declared. */ 520 1.1 christos 521 1.1 christos GCC_METHOD5 (gcc_decl, build_value_template_parameter, 522 1.1 christos gcc_type, /* Argument TYPE. */ 523 1.1 christos const char *, /* Argument ID. */ 524 1.1 christos gcc_expr, /* Argument DEFAULT_VALUE. */ 525 1.1 christos const char *, /* Argument FILENAME. */ 526 1.1 christos unsigned int) /* Argument LINE_NUMBER. */ 527 1.1 christos 528 1.1 christos /* Build a template-dependent typename (e.g., typename T::bar or 529 1.1 christos typename T::template bart<X>). ENCLOSING_TYPE should be the 530 1.1 christos template-dependent nested name specifier (e.g., T), ID should be 531 1.1 christos the name of the member of the ENCLOSING_TYPE (e.g., bar or bart), 532 1.1 christos and TARGS should be non-NULL and specify the template arguments 533 1.1 christos (e.g. <X>) iff ID is to name a class template. 534 1.1 christos 535 1.1 christos In this and other calls, a template-dependent nested name specifier 536 1.1 christos may be a template class parameter (build_type_template_parameter), 537 1.1 christos a specialization (returned by build_dependent_type_template_id) of 538 1.1 christos a template template parameter (returned by 539 1.1 christos build_template_template_parameter) or a member type thereof 540 1.1 christos (returned by build_dependent_typename itself). */ 541 1.1 christos 542 1.1 christos GCC_METHOD3 (gcc_type, build_dependent_typename, 543 1.1 christos gcc_type, /* Argument ENCLOSING_TYPE. */ 544 1.1 christos const char *, /* Argument ID. */ 545 1.1 christos const struct gcc_cp_template_args *) /* Argument TARGS. */ 546 1.1 christos 547 1.1 christos /* Build a template-dependent class template (e.g., T::template bart). 548 1.1 christos ENCLOSING_TYPE should be the template-dependent nested name 549 1.1 christos specifier (e.g., T), ID should be the name of the class template 550 1.1 christos member of the ENCLOSING_TYPE (e.g., bart). */ 551 1.1 christos 552 1.1 christos GCC_METHOD2 (gcc_utempl, build_dependent_class_template, 553 1.1 christos gcc_type, /* Argument ENCLOSING_TYPE. */ 554 1.1 christos const char *) /* Argument ID. */ 555 1.1 christos 556 1.1 christos /* Build a template-dependent type template-id (e.g., T<A>). 557 1.1 christos TEMPLATE_DECL should be a template template parameter (e.g., the T 558 1.1 christos in template <template <[...]> class T = X>), and TARGS should 559 1.1 christos specify the template arguments (e.g. <A>). */ 560 1.1 christos 561 1.1 christos GCC_METHOD2 (gcc_type, build_dependent_type_template_id, 562 1.1 christos gcc_utempl, /* Argument TEMPLATE_DECL. */ 563 1.1 christos const struct gcc_cp_template_args *) /* Argument TARGS. */ 564 1.1 christos 565 1.1 christos /* Build a template-dependent expression (e.g., S::val or S::template 566 1.1 christos mtf<X>, or unqualified f or template tf<X>). 567 1.1 christos 568 1.1 christos ENCLOSING_SCOPE should be a template-dependent nested name 569 1.1 christos specifier (e.g., T), a resolved namespace or class decl, or NULL 570 1.1 christos for unqualified names; ID should be the name of the member of the 571 1.1 christos ENCLOSING_SCOPE (e.g., val or mtf) or unqualified overloaded 572 1.1 christos function; and TARGS should list template arguments (e.g. <X>) when 573 1.1 christos mtf or tf are to name a template function, or be NULL otherwise. 574 1.1 christos 575 1.1 christos Unqualified names and namespace- or class-qualified names can only 576 1.1 christos resolve to overloaded functions, to be used in contexts that 577 1.1 christos involve overload resolution that cannot be resolved because of 578 1.1 christos template-dependent argument or return types, such as call 579 1.1 christos expressions with template-dependent arguments, conversion 580 1.1 christos expressions to function types with template-dependent argument 581 1.1 christos types or the like. Other cases of unqualified or 582 1.1 christos non-template-dependent-qualified names should NOT use this 583 1.1 christos function, and use decl_expr to convert the appropriate function or 584 1.1 christos object declaration to an expression. 585 1.1 christos 586 1.1 christos If ID is the name of a special member function, FLAGS should be 587 1.1 christos GCC_CP_SYMBOL_FUNCTION|GCC_CP_FLAG_SPECIAL_FUNCTION, and ID should 588 1.1 christos be one of the encodings for special member functions documented in 589 1.1 christos build_decl. Otherwise, FLAGS should be GCC_CP_SYMBOL_MASK, which 590 1.1 christos suggests the symbol kind is not known (though we know it is not a 591 1.1 christos type). 592 1.1 christos 593 1.1 christos If ID denotes a conversion operator, CONV_TYPE should name the 594 1.1 christos target type of the conversion. Otherwise, CONV_TYPE must be 595 1.1 christos NULL. */ 596 1.1 christos 597 1.1 christos GCC_METHOD5 (gcc_expr, build_dependent_expr, 598 1.1 christos gcc_decl, /* Argument ENCLOSING_SCOPE. */ 599 1.1 christos enum gcc_cp_symbol_kind, /* Argument FLAGS. */ 600 1.1 christos const char *, /* Argument NAME. */ 601 1.1 christos gcc_type, /* Argument CONV_TYPE. */ 602 1.1 christos const struct gcc_cp_template_args *) /* Argument TARGS. */ 603 1.1 christos 604 1.1 christos /* Build a gcc_expr for the value VALUE in type TYPE. */ 605 1.1 christos 606 1.1 christos GCC_METHOD2 (gcc_expr, build_literal_expr, 607 1.1 christos gcc_type, /* Argument TYPE. */ 608 1.1 christos unsigned long) /* Argument VALUE. */ 609 1.1 christos 610 1.1 christos /* Build a gcc_expr that denotes DECL, the declaration of a variable 611 1.1 christos or function in namespace scope, or of a static member variable or 612 1.1 christos function. Use QUALIFIED_P to build the operand of unary & so as to 613 1.1 christos compute a pointer-to-member, rather than a regular pointer. */ 614 1.1 christos 615 1.1 christos GCC_METHOD2 (gcc_expr, build_decl_expr, 616 1.1 christos gcc_decl, /* Argument DECL. */ 617 1.1 christos int /* bool */) /* Argument QUALIFIED_P. */ 618 1.1 christos 619 1.1 christos /* Build a gcc_expr that denotes the unary operation UNARY_OP applied 620 1.1 christos to the gcc_expr OPERAND. For non-expr operands, see 621 1.1 christos unary_type_expr. Besides the UNARY_OP encodings used for operator 622 1.1 christos names, we support "pp_" for preincrement, and "mm_" for 623 1.1 christos predecrement, "nx" for noexcept, "tw" for throw, "tr" for rethrow 624 1.1 christos (pass NULL as the operand), "te" for typeid, "sz" for sizeof, "az" 625 1.1 christos for alignof, "dl" for delete, "gsdl" for ::delete, "da" for 626 1.1 christos delete[], "gsda" for ::delete[], "sp" for pack expansion, "sZ" for 627 1.1 christos sizeof...(function argument pack). */ 628 1.1 christos 629 1.1 christos GCC_METHOD2 (gcc_expr, build_unary_expr, 630 1.1 christos const char *, /* Argument UNARY_OP. */ 631 1.1 christos gcc_expr) /* Argument OPERAND. */ 632 1.1 christos 633 1.1 christos /* Build a gcc_expr that denotes the binary operation BINARY_OP 634 1.1 christos applied to gcc_exprs OPERAND1 and OPERAND2. Besides the BINARY_OP 635 1.1 christos encodings used for operator names, we support "ds" for the operator 636 1.1 christos token ".*" and "dt" for the operator token ".". When using 637 1.1 christos operators that take a name as their second operand ("." and "->") 638 1.1 christos use decl_expr to convert the gcc_decl of the member name to a 639 1.1 christos gcc_expr, if the member name wasn't created with 640 1.1 christos e.g. build_dependent_expr. */ 641 1.1 christos 642 1.1 christos GCC_METHOD3 (gcc_expr, build_binary_expr, 643 1.1 christos const char *, /* Argument BINARY_OP. */ 644 1.1 christos gcc_expr, /* Argument OPERAND1. */ 645 1.1 christos gcc_expr) /* Argument OPERAND2. */ 646 1.1 christos 647 1.1 christos /* Build a gcc_expr that denotes the ternary operation TERNARY_OP 648 1.1 christos applied to gcc_exprs OPERAND1, OPERAND2 and OPERAND3. The only 649 1.1 christos supported TERNARY_OP is "qu", for the "?:" operator. */ 650 1.1 christos 651 1.1 christos GCC_METHOD4 (gcc_expr, build_ternary_expr, 652 1.1 christos const char *, /* Argument TERNARY_OP. */ 653 1.1 christos gcc_expr, /* Argument OPERAND1. */ 654 1.1 christos gcc_expr, /* Argument OPERAND2. */ 655 1.1 christos gcc_expr) /* Argument OPERAND3. */ 656 1.1 christos 657 1.1 christos /* Build a gcc_expr that denotes the unary operation UNARY_OP applied 658 1.1 christos to the gcc_type OPERAND. Supported unary operations taking types 659 1.1 christos are "ti" for typeid, "st" for sizeof, "at" for alignof, and "sZ" 660 1.1 christos for sizeof...(template argument pack). */ 661 1.1 christos 662 1.1 christos GCC_METHOD2 (gcc_expr, build_unary_type_expr, 663 1.1 christos const char *, /* Argument UNARY_OP. */ 664 1.1 christos gcc_type) /* Argument OPERAND. */ 665 1.1 christos 666 1.1 christos /* Build a gcc_expr that denotes the binary operation BINARY_OP 667 1.1 christos applied to gcc_type OPERAND1 and gcc_expr OPERAND2. Use this for 668 1.1 christos all kinds of (single-argument) type casts ("dc", "sc", "cc", "rc" 669 1.1 christos for dynamic, static, const and reinterpret casts, respectively; 670 1.1 christos "cv" for functional or C-style casts). */ 671 1.1 christos 672 1.1 christos GCC_METHOD3 (gcc_expr, build_cast_expr, 673 1.1 christos const char *, /* Argument BINARY_OP. */ 674 1.1 christos gcc_type, /* Argument OPERAND1. */ 675 1.1 christos gcc_expr) /* Argument OPERAND2. */ 676 1.1 christos 677 1.1 christos /* Build a gcc_expr that denotes the conversion of an expression list 678 1.1 christos VALUES to TYPE, with ("tl") or without ("cv") braces, or a braced 679 1.1 christos initializer list of unspecified type (e.g., a component of another 680 1.1 christos braced initializer list; pass "il" for CONV_OP, and NULL for 681 1.1 christos TYPE). */ 682 1.1 christos 683 1.1 christos GCC_METHOD3 (gcc_expr, build_expression_list_expr, 684 1.1 christos const char *, /* Argument CONV_OP. */ 685 1.1 christos gcc_type, /* Argument TYPE. */ 686 1.1 christos const struct gcc_cp_function_args *) /* Argument VALUES. */ 687 1.1 christos 688 1.1 christos /* Build a gcc_expr that denotes a new ("nw") or new[] ("na") 689 1.1 christos expression of TYPE, with or without a GLOBAL_NS qualifier (prefix 690 1.1 christos the NEW_OP with "gs"), with or without PLACEMENT, with or without 691 1.1 christos INITIALIZER. If it's not a placement new, PLACEMENT must be NULL 692 1.1 christos (rather than a zero-length placement arg list). If there's no 693 1.1 christos specified initializer, INITIALIZER must be NULL; a zero-length arg 694 1.1 christos list stands for a default initializer. */ 695 1.1 christos 696 1.1 christos GCC_METHOD4 (gcc_expr, build_new_expr, 697 1.1 christos const char *, /* Argument NEW_OP. */ 698 1.1 christos const struct gcc_cp_function_args *, /* Argument PLACEMENT. */ 699 1.1 christos gcc_type, /* Argument TYPE. */ 700 1.1 christos const struct gcc_cp_function_args *) /* Argument INITIALIZER. */ 701 1.1 christos 702 1.1 christos /* Return a call expression that calls CALLABLE with arguments ARGS. 703 1.1 christos CALLABLE may be a function, a callable object, a pointer to 704 1.1 christos function, an unresolved expression, an unresolved overload set, an 705 1.1 christos object expression combined with a member function overload set or a 706 1.1 christos pointer-to-member. If QUALIFIED_P, CALLABLE will be interpreted as 707 1.1 christos a qualified name, preventing virtual function dispatch. */ 708 1.1 christos 709 1.1 christos GCC_METHOD3 (gcc_expr, build_call_expr, 710 1.1 christos gcc_expr, /* Argument CALLABLE. */ 711 1.1 christos int /* bool */, /* Argument QUALIFIED_P. */ 712 1.1 christos const struct gcc_cp_function_args *) /* Argument ARGS. */ 713 1.1 christos 714 1.1 christos /* Return the type of the gcc_expr OPERAND. 715 1.1 christos Use this for decltype. 716 1.1 christos For decltype (auto), pass a NULL OPERAND. 717 1.1 christos 718 1.1 christos Note: for template-dependent expressions, the result is NULL, 719 1.1 christos because the type is only computed when template argument 720 1.1 christos substitution is performed. */ 721 1.1 christos 722 1.1 christos GCC_METHOD1 (gcc_type, get_expr_type, 723 1.1 christos gcc_expr) /* Argument OPERAND. */ 724 1.1 christos 725 1.1 christos /* Introduce a specialization of a template function. 726 1.1 christos 727 1.1 christos TEMPLATE_DECL is the template function, and TARGS are the arguments 728 1.1 christos for the specialization. ADDRESS is the address of the 729 1.1 christos specialization. FILENAME and LINE_NUMBER specify the source 730 1.1 christos location associated with the template function specialization. */ 731 1.1 christos 732 1.1 christos GCC_METHOD5 (gcc_decl, build_function_template_specialization, 733 1.1 christos gcc_decl, /* Argument TEMPLATE_DECL. */ 734 1.1 christos const struct gcc_cp_template_args *, /* Argument TARGS. */ 735 1.1 christos gcc_address, /* Argument ADDRESS. */ 736 1.1 christos const char *, /* Argument FILENAME. */ 737 1.1 christos unsigned int) /* Argument LINE_NUMBER. */ 738 1.1 christos 739 1.1 christos /* Specialize a template class as an incomplete type. A definition 740 1.1 christos can be supplied later, with start_class_type. 741 1.1 christos 742 1.1 christos TEMPLATE_DECL is the template class, and TARGS are the arguments 743 1.1 christos for the specialization. FILENAME and LINE_NUMBER specify the 744 1.1 christos source location associated with the template class 745 1.1 christos specialization. */ 746 1.1 christos 747 1.1 christos GCC_METHOD4 (gcc_decl, build_class_template_specialization, 748 1.1 christos gcc_decl, /* Argument TEMPLATE_DECL. */ 749 1.1 christos const struct gcc_cp_template_args *, /* Argument TARGS. */ 750 1.1 christos const char *, /* Argument FILENAME. */ 751 1.1 christos unsigned int) /* Argument LINE_NUMBER. */ 752 1.1 christos 753 1.1 christos /* Start defining a 'class', 'struct' or 'union' type, entering its 754 1.1 christos own binding level. Initially it has no fields. 755 1.1 christos 756 1.1 christos TYPEDECL is the forward-declaration of the type, returned by 757 1.1 christos build_decl. BASE_CLASSES indicate the base classes of class NAME. 758 1.1 christos FILENAME and LINE_NUMBER specify the source location associated 759 1.1 christos with the class definition, should they be different from those of 760 1.1 christos the forward declaration. */ 761 1.1 christos 762 1.1 christos GCC_METHOD4 (gcc_type, start_class_type, 763 1.1 christos gcc_decl, /* Argument TYPEDECL. */ 764 1.1 christos const struct gcc_vbase_array *,/* Argument BASE_CLASSES. */ 765 1.1 christos const char *, /* Argument FILENAME. */ 766 1.1 christos unsigned int) /* Argument LINE_NUMBER. */ 767 1.1 christos 768 1.1 christos /* Create a new closure class type, record it as the 769 1.1 christos DISCRIMINATOR-numbered closure type in the current scope (or 770 1.1 christos associated with EXTRA_SCOPE, if non-NULL), and enter the closure 771 1.1 christos type's own binding level. This primitive would sort of combine 772 1.1 christos build_decl and start_class_type, if they could be used to introduce 773 1.1 christos a closure type. Initially it has no fields. 774 1.1 christos 775 1.1 christos FILENAME and LINE_NUMBER specify the source location associated 776 1.1 christos with the class. EXTRA_SCOPE, if non-NULL, must be a PARM_DECL of 777 1.1 christos the current function, or a FIELD_DECL of the current class. If it 778 1.1 christos is NULL, the current scope must be a function. */ 779 1.1 christos 780 1.1 christos GCC_METHOD5 (gcc_type, start_closure_class_type, 781 1.1 christos int, /* Argument DISCRIMINATOR. */ 782 1.1 christos gcc_decl, /* Argument EXTRA_SCOPE. */ 783 1.1 christos enum gcc_cp_symbol_kind, /* Argument FLAGS. */ 784 1.1 christos const char *, /* Argument FILENAME. */ 785 1.1 christos unsigned int) /* Argument LINE_NUMBER. */ 786 1.1 christos 787 1.1 christos /* Add a non-static data member to the most-recently-started 788 1.1 christos unfinished struct or union type. FIELD_NAME is the field's name. 789 1.1 christos FIELD_TYPE is the type of the field. BITSIZE and BITPOS indicate 790 1.1 christos where in the struct the field occurs. */ 791 1.1 christos 792 1.1 christos GCC_METHOD5 (gcc_decl, build_field, 793 1.1 christos const char *, /* Argument FIELD_NAME. */ 794 1.1 christos gcc_type, /* Argument FIELD_TYPE. */ 795 1.1 christos enum gcc_cp_symbol_kind, /* Argument FIELD_FLAGS. */ 796 1.1 christos unsigned long, /* Argument BITSIZE. */ 797 1.1 christos unsigned long) /* Argument BITPOS. */ 798 1.1 christos 799 1.1 christos /* After all the fields have been added to a struct, class or union, 800 1.1 christos the struct or union type must be "finished". This does some final 801 1.1 christos cleanups in GCC, and pops to the binding level that was in effect 802 1.1 christos before the matching start_class_type or 803 1.1 christos start_closure_class_type. */ 804 1.1 christos 805 1.1 christos GCC_METHOD1 (int /* bool */, finish_class_type, 806 1.1 christos unsigned long) /* Argument SIZE_IN_BYTES. */ 807 1.1 christos 808 1.1 christos /* Create a new 'enum' type, and record it in the current binding 809 1.1 christos level. The new type initially has no associated constants. 810 1.1 christos 811 1.1 christos NAME is the enum name. FILENAME and LINE_NUMBER specify its source 812 1.1 christos location. */ 813 1.1 christos 814 1.1 christos GCC_METHOD5 (gcc_type, start_enum_type, 815 1.1 christos const char *, /* Argument NAME. */ 816 1.1 christos gcc_type, /* Argument UNDERLYING_INT_TYPE. */ 817 1.1 christos enum gcc_cp_symbol_kind, /* Argument FLAGS. */ 818 1.1 christos const char *, /* Argument FILENAME. */ 819 1.1 christos unsigned int) /* Argument LINE_NUMBER. */ 820 1.1 christos 821 1.1 christos /* Add a new constant to an enum type. NAME is the constant's name 822 1.1 christos and VALUE is its value. Returns a gcc_decl for the constant. */ 823 1.1 christos 824 1.1 christos GCC_METHOD3 (gcc_decl, build_enum_constant, 825 1.1 christos gcc_type, /* Argument ENUM_TYPE. */ 826 1.1 christos const char *, /* Argument NAME. */ 827 1.1 christos unsigned long) /* Argument VALUE. */ 828 1.1 christos 829 1.1 christos /* After all the constants have been added to an enum, the type must 830 1.1 christos be "finished". This does some final cleanups in GCC. */ 831 1.1 christos 832 1.1 christos GCC_METHOD1 (int /* bool */, finish_enum_type, 833 1.1 christos gcc_type) /* Argument ENUM_TYPE. */ 834 1.1 christos 835 1.1 christos /* Create a new function type. RETURN_TYPE is the type returned by 836 1.1 christos the function, and ARGUMENT_TYPES is a vector, of length NARGS, of 837 1.1 christos the argument types. IS_VARARGS is true if the function is 838 1.1 christos varargs. */ 839 1.1 christos 840 1.1 christos GCC_METHOD3 (gcc_type, build_function_type, 841 1.1 christos gcc_type, /* Argument RETURN_TYPE. */ 842 1.1 christos const struct gcc_type_array *,/* Argument ARGUMENT_TYPES. */ 843 1.1 christos int /* bool */) /* Argument IS_VARARGS. */ 844 1.1 christos 845 1.1 christos /* Create a variant of a function type with an exception 846 1.1 christos specification. FUNCTION_TYPE is a function or method type. 847 1.1 christos EXCEPT_TYPES is an array with the list of exception types. Zero as 848 1.1 christos the array length implies throw() AKA noexcept(true); NULL as the 849 1.1 christos pointer to gcc_type_array implies noexcept(false), which is almost 850 1.1 christos equivalent (but distinguishable by the compiler) to an unspecified 851 1.1 christos exception list. */ 852 1.1 christos 853 1.1 christos GCC_METHOD2 (gcc_type, build_exception_spec_variant, 854 1.1 christos gcc_type, /* Argument FUNCTION_TYPE. */ 855 1.1 christos const struct gcc_type_array *)/* Argument EXCEPT_TYPES. */ 856 1.1 christos 857 1.1 christos /* Create a new non-static member function type. FUNC_TYPE is the 858 1.1 christos method prototype, without the implicit THIS pointer, added as a 859 1.1 christos pointer to the QUALS-qualified CLASS_TYPE. If CLASS_TYPE is NULL, 860 1.1 christos this creates a cv-qualified (member) function type not associated 861 1.1 christos with any specific class, as needed to support "typedef void f(int) 862 1.1 christos const;", which can later be used to declare member functions and 863 1.1 christos pointers to member functions. */ 864 1.1 christos 865 1.1 christos GCC_METHOD4 (gcc_type, build_method_type, 866 1.1 christos gcc_type, /* Argument CLASS_TYPE. */ 867 1.1 christos gcc_type, /* Argument FUNC_TYPE. */ 868 1.1 christos enum gcc_cp_qualifiers, /* Argument QUALS. */ 869 1.1 christos enum gcc_cp_ref_qualifiers) /* Argument RQUALS. */ 870 1.1 christos 871 1.1 christos /* Return a declaration for the (INDEX - 1)th argument of 872 1.1 christos FUNCTION_DECL, i.e., for the first argument, use zero as the index. 873 1.1 christos If FUNCTION_DECL is a non-static member function, use -1 to get the 874 1.1 christos implicit THIS parameter. */ 875 1.1 christos 876 1.1 christos GCC_METHOD2 (gcc_decl, get_function_parameter_decl, 877 1.1 christos gcc_decl, /* Argument FUNCTION_DECL. */ 878 1.1 christos int) /* Argument INDEX. */ 879 1.1 christos 880 1.1 christos /* Return a lambda expr that constructs an instance of CLOSURE_TYPE. 881 1.1 christos Only lambda exprs without any captures can be correctly created 882 1.1 christos through these mechanisms; that's all we need to support lambdas 883 1.1 christos expressions in default parameters, the only kind that may have to 884 1.1 christos be introduced through this interface. */ 885 1.1 christos 886 1.1 christos GCC_METHOD1 (gcc_expr, build_lambda_expr, 887 1.1 christos gcc_type) /* Argument CLOSURE_TYPE. */ 888 1.1 christos 889 1.1 christos /* Return an integer type with the given properties. If BUILTIN_NAME 890 1.1 christos is non-NULL, it must name a builtin integral type with the given 891 1.1 christos signedness and size, and that is the type that will be returned. */ 892 1.1 christos 893 1.1 christos GCC_METHOD3 (gcc_type, get_int_type, 894 1.1 christos int /* bool */, /* Argument IS_UNSIGNED. */ 895 1.1 christos unsigned long, /* Argument SIZE_IN_BYTES. */ 896 1.1 christos const char *) /* Argument BUILTIN_NAME. */ 897 1.1 christos 898 1.1 christos /* Return the 'char' type, a distinct type from both 'signed char' and 899 1.1 christos 'unsigned char' returned by int_type. */ 900 1.1 christos 901 1.1 christos GCC_METHOD0 (gcc_type, get_char_type) 902 1.1 christos 903 1.1 christos /* Return a floating point type with the given properties. If BUILTIN_NAME 904 1.1 christos is non-NULL, it must name a builtin integral type with the given 905 1.1 christos signedness and size, and that is the type that will be returned. */ 906 1.1 christos 907 1.1 christos GCC_METHOD2 (gcc_type, get_float_type, 908 1.1 christos unsigned long, /* Argument SIZE_IN_BYTES. */ 909 1.1 christos const char *) /* Argument BUILTIN_NAME. */ 910 1.1 christos 911 1.1 christos /* Return the 'void' type. */ 912 1.1 christos 913 1.1 christos GCC_METHOD0 (gcc_type, get_void_type) 914 1.1 christos 915 1.1 christos /* Return the 'bool' type. */ 916 1.1 christos 917 1.1 christos GCC_METHOD0 (gcc_type, get_bool_type) 918 1.1 christos 919 1.1 christos /* Return the std::nullptr_t type. */ 920 1.1 christos 921 1.1 christos GCC_METHOD0 (gcc_type, get_nullptr_type) 922 1.1 christos 923 1.1 christos /* Return the nullptr constant. */ 924 1.1 christos 925 1.1 christos GCC_METHOD0 (gcc_expr, get_nullptr_constant) 926 1.1 christos 927 1.1 christos /* Create a new array type. If NUM_ELEMENTS is -1, then the array 928 1.1 christos is assumed to have an unknown length. */ 929 1.1 christos 930 1.1 christos GCC_METHOD2 (gcc_type, build_array_type, 931 1.1 christos gcc_type, /* Argument ELEMENT_TYPE. */ 932 1.1 christos int) /* Argument NUM_ELEMENTS. */ 933 1.1 christos 934 1.1 christos /* Create a new array type. NUM_ELEMENTS is a template-dependent 935 1.1 christos expression. */ 936 1.1 christos 937 1.1 christos GCC_METHOD2 (gcc_type, build_dependent_array_type, 938 1.1 christos gcc_type, /* Argument ELEMENT_TYPE. */ 939 1.1 christos gcc_expr) /* Argument NUM_ELEMENTS. */ 940 1.1 christos 941 1.1 christos /* Create a new variably-sized array type. UPPER_BOUND_NAME is the 942 1.1 christos name of a local variable that holds the upper bound of the array; 943 1.1 christos it is one less than the array size. */ 944 1.1 christos 945 1.1 christos GCC_METHOD2 (gcc_type, build_vla_array_type, 946 1.1 christos gcc_type, /* Argument ELEMENT_TYPE. */ 947 1.1 christos const char *) /* Argument UPPER_BOUND_NAME. */ 948 1.1 christos 949 1.1 christos /* Return a qualified variant of a given base type. QUALIFIERS says 950 1.1 christos which qualifiers to use; it is composed of or'd together 951 1.1 christos constants from 'enum gcc_cp_qualifiers'. */ 952 1.1 christos 953 1.1 christos GCC_METHOD2 (gcc_type, build_qualified_type, 954 1.1 christos gcc_type, /* Argument UNQUALIFIED_TYPE. */ 955 1.1 christos enum gcc_cp_qualifiers) /* Argument QUALIFIERS. */ 956 1.1 christos 957 1.1 christos /* Build a complex type given its element type. */ 958 1.1 christos 959 1.1 christos GCC_METHOD1 (gcc_type, build_complex_type, 960 1.1 christos gcc_type) /* Argument ELEMENT_TYPE. */ 961 1.1 christos 962 1.1 christos /* Build a vector type given its element type and number of 963 1.1 christos elements. */ 964 1.1 christos 965 1.1 christos GCC_METHOD2 (gcc_type, build_vector_type, 966 1.1 christos gcc_type, /* Argument ELEMENT_TYPE. */ 967 1.1 christos int) /* Argument NUM_ELEMENTS. */ 968 1.1 christos 969 1.1 christos /* Build a constant. NAME is the constant's name and VALUE is its 970 1.1 christos value. FILENAME and LINE_NUMBER refer to the type's source 971 1.1 christos location. If this is not known, FILENAME can be NULL and 972 1.1 christos LINE_NUMBER can be 0. */ 973 1.1 christos 974 1.1 christos GCC_METHOD5 (int /* bool */, build_constant, 975 1.1 christos gcc_type, /* Argument TYPE. */ 976 1.1 christos const char *, /* Argument NAME. */ 977 1.1 christos unsigned long, /* Argument VALUE. */ 978 1.1 christos const char *, /* Argument FILENAME. */ 979 1.1 christos unsigned int) /* Argument LINE_NUMBER. */ 980 1.1 christos 981 1.1 christos /* Emit an error and return an error type object. */ 982 1.1 christos 983 1.1 christos GCC_METHOD1 (gcc_type, error, 984 1.1 christos const char *) /* Argument MESSAGE. */ 985 1.1 christos 986 1.1 christos /* Declare a static_assert with the given CONDITION and ERRORMSG at 987 1.1 christos FILENAME:LINE_NUMBER. */ 988 1.1 christos 989 1.1 christos GCC_METHOD4 (int /* bool */, add_static_assert, 990 1.1 christos gcc_expr, /* Argument CONDITION. */ 991 1.1 christos const char *, /* Argument ERRORMSG. */ 992 1.1 christos const char *, /* Argument FILENAME. */ 993 1.1 christos unsigned int) /* Argument LINE_NUMBER. */ 994 1.1 christos 995 1.1 christos #if 0 996 1.1 christos 997 1.1 christos /* FIXME: We don't want to expose the internal implementation detail 998 1.1 christos that default parms are stored in function types, and it's not clear 999 1.1 christos how this or other approaches would interact with the type sharing 1000 1.1 christos of e.g. ctor clones, so we're leaving this out, since default args 1001 1.1 christos are not even present in debug information anyway. Besides, the set 1002 1.1 christos of default args for a function may grow within its scope, and vary 1003 1.1 christos independently in other scopes. */ 1004 1.1 christos 1005 1.1 christos /* Create a modified version of a function type that has default 1006 1.1 christos values for some of its arguments. The returned type should ONLY be 1007 1.1 christos used to define functions or methods, never to declare parameters, 1008 1.1 christos variables, types or the like. 1009 1.1 christos 1010 1.1 christos DEFAULTS must have at most as many N_ELEMENTS as there are 1011 1.1 christos arguments without default values in FUNCTION_TYPE. Say, if 1012 1.1 christos FUNCTION_TYPE has an argument list such as (T1, T2, T3, T4 = V0) 1013 1.1 christos and DEFAULTS has 2 elements (V1, V2), the returned type will have 1014 1.1 christos the following argument list: (T1, T2 = V1, T3 = V2, T4 = V0). 1015 1.1 christos 1016 1.1 christos Any NULL expressions in DEFAULTS will be marked as deferred, and 1017 1.1 christos they should be filled in with set_deferred_function_default_args. */ 1018 1.1 christos 1019 1.1 christos GCC_METHOD2 (gcc_type, add_function_default_args, 1020 1.1 christos gcc_type, /* Argument FUNCTION_TYPE. */ 1021 1.1 christos const struct gcc_cp_function_args *) /* Argument DEFAULTS. */ 1022 1.1 christos 1023 1.1 christos /* Fill in the first deferred default args in FUNCTION_DECL with the 1024 1.1 christos expressions given in DEFAULTS. This can be used when the 1025 1.1 christos declaration of a parameter is needed to create a default 1026 1.1 christos expression, such as taking the size of an earlier parameter, or 1027 1.1 christos building a lambda expression in the parameter's context. */ 1028 1.1 christos 1029 1.1 christos GCC_METHOD2 (int /* bool */, set_deferred_function_default_args, 1030 1.1 christos gcc_decl, /* Argument FUNCTION_DECL. */ 1031 1.1 christos const struct gcc_cp_function_args *) /* Argument DEFAULTS. */ 1032 1.1 christos 1033 1.1 christos #endif 1034 1.1 christos 1035 1.1 christos 1036 1.1 christos /* When you add entry points, add them at the end, so that the new API 1037 1.1 christos version remains compatible with the old version. 1038 1.1 christos 1039 1.1 christos The following conventions have been observed as to naming entry points: 1040 1.1 christos 1041 1.1 christos - build_* creates (and maybe records) something and returns it; 1042 1.1 christos - add_* creates and records something, but doesn't return it; 1043 1.1 christos - get_* obtains something without creating it; 1044 1.1 christos - start_* marks the beginning of a compound (type, list, ...); 1045 1.1 christos - finish_* completes the compound when needed. 1046 1.1 christos 1047 1.1 christos Entry points that return an int (bool) and don't have a return value 1048 1.1 christos specification return nonzero (true) on success and zero (false) on 1049 1.1 christos failure. This is in line with libcc1's conventions of returning a 1050 1.1 christos zero-initialized value in case of e.g. a transport error. */ 1051