1 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 // -*- Mode: C++ -*- 3 // 4 // Copyright (C) 2013-2022 Red Hat, Inc. 5 6 /// @file 7 8 #ifndef __ABG_IRFWD_H__ 9 #define __ABG_IRFWD_H__ 10 11 #include <stdint.h> 12 #include <cstddef> 13 #include <cstdlib> 14 #include <list> 15 #include <memory> 16 #include <ostream> 17 #include <string> 18 #include <typeinfo> 19 #include <unordered_map> 20 #include <utility> // for std::rel_ops, at least. 21 #include <vector> 22 #include "abg-interned-str.h" 23 #include "abg-hash.h" 24 25 /// Toplevel namespace for libabigail. 26 namespace abigail 27 { 28 /** 29 @mainpage libabigail 30 31 This is the API documentation of the Application Binary 32 Interface Generic Analysis and Instrumentation Library, aka, 33 <em>libabigail</em>. 34 35 Check out <a href="http://sourceware.org/libabigail"> the project 36 homepage</a>! 37 38 The current libabigail source code can be browsed at 39 http://sourceware.org/git/gitweb.cgi?p=libabigail.git 40 41 It can be checked out with: 42 <em>git clone git://sourceware.org/git/libabigail.git</em> 43 44 The mailing list to send messages and patches to is 45 libabigail@sourceware.org. 46 47 You can hang out with libabigail developers and users on irc at 48 irc://irc.oftc.net\#libabigail. 49 */ 50 51 // Inject some types. 52 using std::shared_ptr; 53 using std::weak_ptr; 54 using std::unordered_map; 55 using std::string; 56 using std::vector; 57 58 // Pull in relational operators. 59 using namespace std::rel_ops; 60 61 namespace ir 62 { 63 64 // Forward declarations for corpus. 65 66 class corpus; 67 typedef shared_ptr<corpus> corpus_sptr; 68 69 class corpus_group; 70 typedef shared_ptr<corpus_group> corpus_group_sptr; 71 72 // Forward declarations for ir. 73 74 class ir_node_visitor; 75 76 struct ir_traversable_base; 77 78 /// Convenience typedef for a shared pointer to @ref 79 /// ir_traversable_base. 80 typedef shared_ptr<ir_traversable_base> ir_traversable_base_sptr; 81 82 class environment; 83 /// Convenience typedef for a shared pointer to an @ref environment 84 typedef shared_ptr<environment> environment_sptr; 85 86 class location; 87 class location_manager; 88 89 class type_or_decl_base; 90 /// A convenience typedef for a shared_ptr to @ref type_or_decl_base. 91 typedef shared_ptr<type_or_decl_base> type_or_decl_base_sptr; 92 93 class type_base; 94 95 // Convenience typedef for a shared pointer on a @ref type_base 96 typedef shared_ptr<type_base> type_base_sptr; 97 98 /// Convenience typedef for a weak pointer on a @ref type_base 99 typedef weak_ptr<type_base> type_base_wptr; 100 101 /// Convenience typedef for a weak pointer to a @ref corpus. 102 typedef weak_ptr<corpus> corpus_wptr; 103 104 class translation_unit; 105 /// Convenience typedef for a shared pointer on a @ref 106 /// translation_unit type. 107 typedef shared_ptr<translation_unit> translation_unit_sptr; 108 /// Convenience typedef for a map that associates a string to a 109 /// translation unit. 110 typedef unordered_map<string, translation_unit_sptr> string_tu_map_type; 111 112 /// A convenience typedef for a vector of type_base_wptr. 113 typedef vector<type_base_wptr> type_base_wptrs_type; 114 115 /// A convenience typedef for a map which key is an interned_string 116 /// and which value is a vector of type_base_wptr. 117 typedef unordered_map<interned_string, 118 type_base_wptrs_type, 119 hash_interned_string> istring_type_base_wptrs_map_type; 120 121 class decl_base; 122 123 // Convenience typedef for a smart pointer on @ref decl_base. 124 typedef shared_ptr<decl_base> decl_base_sptr; 125 126 class type_decl; 127 /// Convenience typedef for a shared pointer on a @ref type_decl. 128 typedef shared_ptr<type_decl> type_decl_sptr; 129 130 131 class typedef_decl; 132 133 /// Convenience typedef for a shared pointer on a @ref typedef_decl. 134 typedef shared_ptr<typedef_decl> typedef_decl_sptr; 135 136 /// Convenience typedef for a weak pointer on a @ref typedef_decl. 137 typedef weak_ptr<typedef_decl> typedef_decl_wptr; 138 139 class enum_type_decl; 140 141 /// Convenience typedef for shared pointer to a @ref enum_type_decl. 142 typedef shared_ptr<enum_type_decl> enum_type_decl_sptr; 143 144 /// Convenience typedef for a vector of @ref enum_type_decl_sptr 145 typedef vector<enum_type_decl_sptr> enums_type; 146 147 /// Convenience typedef for a weak pointer to a @ref decl_base. 148 typedef weak_ptr<decl_base> decl_base_wptr; 149 150 class class_or_union; 151 152 typedef shared_ptr<class_or_union> class_or_union_sptr; 153 typedef weak_ptr<class_or_union> class_or_union_wptr; 154 155 class scope_type_decl; 156 157 class class_decl; 158 159 /// Convenience typedef for a shared pointer on a @ref class_decl 160 typedef shared_ptr<class_decl> class_decl_sptr; 161 162 /// Convenience typedef for a vector of @ref class_decl_sptr 163 typedef vector<class_decl_sptr> classes_type; 164 165 /// Convenience typedef for a weak pointer on a @ref class_decl. 166 typedef weak_ptr<class_decl> class_decl_wptr; 167 168 class union_decl; 169 170 typedef shared_ptr<union_decl> union_decl_sptr; 171 172 class function_type; 173 /// Convenience typedef for a shared pointer on a @ref function_type 174 typedef shared_ptr<function_type> function_type_sptr; 175 176 /// Convenience typedef fo a vector of @ref function_type_sptr 177 typedef vector<function_type_sptr> function_types_type; 178 179 /// Convenience typedef for a weak pointer on a @ref function_type 180 typedef weak_ptr<function_type> function_type_wptr; 181 182 class method_type; 183 184 /// Convenience typedef for shared pointer to @ref method_type. 185 typedef shared_ptr<method_type> method_type_sptr; 186 187 class pointer_type_def; 188 189 /// Convenience typedef for a shared pointer on a @ref pointer_type_def 190 typedef shared_ptr<pointer_type_def> pointer_type_def_sptr; 191 192 class qualified_type_def; 193 194 typedef shared_ptr<qualified_type_def> qualified_type_def_sptr; 195 196 class reference_type_def; 197 198 /// Convenience typedef for a shared pointer on a @ref reference_type_def 199 typedef shared_ptr<reference_type_def> reference_type_def_sptr; 200 201 class array_type_def; 202 203 /// Convenience typedef for a shared pointer on a @ref array_type_def 204 typedef shared_ptr<array_type_def> array_type_def_sptr; 205 206 class subrange_type; 207 208 class dm_context_rel; 209 210 /// A convenience typedef for a shared pointer to dm_context_rel. 211 typedef shared_ptr<dm_context_rel> dm_context_rel_sptr; 212 213 class var_decl; 214 215 /// Convenience typedef for a shared pointer on a @ref var_decl 216 typedef shared_ptr<var_decl> var_decl_sptr; 217 218 /// Convenience typedef for a weak pointer on a @ref var_decl 219 typedef weak_ptr<var_decl> var_decl_wptr; 220 221 typedef unordered_map<interned_string, 222 var_decl*, 223 hash_interned_string> istring_var_decl_ptr_map_type; 224 225 class scope_decl; 226 227 /// Convenience typedef for a shared pointer on a @ref scope_decl. 228 typedef shared_ptr<scope_decl> scope_decl_sptr; 229 230 class function_decl; 231 232 /// Convenience typedef for a shared pointer on a @ref function_decl 233 typedef shared_ptr<function_decl> function_decl_sptr; 234 235 typedef unordered_map<interned_string, 236 function_decl*, 237 hash_interned_string> istring_function_decl_ptr_map_type; 238 239 class method_decl; 240 241 typedef shared_ptr<method_decl> method_decl_sptr; 242 243 class mem_fn_context_rel; 244 245 /// A convenience typedef for a shared pointer to @ref 246 /// mem_fn_context_rel. 247 typedef shared_ptr<mem_fn_context_rel> mem_fn_context_rel_sptr; 248 249 class namespace_decl; 250 251 /// Convenience typedef for a shared pointer on namespace_decl. 252 typedef shared_ptr<namespace_decl> namespace_decl_sptr; 253 254 class class_tdecl; 255 256 /// Convenience typedef for a shared pointer on a @ref class_tdecl 257 typedef shared_ptr<class_tdecl> class_tdecl_sptr; 258 259 class function_tdecl; 260 261 /// Convenience typedef for a shared pointer on a @ref function_tdecl 262 typedef shared_ptr<function_tdecl> function_tdecl_sptr; 263 264 class global_scope; 265 266 /// Convenience typedef for shared pointer on @ref global_scope. 267 typedef shared_ptr<global_scope> global_scope_sptr; 268 269 class node_visitor; 270 271 class template_decl; 272 273 /// Convenience typedef for a shared pointer to @ref template_decl 274 typedef shared_ptr<template_decl> template_decl_sptr; 275 276 /// Convenience typedef for a weak pointer to template_decl 277 typedef weak_ptr<template_decl> template_decl_wptr; 278 279 class template_parameter; 280 281 /// Convenience typedef for shared pointer to template parameter 282 typedef shared_ptr<template_parameter> template_parameter_sptr; 283 284 class non_type_tparameter; 285 286 /// Convenience typedef for shared pointer to @ref 287 /// non_type_template_parameter 288 typedef shared_ptr<non_type_tparameter> non_type_tparameter_sptr; 289 290 class type_tparameter; 291 292 class template_tparameter; 293 294 /// Convenience typedef for a shared_ptr to @ref template_tparameter. 295 typedef shared_ptr<template_tparameter> template_tparameter_sptr; 296 297 /// Convenience typedef for a shared pointer to @ref type_tparameter. 298 typedef shared_ptr<type_tparameter> type_tparameter_sptr; 299 300 class type_composition; 301 302 class member_function_template; 303 typedef shared_ptr<member_function_template> member_function_template_sptr; 304 typedef vector<member_function_template_sptr> member_function_templates; 305 306 class member_class_template; 307 typedef shared_ptr<member_class_template> member_class_template_sptr; 308 typedef vector<member_class_template_sptr> member_class_templates; 309 310 /// Convenience typedef for shared pointer to type_composition 311 typedef shared_ptr<type_composition> type_composition_sptr; 312 313 decl_base_sptr 314 add_decl_to_scope(decl_base_sptr, scope_decl*); 315 316 decl_base_sptr 317 add_decl_to_scope(decl_base_sptr, const scope_decl_sptr&); 318 319 const global_scope* 320 get_global_scope(const decl_base&); 321 322 const global_scope* 323 get_global_scope(const decl_base*); 324 325 const global_scope* 326 get_global_scope(const decl_base_sptr); 327 328 translation_unit* 329 get_translation_unit(const decl_base&); 330 331 translation_unit* 332 get_translation_unit(const decl_base*); 333 334 translation_unit* 335 get_translation_unit(const decl_base_sptr); 336 337 bool 338 is_global_scope(const scope_decl&); 339 340 const global_scope* 341 is_global_scope(const scope_decl*); 342 343 bool 344 is_global_scope(const scope_decl_sptr); 345 346 bool 347 is_at_global_scope(const decl_base&); 348 349 bool 350 is_at_global_scope(const decl_base_sptr); 351 352 bool 353 is_at_global_scope(const decl_base*); 354 355 class_or_union* 356 is_at_class_scope(const decl_base_sptr); 357 358 class_or_union* 359 is_at_class_scope(const decl_base*); 360 361 class_or_union* 362 is_at_class_scope(const decl_base&); 363 364 bool 365 is_at_template_scope(const decl_base_sptr); 366 367 bool 368 is_template_parameter(const decl_base_sptr); 369 370 function_decl* 371 is_function_decl(const type_or_decl_base*); 372 373 function_decl_sptr 374 is_function_decl(const type_or_decl_base_sptr&); 375 376 bool 377 is_function_decl(const type_or_decl_base&); 378 379 decl_base* 380 is_decl(const type_or_decl_base*); 381 382 decl_base_sptr 383 is_decl(const type_or_decl_base_sptr&); 384 385 decl_base* 386 is_decl_slow(const type_or_decl_base*); 387 388 decl_base_sptr 389 is_decl_slow(const type_or_decl_base_sptr&); 390 391 bool 392 is_type(const type_or_decl_base&); 393 394 type_base* 395 is_type(const type_or_decl_base*); 396 397 type_base_sptr 398 is_type(const type_or_decl_base_sptr& tod); 399 400 bool 401 is_anonymous_type(const type_base*); 402 403 bool 404 is_anonymous_type(const type_base_sptr&); 405 406 const type_decl* 407 is_type_decl(const type_or_decl_base*); 408 409 type_decl_sptr 410 is_type_decl(const type_or_decl_base_sptr&); 411 412 type_decl* 413 is_integral_type(const type_or_decl_base*); 414 415 type_decl_sptr 416 is_integral_type(const type_or_decl_base_sptr&); 417 418 typedef_decl_sptr 419 is_typedef(const type_or_decl_base_sptr); 420 421 const typedef_decl* 422 is_typedef(const type_base*); 423 424 typedef_decl* 425 is_typedef(type_base*); 426 427 enum_type_decl_sptr 428 is_compatible_with_enum_type(const type_base_sptr&); 429 430 enum_type_decl_sptr 431 is_compatible_with_enum_type(const decl_base_sptr&); 432 433 enum_type_decl_sptr 434 is_enum_type(const type_or_decl_base_sptr&); 435 436 const enum_type_decl* 437 is_enum_type(const type_or_decl_base*); 438 439 bool 440 is_class_type(const type_or_decl_base&); 441 442 class_decl* 443 is_class_type(const type_or_decl_base*); 444 445 class_decl_sptr 446 is_class_type(const type_or_decl_base_sptr&); 447 448 bool 449 is_declaration_only_class_or_union_type(const type_base *t); 450 451 bool 452 is_declaration_only_class_or_union_type(const type_base_sptr&); 453 454 class_or_union* 455 is_class_or_union_type(const type_or_decl_base*); 456 457 class_or_union_sptr 458 is_class_or_union_type(const type_or_decl_base_sptr&); 459 460 bool 461 is_union_type(const type_or_decl_base&); 462 463 union_decl* 464 is_union_type(const type_or_decl_base*); 465 466 union_decl_sptr 467 is_union_type(const type_or_decl_base_sptr&); 468 469 class_decl_sptr 470 is_compatible_with_class_type(const type_base_sptr&); 471 472 class_decl_sptr 473 is_compatible_with_class_type(const decl_base_sptr&); 474 475 pointer_type_def* 476 is_pointer_type(type_or_decl_base*); 477 478 const pointer_type_def* 479 is_pointer_type(const type_or_decl_base*); 480 481 pointer_type_def_sptr 482 is_pointer_type(const type_or_decl_base_sptr&); 483 484 reference_type_def* 485 is_reference_type(type_or_decl_base*); 486 487 const reference_type_def* 488 is_reference_type(const type_or_decl_base*); 489 490 reference_type_def_sptr 491 is_reference_type(const type_or_decl_base_sptr&); 492 493 const type_base* 494 is_void_pointer_type(const type_base*); 495 496 qualified_type_def* 497 is_qualified_type(const type_or_decl_base*); 498 499 qualified_type_def_sptr 500 is_qualified_type(const type_or_decl_base_sptr&); 501 502 function_type_sptr 503 is_function_type(const type_or_decl_base_sptr&); 504 505 function_type* 506 is_function_type(type_or_decl_base*); 507 508 const function_type* 509 is_function_type(const type_or_decl_base*); 510 511 method_type_sptr 512 is_method_type(const type_or_decl_base_sptr&); 513 514 const method_type* 515 is_method_type(const type_or_decl_base*); 516 517 method_type* 518 is_method_type(type_or_decl_base*); 519 520 class_or_union_sptr 521 look_through_decl_only_class(const class_or_union&); 522 523 class_or_union_sptr 524 look_through_decl_only_class(class_or_union_sptr); 525 526 class_or_union* 527 look_through_decl_only_class(class_or_union*); 528 529 enum_type_decl_sptr 530 look_through_decl_only_enum(const enum_type_decl&); 531 532 enum_type_decl_sptr 533 look_through_decl_only_enum(enum_type_decl_sptr); 534 535 decl_base_sptr 536 look_through_decl_only(const decl_base&); 537 538 decl_base* 539 look_through_decl_only(decl_base*); 540 541 decl_base_sptr 542 look_through_decl_only(const decl_base_sptr&); 543 544 var_decl* 545 is_var_decl(const type_or_decl_base*); 546 547 var_decl_sptr 548 is_var_decl(const type_or_decl_base_sptr&); 549 550 namespace_decl_sptr 551 is_namespace(const decl_base_sptr&); 552 553 namespace_decl* 554 is_namespace(const decl_base*); 555 556 bool 557 is_template_parm_composition_type(const decl_base_sptr); 558 559 bool 560 is_template_decl(const decl_base_sptr); 561 562 bool 563 is_function_template_pattern(const decl_base_sptr); 564 565 566 decl_base_sptr 567 insert_decl_into_scope(decl_base_sptr, 568 vector<decl_base_sptr >::iterator, 569 scope_decl*); 570 571 decl_base_sptr 572 insert_decl_into_scope(decl_base_sptr, 573 vector<decl_base_sptr >::iterator, 574 scope_decl_sptr); 575 576 bool 577 has_scope(const decl_base&); 578 579 bool 580 has_scope(const decl_base_sptr); 581 582 bool 583 is_member_decl(const decl_base_sptr); 584 585 bool 586 is_member_decl(const decl_base*); 587 588 bool 589 is_member_decl(const decl_base&); 590 591 scope_decl* 592 is_scope_decl(decl_base*); 593 594 scope_decl_sptr 595 is_scope_decl(const decl_base_sptr&); 596 597 bool 598 is_member_type(const type_base_sptr&); 599 600 bool 601 is_user_defined_type(const type_base*); 602 603 bool 604 is_user_defined_type(const type_base_sptr&); 605 606 void 607 remove_decl_from_scope(decl_base_sptr); 608 609 bool 610 get_member_is_static(const decl_base&); 611 612 bool 613 get_member_is_static(const decl_base*); 614 615 bool 616 get_member_is_static(const decl_base_sptr&); 617 618 void 619 set_member_is_static(decl_base&, bool); 620 621 void 622 set_member_is_static(const decl_base_sptr&, bool); 623 624 bool 625 is_data_member(const var_decl&); 626 627 var_decl* 628 is_data_member(const type_or_decl_base*); 629 630 bool 631 is_data_member(const var_decl*); 632 633 var_decl_sptr 634 is_data_member(const type_or_decl_base_sptr&); 635 636 bool 637 is_data_member(const var_decl_sptr); 638 639 var_decl_sptr 640 is_data_member(const decl_base_sptr&); 641 642 var_decl* 643 is_data_member(const decl_base *); 644 645 var_decl* 646 is_data_member(const decl_base *); 647 648 const var_decl_sptr 649 get_next_data_member(const class_or_union_sptr&, const var_decl_sptr&); 650 651 var_decl_sptr 652 get_last_data_member(const class_or_union_sptr&); 653 654 bool 655 is_anonymous_data_member(const decl_base&); 656 657 const var_decl* 658 is_anonymous_data_member(const type_or_decl_base*); 659 660 const var_decl* 661 is_anonymous_data_member(const decl_base*); 662 663 var_decl_sptr 664 is_anonymous_data_member(const type_or_decl_base_sptr&); 665 666 var_decl_sptr 667 is_anonymous_data_member(const decl_base_sptr&); 668 669 var_decl_sptr 670 is_anonymous_data_member(const var_decl_sptr&); 671 672 const var_decl* 673 is_anonymous_data_member(const var_decl*); 674 675 bool 676 is_anonymous_data_member(const var_decl&); 677 678 const var_decl_sptr 679 get_first_non_anonymous_data_member(const var_decl_sptr); 680 681 var_decl_sptr 682 find_data_member_from_anonymous_data_member(const var_decl_sptr&, 683 const string&); 684 685 class_or_union* 686 anonymous_data_member_to_class_or_union(const var_decl*); 687 688 class_or_union_sptr 689 anonymous_data_member_to_class_or_union(const var_decl_sptr&); 690 691 bool 692 scope_anonymous_or_typedef_named(const decl_base&); 693 694 bool 695 is_anonymous_or_typedef_named(const decl_base&); 696 697 const class_or_union_sptr 698 data_member_has_anonymous_type(const var_decl& d); 699 700 const class_or_union_sptr 701 data_member_has_anonymous_type(const var_decl* d); 702 703 const class_or_union_sptr 704 data_member_has_anonymous_type(const var_decl_sptr& d); 705 706 array_type_def* 707 is_array_type(const type_or_decl_base* decl); 708 709 array_type_def_sptr 710 is_array_type(const type_or_decl_base_sptr& decl); 711 712 array_type_def_sptr 713 is_array_of_qualified_element(const type_base_sptr&); 714 715 qualified_type_def_sptr 716 is_array_of_qualified_element(const array_type_def_sptr&); 717 718 array_type_def_sptr 719 is_typedef_of_array(const type_base_sptr&); 720 721 void 722 set_data_member_offset(var_decl_sptr, uint64_t); 723 724 uint64_t 725 get_data_member_offset(const var_decl&); 726 727 uint64_t 728 get_data_member_offset(const var_decl_sptr); 729 730 uint64_t 731 get_data_member_offset(const decl_base_sptr); 732 733 uint64_t 734 get_absolute_data_member_offset(const var_decl&); 735 736 bool 737 get_next_data_member_offset(const class_or_union_sptr&, 738 const var_decl_sptr&, 739 uint64_t&); 740 741 uint64_t 742 get_var_size_in_bits(const var_decl_sptr&); 743 744 void 745 set_data_member_is_laid_out(var_decl_sptr, bool); 746 747 bool 748 get_data_member_is_laid_out(const var_decl&); 749 750 bool 751 get_data_member_is_laid_out(const var_decl_sptr); 752 753 bool 754 is_member_function(const function_decl&); 755 756 bool 757 is_member_function(const function_decl*); 758 759 bool 760 is_member_function(const function_decl_sptr&); 761 762 bool 763 get_member_function_is_ctor(const function_decl&); 764 765 bool 766 get_member_function_is_ctor(const function_decl_sptr&); 767 768 void 769 set_member_function_is_ctor(const function_decl&, bool); 770 771 void 772 set_member_function_is_ctor(const function_decl_sptr&, bool); 773 774 bool 775 get_member_function_is_dtor(const function_decl&); 776 777 bool 778 get_member_function_is_dtor(const function_decl_sptr&); 779 780 void 781 set_member_function_is_dtor(function_decl&, bool); 782 783 void 784 set_member_function_is_dtor(const function_decl_sptr&, bool); 785 786 bool 787 get_member_function_is_const(const function_decl&); 788 789 bool 790 get_member_function_is_const(const function_decl_sptr&); 791 792 void 793 set_member_function_is_const(function_decl&, bool); 794 795 void 796 set_member_function_is_const(const function_decl_sptr&, bool); 797 798 bool 799 member_function_has_vtable_offset(const function_decl&); 800 801 ssize_t 802 get_member_function_vtable_offset(const function_decl&); 803 804 ssize_t 805 get_member_function_vtable_offset(const function_decl_sptr&); 806 807 void 808 set_member_function_vtable_offset(const function_decl& f, 809 ssize_t s); 810 811 void 812 set_member_function_vtable_offset(const function_decl_sptr &f, 813 ssize_t s); 814 815 bool 816 get_member_function_is_virtual(const function_decl&); 817 818 bool 819 get_member_function_is_virtual(const function_decl_sptr&); 820 821 bool 822 get_member_function_is_virtual(const function_decl*); 823 824 void 825 set_member_function_is_virtual(function_decl&, bool); 826 827 void 828 set_member_function_is_virtual(const function_decl_sptr&, bool); 829 830 type_base_sptr 831 strip_typedef(const type_base_sptr); 832 833 decl_base_sptr 834 strip_useless_const_qualification(const qualified_type_def_sptr t); 835 836 void 837 strip_redundant_quals_from_underyling_types(const qualified_type_def_sptr&); 838 839 type_base_sptr 840 peel_typedef_type(const type_base_sptr&); 841 842 const type_base* 843 peel_typedef_type(const type_base*); 844 845 type_base_sptr 846 peel_pointer_type(const type_base_sptr&); 847 848 const type_base* 849 peel_pointer_type(const type_base*); 850 851 type_base_sptr 852 peel_reference_type(const type_base_sptr&); 853 854 const type_base* 855 peel_reference_type(const type_base*); 856 857 const type_base_sptr 858 peel_array_type(const type_base_sptr&); 859 860 const type_base* 861 peel_array_type(const type_base*); 862 863 const type_base* 864 peel_qualified_type(const type_base*); 865 866 const type_base_sptr 867 peel_qualified_type(const type_base_sptr&); 868 869 type_base* 870 peel_qualified_or_typedef_type(const type_base* type); 871 872 type_base_sptr 873 peel_qualified_or_typedef_type(const type_base_sptr &type); 874 875 type_base_sptr 876 peel_typedef_pointer_or_reference_type(const type_base_sptr); 877 878 type_base* 879 peel_typedef_pointer_or_reference_type(const type_base* type); 880 881 type_base* 882 peel_typedef_pointer_or_reference_type(const type_base* type, 883 bool peel_qual_type); 884 885 type_base* 886 peel_pointer_or_reference_type(const type_base *type, 887 bool peel_qualified_type = true); 888 889 array_type_def_sptr 890 clone_array(const array_type_def_sptr& array); 891 892 typedef_decl_sptr 893 clone_typedef(const typedef_decl_sptr& t); 894 895 qualified_type_def_sptr 896 clone_qualified_type(const qualified_type_def_sptr& t); 897 898 type_base_sptr 899 clone_array_tree(const type_base_sptr t); 900 901 string 902 get_name(const type_or_decl_base*, bool qualified = true); 903 904 string 905 get_name(const type_or_decl_base_sptr&, 906 bool qualified = true); 907 908 location 909 get_location(const type_base_sptr& type); 910 911 location 912 get_location(const decl_base_sptr& decl); 913 914 string 915 build_qualified_name(const scope_decl* scope, const string& name); 916 917 string 918 build_qualified_name(const scope_decl* scope, 919 const type_base_sptr& type); 920 921 scope_decl* 922 get_type_scope(type_base*); 923 924 scope_decl* 925 get_type_scope(const type_base_sptr&); 926 927 interned_string 928 get_type_name(const type_base_sptr&, 929 bool qualified = true, 930 bool internal = false); 931 932 interned_string 933 get_type_name(const type_base*, 934 bool qualified = true, 935 bool internal = false); 936 937 interned_string 938 get_type_name(const type_base&, 939 bool qualified = true, 940 bool internal = false); 941 942 interned_string 943 get_name_of_pointer_to_type(const type_base& pointed_to_type, 944 bool qualified = true, 945 bool internal = false); 946 947 interned_string 948 get_name_of_reference_to_type(const type_base& pointed_to_type, 949 bool lvalue_reference = false, 950 bool qualified = true, 951 bool internal = false); 952 953 interned_string 954 get_function_type_name(const function_type_sptr&, 955 bool internal = false); 956 957 interned_string 958 get_function_type_name(const function_type*, bool internal = false); 959 960 interned_string 961 get_function_type_name(const function_type&, bool internal = false); 962 963 interned_string 964 get_method_type_name(const method_type_sptr&, bool internal = false); 965 966 interned_string 967 get_method_type_name(const method_type*, bool internal = false); 968 969 interned_string 970 get_method_type_name(const method_type&, bool internal = false); 971 972 string 973 get_pretty_representation(const decl_base*, bool internal = false); 974 975 string 976 get_pretty_representation(const type_base*, bool internal = false); 977 978 string 979 get_pretty_representation(const type_or_decl_base*, bool internal = false); 980 981 string 982 get_pretty_representation(const type_or_decl_base_sptr&, 983 bool internal = false); 984 985 string 986 get_pretty_representation(const decl_base_sptr&, bool internal = false); 987 988 string 989 get_pretty_representation(const type_base_sptr&, bool internal = false); 990 991 string 992 get_pretty_representation(const function_type&, bool internal = false); 993 994 string 995 get_pretty_representation(const function_type*, bool internal = false); 996 997 string 998 get_pretty_representation(const function_type_sptr&, 999 bool internal = false); 1000 1001 string 1002 get_pretty_representation(const method_type&, bool internal = false); 1003 1004 string 1005 get_pretty_representation(const method_type*, bool internal = false); 1006 1007 string 1008 get_pretty_representation(const method_type_sptr&, 1009 bool internal = false); 1010 1011 string 1012 get_class_or_union_flat_representation(const class_or_union& cou, 1013 const string& indent, 1014 bool one_line, 1015 bool internal, 1016 bool qualified_name = true); 1017 1018 string 1019 get_class_or_union_flat_representation(const class_or_union* cou, 1020 const string& indent, 1021 bool one_line, 1022 bool internal, 1023 bool qualified_name = true); 1024 1025 string 1026 get_class_or_union_flat_representation(const class_or_union_sptr& cou, 1027 const string& indent, 1028 bool one_line, 1029 bool internal, 1030 bool qualified_name = true); 1031 1032 string 1033 get_debug_representation(const type_or_decl_base*); 1034 1035 var_decl_sptr 1036 get_data_member(class_or_union *, const char*); 1037 1038 var_decl_sptr 1039 get_data_member(type_base *clazz, const char* member_name); 1040 1041 const location& 1042 get_natural_or_artificial_location(const decl_base*); 1043 1044 const location& 1045 get_artificial_or_natural_location(const decl_base*); 1046 1047 type_or_decl_base* 1048 debug(const type_or_decl_base* artifact); 1049 1050 type_base* 1051 debug(const type_base* artifact); 1052 1053 decl_base* 1054 debug(const decl_base* artifact); 1055 1056 bool 1057 debug_equals(const type_or_decl_base *l, const type_or_decl_base *r); 1058 1059 bool 1060 odr_is_relevant(const type_or_decl_base&); 1061 1062 const decl_base* 1063 get_type_declaration(const type_base*); 1064 1065 decl_base* 1066 get_type_declaration(type_base*); 1067 1068 decl_base_sptr 1069 get_type_declaration(const type_base_sptr); 1070 1071 bool 1072 types_are_compatible(const type_base_sptr, 1073 const type_base_sptr); 1074 1075 bool 1076 types_are_compatible(const decl_base_sptr, 1077 const decl_base_sptr); 1078 1079 const scope_decl* 1080 get_top_most_scope_under(const decl_base*, 1081 const scope_decl*); 1082 1083 const scope_decl* 1084 get_top_most_scope_under(const decl_base_sptr, 1085 const scope_decl*); 1086 1087 const scope_decl* 1088 get_top_most_scope_under(const decl_base_sptr, 1089 const scope_decl_sptr); 1090 1091 void 1092 fqn_to_components(const std::string&, 1093 std::list<string>&); 1094 1095 string 1096 components_to_type_name(const std::list<string>&); 1097 1098 type_decl_sptr 1099 lookup_basic_type(const type_decl&, const translation_unit&); 1100 1101 type_decl_sptr 1102 lookup_basic_type(const interned_string&, const translation_unit&); 1103 1104 type_decl_sptr 1105 lookup_basic_type(const string&, const translation_unit&); 1106 1107 type_decl_sptr 1108 lookup_basic_type(const type_decl&, const corpus&); 1109 1110 type_decl_sptr 1111 lookup_basic_type(const string&, const corpus&); 1112 1113 type_decl_sptr 1114 lookup_basic_type(const interned_string&, const corpus&); 1115 1116 type_decl_sptr 1117 lookup_basic_type_per_location(const interned_string&, const corpus&); 1118 1119 type_decl_sptr 1120 lookup_basic_type_per_location(const string&, const corpus&); 1121 1122 class_decl_sptr 1123 lookup_class_type(const class_decl&, const translation_unit&); 1124 1125 class_decl_sptr 1126 lookup_class_type(const interned_string&, const translation_unit&); 1127 1128 class_decl_sptr 1129 lookup_class_type(const string&, const translation_unit&); 1130 1131 class_decl_sptr 1132 lookup_class_type(const class_decl&, const corpus&); 1133 1134 class_decl_sptr 1135 lookup_class_type(const interned_string&, const corpus&); 1136 1137 const type_base_wptrs_type* 1138 lookup_class_types(const interned_string&, const corpus&); 1139 1140 bool 1141 lookup_decl_only_class_types(const interned_string&, 1142 const corpus&, 1143 type_base_wptrs_type&); 1144 1145 const type_base_wptrs_type* 1146 lookup_class_types(const string&, const corpus&); 1147 1148 class_decl_sptr 1149 lookup_class_type_per_location(const interned_string&, const corpus&); 1150 1151 class_decl_sptr 1152 lookup_class_type_per_location(const string&, const corpus&); 1153 1154 class_decl_sptr 1155 lookup_class_type(const string&, const corpus&); 1156 1157 class_decl_sptr 1158 lookup_class_type_through_scopes(const std::list<string>&, 1159 const translation_unit&); 1160 1161 union_decl_sptr 1162 lookup_union_type(const interned_string&, const translation_unit&); 1163 1164 union_decl_sptr 1165 lookup_union_type(const interned_string&, const corpus&); 1166 1167 union_decl_sptr 1168 lookup_union_type_per_location(const interned_string&, const corpus&); 1169 1170 union_decl_sptr 1171 lookup_union_type_per_location(const string&, const corpus&); 1172 1173 union_decl_sptr 1174 lookup_union_type(const string&, const corpus&); 1175 1176 enum_type_decl_sptr 1177 lookup_enum_type(const enum_type_decl&, const translation_unit&); 1178 1179 enum_type_decl_sptr 1180 lookup_enum_type(const string&, const translation_unit&); 1181 1182 enum_type_decl_sptr 1183 lookup_enum_type(const enum_type_decl&, const corpus&); 1184 1185 enum_type_decl_sptr 1186 lookup_enum_type(const string&, const corpus&); 1187 1188 enum_type_decl_sptr 1189 lookup_enum_type(const interned_string&, const corpus&); 1190 1191 const type_base_wptrs_type* 1192 lookup_enum_types(const interned_string&, const corpus&); 1193 1194 const type_base_wptrs_type* 1195 lookup_enum_types(const string&, const corpus&); 1196 1197 enum_type_decl_sptr 1198 lookup_enum_type_per_location(const interned_string&, const corpus&); 1199 1200 enum_type_decl_sptr 1201 lookup_enum_type_per_location(const string&, const corpus&); 1202 1203 typedef_decl_sptr 1204 lookup_typedef_type(const typedef_decl&, const translation_unit&); 1205 1206 typedef_decl_sptr 1207 lookup_typedef_type(const typedef_decl&, const corpus&); 1208 1209 typedef_decl_sptr 1210 lookup_typedef_type(const interned_string& type_name, 1211 const translation_unit& tu); 1212 1213 typedef_decl_sptr 1214 lookup_typedef_type(const string& type_name, const translation_unit& tu); 1215 1216 typedef_decl_sptr 1217 lookup_typedef_type(const interned_string&, const corpus&); 1218 1219 typedef_decl_sptr 1220 lookup_typedef_type_per_location(const interned_string&, const corpus &); 1221 1222 typedef_decl_sptr 1223 lookup_typedef_type_per_location(const string&, const corpus &); 1224 1225 typedef_decl_sptr 1226 lookup_typedef_type(const string&, const corpus&); 1227 1228 type_base_sptr 1229 lookup_class_or_typedef_type(const string&, const translation_unit&); 1230 1231 type_base_sptr 1232 lookup_class_typedef_or_enum_type(const string&, const translation_unit&); 1233 1234 type_base_sptr 1235 lookup_class_or_typedef_type(const string&, const corpus&); 1236 1237 type_base_sptr 1238 lookup_class_typedef_or_enum_type(const string&, const corpus&); 1239 1240 qualified_type_def_sptr 1241 lookup_qualified_type(const qualified_type_def&, const translation_unit&); 1242 1243 qualified_type_def_sptr 1244 lookup_qualified_type(const string&, const translation_unit&); 1245 1246 qualified_type_def_sptr 1247 lookup_qualified_type(const qualified_type_def&, const corpus&); 1248 1249 qualified_type_def_sptr 1250 lookup_qualified_type(const interned_string&, const corpus&); 1251 1252 pointer_type_def_sptr 1253 lookup_pointer_type(const pointer_type_def&, const translation_unit&); 1254 1255 pointer_type_def_sptr 1256 lookup_pointer_type(const string&, const translation_unit&); 1257 1258 pointer_type_def_sptr 1259 lookup_pointer_type(const type_base_sptr& pointed_to_type, 1260 const translation_unit& tu); 1261 1262 pointer_type_def_sptr 1263 lookup_pointer_type(const pointer_type_def&, const corpus&); 1264 1265 pointer_type_def_sptr 1266 lookup_pointer_type(const interned_string&, const corpus&); 1267 1268 const reference_type_def_sptr 1269 lookup_reference_type(const reference_type_def&, const translation_unit&); 1270 1271 const reference_type_def_sptr 1272 lookup_reference_type(const string&, const translation_unit&); 1273 1274 const reference_type_def_sptr 1275 lookup_reference_type(const type_base_sptr& pointed_to_type, 1276 bool lvalue_reference, 1277 const translation_unit& tu); 1278 1279 reference_type_def_sptr 1280 lookup_reference_type(const reference_type_def&, const corpus&); 1281 1282 reference_type_def_sptr 1283 lookup_reference_type(const interned_string&, const corpus&); 1284 1285 array_type_def_sptr 1286 lookup_array_type(const array_type_def&, const translation_unit&); 1287 1288 array_type_def_sptr 1289 lookup_array_type(const string&, const translation_unit&); 1290 1291 array_type_def_sptr 1292 lookup_array_type(const array_type_def&, const corpus&); 1293 1294 array_type_def_sptr 1295 lookup_array_type(const interned_string&, const corpus&); 1296 1297 function_type_sptr 1298 lookup_function_type(const string&, 1299 const translation_unit&); 1300 1301 function_type_sptr 1302 lookup_function_type(const interned_string&, 1303 const translation_unit&); 1304 1305 function_type_sptr 1306 lookup_function_type(const function_type&, 1307 const translation_unit&); 1308 1309 function_type_sptr 1310 lookup_function_type(const function_type_sptr&, 1311 const translation_unit&); 1312 1313 function_type_sptr 1314 lookup_function_type(const function_type&, const corpus&); 1315 1316 function_type_sptr 1317 lookup_function_type(const function_type_sptr&, const corpus&); 1318 1319 function_type_sptr 1320 lookup_function_type(const function_type&, const corpus&); 1321 1322 function_type_sptr 1323 lookup_function_type(const interned_string&, const corpus&); 1324 1325 type_base_sptr 1326 lookup_type(const string&, const translation_unit&); 1327 1328 const type_base_sptr 1329 lookup_type(const type_base_sptr, const translation_unit&); 1330 1331 type_base_sptr 1332 lookup_type(const interned_string&, const corpus&); 1333 1334 type_base_sptr 1335 lookup_type_per_location(const interned_string&, const corpus&); 1336 1337 type_base_sptr 1338 lookup_type(const type_base&, const corpus&); 1339 1340 type_base_sptr 1341 lookup_type(const type_base_sptr&, const corpus&); 1342 1343 type_base_sptr 1344 lookup_type_through_scopes(const std::list<string>&, 1345 const translation_unit&); 1346 1347 type_base_sptr 1348 lookup_type_through_translation_units(const string&, const corpus&); 1349 1350 type_base_sptr 1351 lookup_type_from_translation_unit(const string& type_name, 1352 const string& tu_path, 1353 const corpus& corp); 1354 1355 function_type_sptr 1356 lookup_or_synthesize_fn_type(const function_type_sptr&, 1357 const corpus&); 1358 1359 type_base_sptr 1360 synthesize_type_from_translation_unit(const type_base_sptr&, 1361 translation_unit&); 1362 1363 function_type_sptr 1364 synthesize_function_type_from_translation_unit(const function_type&, 1365 translation_unit&); 1366 1367 const type_base_sptr 1368 lookup_type_in_scope(const string&, 1369 const scope_decl_sptr&); 1370 1371 const type_base_sptr 1372 lookup_type_in_scope(const std::list<string>&, 1373 const scope_decl_sptr&); 1374 1375 const decl_base_sptr 1376 lookup_var_decl_in_scope(const string&, 1377 const scope_decl_sptr&); 1378 1379 const decl_base_sptr 1380 lookup_var_decl_in_scope(const std::list<string>&, 1381 const scope_decl_sptr&); 1382 1383 string 1384 demangle_cplus_mangled_name(const string&); 1385 1386 type_base_sptr 1387 type_or_void(const type_base_sptr, const environment&); 1388 1389 type_base_sptr 1390 canonicalize(type_base_sptr); 1391 1392 type_base* 1393 type_has_non_canonicalized_subtype(type_base_sptr t); 1394 1395 bool 1396 type_has_sub_type_changes(type_base_sptr t_v1, 1397 type_base_sptr t_v2); 1398 1399 void 1400 keep_type_alive(type_base_sptr t); 1401 1402 size_t 1403 hash_type(const type_base *t); 1404 1405 size_t 1406 hash_type_or_decl(const type_or_decl_base *); 1407 1408 size_t 1409 hash_type_or_decl(const type_or_decl_base_sptr &); 1410 1411 bool 1412 is_non_canonicalized_type(const type_base *); 1413 1414 bool 1415 is_non_canonicalized_type(const type_base_sptr&); 1416 1417 /// For a given type, return its exemplar type. 1418 /// 1419 /// For a given type, its exemplar type is either its canonical type 1420 /// or the canonical type of the definition type of a given 1421 /// declaration-only type. If the neither of those two types exist, 1422 /// then the exemplar type is the given type itself. 1423 /// 1424 /// @param type the input to consider. 1425 /// 1426 /// @return the exemplar type. 1427 type_base* 1428 get_exemplar_type(const type_base* type); 1429 1430 bool 1431 function_decl_is_less_than(const function_decl&f, const function_decl &s); 1432 1433 bool 1434 types_have_similar_structure(const type_base_sptr& first, 1435 const type_base_sptr& second, 1436 bool indirect_type = false); 1437 1438 bool 1439 types_have_similar_structure(const type_base* first, 1440 const type_base* second, 1441 bool indirect_type = false); 1442 1443 string 1444 build_internal_underlying_enum_type_name(const string &base_name, 1445 bool is_anonymous, 1446 uint64_t size); 1447 1448 } // end namespace ir 1449 1450 using namespace abigail::ir; 1451 1452 namespace suppr 1453 { 1454 class suppression_base; 1455 1456 /// Convenience typedef for a shared pointer to a @ref suppression. 1457 typedef shared_ptr<suppression_base> suppression_sptr; 1458 1459 /// Convenience typedef for a vector of @ref suppression_sptr 1460 typedef vector<suppression_sptr> suppressions_type; 1461 1462 } // end namespace suppr 1463 1464 namespace symtab_reader 1465 { 1466 1467 class symtab; 1468 /// Convenience typedef for a shared pointer to a @ref symtab 1469 typedef std::shared_ptr<symtab> symtab_sptr; 1470 1471 } // end namespace symtab_reader 1472 1473 void 1474 dump(const decl_base_sptr, std::ostream&); 1475 1476 void 1477 dump(const decl_base_sptr); 1478 1479 void 1480 dump(const type_base_sptr, std::ostream&); 1481 1482 void 1483 dump(const type_base_sptr); 1484 1485 void 1486 dump(const var_decl_sptr, std::ostream&); 1487 1488 void 1489 dump(const var_decl_sptr); 1490 1491 void 1492 dump(const translation_unit&, std::ostream&); 1493 1494 void 1495 dump(const translation_unit&); 1496 1497 void 1498 dump(const translation_unit_sptr, std::ostream&); 1499 1500 void 1501 dump(const translation_unit_sptr); 1502 1503 void 1504 dump_decl_location(const decl_base&); 1505 1506 void 1507 dump_decl_location(const decl_base*); 1508 1509 void 1510 dump_decl_location(const decl_base_sptr&); 1511 1512 #ifndef ABG_ASSERT 1513 /// This is a wrapper around the 'assert' glibc call. It allows for 1514 /// its argument to have side effects, so that it keeps working when 1515 /// the code of libabigail is compiled with the NDEBUG macro defined. 1516 #define ABG_ASSERT(cond) do {({bool __abg_cond__ = bool(cond); assert(__abg_cond__); !!__abg_cond__;});} while (false) 1517 #endif 1518 1519 } // end namespace abigail 1520 #endif // __ABG_IRFWD_H__ 1521