1 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 // -*- Mode: C++ -*- 3 // 4 // Copyright (C) 2013-2020 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 typedef_decl_sptr 413 is_typedef(const type_or_decl_base_sptr); 414 415 const typedef_decl* 416 is_typedef(const type_base*); 417 418 typedef_decl* 419 is_typedef(type_base*); 420 421 enum_type_decl_sptr 422 is_compatible_with_enum_type(const type_base_sptr&); 423 424 enum_type_decl_sptr 425 is_compatible_with_enum_type(const decl_base_sptr&); 426 427 enum_type_decl_sptr 428 is_enum_type(const type_or_decl_base_sptr&); 429 430 const enum_type_decl* 431 is_enum_type(const type_or_decl_base*); 432 433 bool 434 is_class_type(const type_or_decl_base&); 435 436 class_decl* 437 is_class_type(const type_or_decl_base*); 438 439 class_decl_sptr 440 is_class_type(const type_or_decl_base_sptr&); 441 442 bool 443 is_declaration_only_class_or_union_type(const type_base *t); 444 445 bool 446 is_declaration_only_class_or_union_type(const type_base_sptr&); 447 448 class_or_union* 449 is_class_or_union_type(const type_or_decl_base*); 450 451 class_or_union_sptr 452 is_class_or_union_type(const type_or_decl_base_sptr&); 453 454 bool 455 is_union_type(const type_or_decl_base&); 456 457 union_decl* 458 is_union_type(const type_or_decl_base*); 459 460 union_decl_sptr 461 is_union_type(const type_or_decl_base_sptr&); 462 463 class_decl_sptr 464 is_compatible_with_class_type(const type_base_sptr&); 465 466 class_decl_sptr 467 is_compatible_with_class_type(const decl_base_sptr&); 468 469 pointer_type_def* 470 is_pointer_type(type_or_decl_base*); 471 472 const pointer_type_def* 473 is_pointer_type(const type_or_decl_base*); 474 475 pointer_type_def_sptr 476 is_pointer_type(const type_or_decl_base_sptr&); 477 478 reference_type_def* 479 is_reference_type(type_or_decl_base*); 480 481 const reference_type_def* 482 is_reference_type(const type_or_decl_base*); 483 484 reference_type_def_sptr 485 is_reference_type(const type_or_decl_base_sptr&); 486 487 const type_base* 488 is_void_pointer_type(const type_base*); 489 490 qualified_type_def* 491 is_qualified_type(const type_or_decl_base*); 492 493 qualified_type_def_sptr 494 is_qualified_type(const type_or_decl_base_sptr&); 495 496 function_type_sptr 497 is_function_type(const type_or_decl_base_sptr&); 498 499 function_type* 500 is_function_type(type_or_decl_base*); 501 502 const function_type* 503 is_function_type(const type_or_decl_base*); 504 505 method_type_sptr 506 is_method_type(const type_or_decl_base_sptr&); 507 508 const method_type* 509 is_method_type(const type_or_decl_base*); 510 511 method_type* 512 is_method_type(type_or_decl_base*); 513 514 class_or_union_sptr 515 look_through_decl_only_class(class_or_union_sptr); 516 517 class_or_union* 518 look_through_decl_only_class(class_or_union*); 519 520 enum_type_decl_sptr 521 look_through_decl_only_enum(enum_type_decl_sptr); 522 523 decl_base* 524 look_through_decl_only(decl_base*); 525 526 decl_base_sptr 527 look_through_decl_only(decl_base_sptr); 528 529 var_decl* 530 is_var_decl(const type_or_decl_base*); 531 532 var_decl_sptr 533 is_var_decl(const type_or_decl_base_sptr&); 534 535 namespace_decl_sptr 536 is_namespace(const decl_base_sptr&); 537 538 namespace_decl* 539 is_namespace(const decl_base*); 540 541 bool 542 is_template_parm_composition_type(const decl_base_sptr); 543 544 bool 545 is_template_decl(const decl_base_sptr); 546 547 bool 548 is_function_template_pattern(const decl_base_sptr); 549 550 551 decl_base_sptr 552 insert_decl_into_scope(decl_base_sptr, 553 vector<decl_base_sptr >::iterator, 554 scope_decl*); 555 556 decl_base_sptr 557 insert_decl_into_scope(decl_base_sptr, 558 vector<decl_base_sptr >::iterator, 559 scope_decl_sptr); 560 561 bool 562 has_scope(const decl_base&); 563 564 bool 565 has_scope(const decl_base_sptr); 566 567 bool 568 is_member_decl(const decl_base_sptr); 569 570 bool 571 is_member_decl(const decl_base*); 572 573 bool 574 is_member_decl(const decl_base&); 575 576 scope_decl* 577 is_scope_decl(decl_base*); 578 579 scope_decl_sptr 580 is_scope_decl(const decl_base_sptr&); 581 582 bool 583 is_member_type(const type_base_sptr&); 584 585 bool 586 is_user_defined_type(const type_base*); 587 588 bool 589 is_user_defined_type(const type_base_sptr&); 590 591 void 592 remove_decl_from_scope(decl_base_sptr); 593 594 bool 595 get_member_is_static(const decl_base&); 596 597 bool 598 get_member_is_static(const decl_base*); 599 600 bool 601 get_member_is_static(const decl_base_sptr&); 602 603 void 604 set_member_is_static(decl_base&, bool); 605 606 void 607 set_member_is_static(const decl_base_sptr&, bool); 608 609 bool 610 is_data_member(const var_decl&); 611 612 var_decl* 613 is_data_member(const type_or_decl_base*); 614 615 bool 616 is_data_member(const var_decl*); 617 618 var_decl_sptr 619 is_data_member(const type_or_decl_base_sptr&); 620 621 bool 622 is_data_member(const var_decl_sptr); 623 624 var_decl_sptr 625 is_data_member(const decl_base_sptr&); 626 627 var_decl* 628 is_data_member(const decl_base *); 629 630 var_decl* 631 is_data_member(const decl_base *); 632 633 const var_decl_sptr 634 get_next_data_member(const class_or_union_sptr&, const var_decl_sptr&); 635 636 var_decl_sptr 637 get_last_data_member(const class_or_union_sptr&); 638 639 bool 640 is_anonymous_data_member(const decl_base&); 641 642 const var_decl* 643 is_anonymous_data_member(const type_or_decl_base*); 644 645 const var_decl* 646 is_anonymous_data_member(const decl_base*); 647 648 var_decl_sptr 649 is_anonymous_data_member(const type_or_decl_base_sptr&); 650 651 var_decl_sptr 652 is_anonymous_data_member(const decl_base_sptr&); 653 654 var_decl_sptr 655 is_anonymous_data_member(const var_decl_sptr&); 656 657 const var_decl* 658 is_anonymous_data_member(const var_decl*); 659 660 bool 661 is_anonymous_data_member(const var_decl&); 662 663 const var_decl_sptr 664 get_first_non_anonymous_data_member(const var_decl_sptr); 665 666 var_decl_sptr 667 find_data_member_from_anonymous_data_member(const var_decl_sptr&, 668 const string&); 669 670 class_or_union* 671 anonymous_data_member_to_class_or_union(const var_decl*); 672 673 class_or_union_sptr 674 anonymous_data_member_to_class_or_union(const var_decl_sptr&); 675 676 bool 677 scope_anonymous_or_typedef_named(const decl_base&); 678 679 bool 680 is_anonymous_or_typedef_named(const decl_base&); 681 682 const class_or_union_sptr 683 data_member_has_anonymous_type(const var_decl& d); 684 685 const class_or_union_sptr 686 data_member_has_anonymous_type(const var_decl* d); 687 688 const class_or_union_sptr 689 data_member_has_anonymous_type(const var_decl_sptr& d); 690 691 array_type_def* 692 is_array_type(const type_or_decl_base* decl); 693 694 array_type_def_sptr 695 is_array_type(const type_or_decl_base_sptr& decl); 696 697 array_type_def_sptr 698 is_array_of_qualified_element(const type_base_sptr&); 699 700 qualified_type_def_sptr 701 is_array_of_qualified_element(const array_type_def_sptr&); 702 703 array_type_def_sptr 704 is_typedef_of_array(const type_base_sptr&); 705 706 void 707 set_data_member_offset(var_decl_sptr, uint64_t); 708 709 uint64_t 710 get_data_member_offset(const var_decl&); 711 712 uint64_t 713 get_data_member_offset(const var_decl_sptr); 714 715 uint64_t 716 get_data_member_offset(const decl_base_sptr); 717 718 uint64_t 719 get_absolute_data_member_offset(const var_decl&); 720 721 bool 722 get_next_data_member_offset(const class_or_union_sptr&, 723 const var_decl_sptr&, 724 uint64_t&); 725 726 uint64_t 727 get_var_size_in_bits(const var_decl_sptr&); 728 729 void 730 set_data_member_is_laid_out(var_decl_sptr, bool); 731 732 bool 733 get_data_member_is_laid_out(const var_decl&); 734 735 bool 736 get_data_member_is_laid_out(const var_decl_sptr); 737 738 bool 739 is_member_function(const function_decl&); 740 741 bool 742 is_member_function(const function_decl*); 743 744 bool 745 is_member_function(const function_decl_sptr&); 746 747 bool 748 get_member_function_is_ctor(const function_decl&); 749 750 bool 751 get_member_function_is_ctor(const function_decl_sptr&); 752 753 void 754 set_member_function_is_ctor(const function_decl&, bool); 755 756 void 757 set_member_function_is_ctor(const function_decl_sptr&, bool); 758 759 bool 760 get_member_function_is_dtor(const function_decl&); 761 762 bool 763 get_member_function_is_dtor(const function_decl_sptr&); 764 765 void 766 set_member_function_is_dtor(function_decl&, bool); 767 768 void 769 set_member_function_is_dtor(const function_decl_sptr&, bool); 770 771 bool 772 get_member_function_is_const(const function_decl&); 773 774 bool 775 get_member_function_is_const(const function_decl_sptr&); 776 777 void 778 set_member_function_is_const(function_decl&, bool); 779 780 void 781 set_member_function_is_const(const function_decl_sptr&, bool); 782 783 bool 784 member_function_has_vtable_offset(const function_decl&); 785 786 ssize_t 787 get_member_function_vtable_offset(const function_decl&); 788 789 ssize_t 790 get_member_function_vtable_offset(const function_decl_sptr&); 791 792 void 793 set_member_function_vtable_offset(const function_decl& f, 794 ssize_t s); 795 796 void 797 set_member_function_vtable_offset(const function_decl_sptr &f, 798 ssize_t s); 799 800 bool 801 get_member_function_is_virtual(const function_decl&); 802 803 bool 804 get_member_function_is_virtual(const function_decl_sptr&); 805 806 bool 807 get_member_function_is_virtual(const function_decl*); 808 809 void 810 set_member_function_is_virtual(function_decl&, bool); 811 812 void 813 set_member_function_is_virtual(const function_decl_sptr&, bool); 814 815 type_base_sptr 816 strip_typedef(const type_base_sptr); 817 818 decl_base_sptr 819 strip_useless_const_qualification(const qualified_type_def_sptr t); 820 821 type_base_sptr 822 peel_typedef_type(const type_base_sptr&); 823 824 const type_base* 825 peel_typedef_type(const type_base*); 826 827 type_base_sptr 828 peel_pointer_type(const type_base_sptr&); 829 830 const type_base* 831 peel_pointer_type(const type_base*); 832 833 type_base_sptr 834 peel_reference_type(const type_base_sptr&); 835 836 const type_base* 837 peel_reference_type(const type_base*); 838 839 const type_base_sptr 840 peel_array_type(const type_base_sptr&); 841 842 const type_base* 843 peel_array_type(const type_base*); 844 845 const type_base* 846 peel_qualified_type(const type_base*); 847 848 const type_base_sptr 849 peel_qualified_type(const type_base_sptr&); 850 851 type_base* 852 peel_qualified_or_typedef_type(const type_base* type); 853 854 type_base_sptr 855 peel_qualified_or_typedef_type(const type_base_sptr &type); 856 857 type_base_sptr 858 peel_typedef_pointer_or_reference_type(const type_base_sptr); 859 860 type_base* 861 peel_typedef_pointer_or_reference_type(const type_base* type); 862 863 type_base* 864 peel_pointer_or_reference_type(const type_base *type, 865 bool peel_qualified_type = true); 866 867 array_type_def_sptr 868 clone_array(const array_type_def_sptr& array); 869 870 typedef_decl_sptr 871 clone_typedef(const typedef_decl_sptr& t); 872 873 qualified_type_def_sptr 874 clone_qualified_type(const qualified_type_def_sptr& t); 875 876 type_base_sptr 877 clone_array_tree(const type_base_sptr t); 878 879 string 880 get_name(const type_or_decl_base*, bool qualified = true); 881 882 string 883 get_name(const type_or_decl_base_sptr&, 884 bool qualified = true); 885 886 location 887 get_location(const type_base_sptr& type); 888 889 location 890 get_location(const decl_base_sptr& decl); 891 892 string 893 build_qualified_name(const scope_decl* scope, const string& name); 894 895 string 896 build_qualified_name(const scope_decl* scope, 897 const type_base_sptr& type); 898 899 scope_decl* 900 get_type_scope(type_base*); 901 902 scope_decl* 903 get_type_scope(const type_base_sptr&); 904 905 interned_string 906 get_type_name(const type_base_sptr&, 907 bool qualified = true, 908 bool internal = false); 909 910 interned_string 911 get_type_name(const type_base*, 912 bool qualified = true, 913 bool internal = false); 914 915 interned_string 916 get_type_name(const type_base&, 917 bool qualified = true, 918 bool internal = false); 919 920 interned_string 921 get_name_of_pointer_to_type(const type_base& pointed_to_type, 922 bool qualified = true, 923 bool internal = false); 924 925 interned_string 926 get_name_of_reference_to_type(const type_base& pointed_to_type, 927 bool lvalue_reference = false, 928 bool qualified = true, 929 bool internal = false); 930 931 interned_string 932 get_function_type_name(const function_type_sptr&, 933 bool internal = false); 934 935 interned_string 936 get_function_type_name(const function_type*, bool internal = false); 937 938 interned_string 939 get_function_type_name(const function_type&, bool internal = false); 940 941 interned_string 942 get_method_type_name(const method_type_sptr&, bool internal = false); 943 944 interned_string 945 get_method_type_name(const method_type*, bool internal = false); 946 947 interned_string 948 get_method_type_name(const method_type&, bool internal = false); 949 950 string 951 get_pretty_representation(const decl_base*, bool internal = false); 952 953 string 954 get_pretty_representation(const type_base*, bool internal = false); 955 956 string 957 get_pretty_representation(const type_or_decl_base*, bool internal = false); 958 959 string 960 get_pretty_representation(const type_or_decl_base_sptr&, 961 bool internal = false); 962 963 string 964 get_pretty_representation(const decl_base_sptr&, bool internal = false); 965 966 string 967 get_pretty_representation(const type_base_sptr&, bool internal = false); 968 969 string 970 get_pretty_representation(const function_type&, bool internal = false); 971 972 string 973 get_pretty_representation(const function_type*, bool internal = false); 974 975 string 976 get_pretty_representation(const function_type_sptr&, 977 bool internal = false); 978 979 string 980 get_pretty_representation(const method_type&, bool internal = false); 981 982 string 983 get_pretty_representation(const method_type*, bool internal = false); 984 985 string 986 get_pretty_representation(const method_type_sptr&, 987 bool internal = false); 988 989 string 990 get_class_or_union_flat_representation(const class_or_union& cou, 991 const string& indent, 992 bool one_line, 993 bool internal, 994 bool qualified_name = true); 995 996 string 997 get_class_or_union_flat_representation(const class_or_union* cou, 998 const string& indent, 999 bool one_line, 1000 bool internal, 1001 bool qualified_name = true); 1002 1003 string 1004 get_class_or_union_flat_representation(const class_or_union_sptr& cou, 1005 const string& indent, 1006 bool one_line, 1007 bool internal, 1008 bool qualified_name = true); 1009 1010 string 1011 get_debug_representation(const type_or_decl_base*); 1012 1013 var_decl_sptr 1014 get_data_member(class_or_union *, const char*); 1015 1016 var_decl_sptr 1017 get_data_member(type_base *clazz, const char* member_name); 1018 1019 const location& 1020 get_natural_or_artificial_location(const decl_base*); 1021 1022 const location& 1023 get_artificial_or_natural_location(const decl_base*); 1024 1025 type_or_decl_base* 1026 debug(const type_or_decl_base* artifact); 1027 1028 type_base* 1029 debug(const type_base* artifact); 1030 1031 decl_base* 1032 debug(const decl_base* artifact); 1033 1034 bool 1035 debug_equals(const type_or_decl_base *l, const type_or_decl_base *r); 1036 1037 bool 1038 odr_is_relevant(const type_or_decl_base&); 1039 1040 const decl_base* 1041 get_type_declaration(const type_base*); 1042 1043 decl_base* 1044 get_type_declaration(type_base*); 1045 1046 decl_base_sptr 1047 get_type_declaration(const type_base_sptr); 1048 1049 bool 1050 types_are_compatible(const type_base_sptr, 1051 const type_base_sptr); 1052 1053 bool 1054 types_are_compatible(const decl_base_sptr, 1055 const decl_base_sptr); 1056 1057 const scope_decl* 1058 get_top_most_scope_under(const decl_base*, 1059 const scope_decl*); 1060 1061 const scope_decl* 1062 get_top_most_scope_under(const decl_base_sptr, 1063 const scope_decl*); 1064 1065 const scope_decl* 1066 get_top_most_scope_under(const decl_base_sptr, 1067 const scope_decl_sptr); 1068 1069 void 1070 fqn_to_components(const std::string&, 1071 std::list<string>&); 1072 1073 string 1074 components_to_type_name(const std::list<string>&); 1075 1076 type_decl_sptr 1077 lookup_basic_type(const type_decl&, const translation_unit&); 1078 1079 type_decl_sptr 1080 lookup_basic_type(const interned_string&, const translation_unit&); 1081 1082 type_decl_sptr 1083 lookup_basic_type(const string&, const translation_unit&); 1084 1085 type_decl_sptr 1086 lookup_basic_type(const type_decl&, const corpus&); 1087 1088 type_decl_sptr 1089 lookup_basic_type(const string&, const corpus&); 1090 1091 type_decl_sptr 1092 lookup_basic_type(const interned_string&, const corpus&); 1093 1094 type_decl_sptr 1095 lookup_basic_type_per_location(const interned_string&, const corpus&); 1096 1097 type_decl_sptr 1098 lookup_basic_type_per_location(const string&, const corpus&); 1099 1100 class_decl_sptr 1101 lookup_class_type(const class_decl&, const translation_unit&); 1102 1103 class_decl_sptr 1104 lookup_class_type(const interned_string&, const translation_unit&); 1105 1106 class_decl_sptr 1107 lookup_class_type(const string&, const translation_unit&); 1108 1109 class_decl_sptr 1110 lookup_class_type(const class_decl&, const corpus&); 1111 1112 class_decl_sptr 1113 lookup_class_type(const interned_string&, const corpus&); 1114 1115 const type_base_wptrs_type* 1116 lookup_class_types(const interned_string&, const corpus&); 1117 1118 const type_base_wptrs_type* 1119 lookup_class_types(const string&, const corpus&); 1120 1121 class_decl_sptr 1122 lookup_class_type_per_location(const interned_string&, const corpus&); 1123 1124 class_decl_sptr 1125 lookup_class_type_per_location(const string&, const corpus&); 1126 1127 class_decl_sptr 1128 lookup_class_type(const string&, const corpus&); 1129 1130 class_decl_sptr 1131 lookup_class_type_through_scopes(const std::list<string>&, 1132 const translation_unit&); 1133 1134 union_decl_sptr 1135 lookup_union_type(const interned_string&, const translation_unit&); 1136 1137 union_decl_sptr 1138 lookup_union_type(const interned_string&, const corpus&); 1139 1140 union_decl_sptr 1141 lookup_union_type_per_location(const interned_string&, const corpus&); 1142 1143 union_decl_sptr 1144 lookup_union_type_per_location(const string&, const corpus&); 1145 1146 union_decl_sptr 1147 lookup_union_type(const string&, const corpus&); 1148 1149 enum_type_decl_sptr 1150 lookup_enum_type(const enum_type_decl&, const translation_unit&); 1151 1152 enum_type_decl_sptr 1153 lookup_enum_type(const string&, const translation_unit&); 1154 1155 enum_type_decl_sptr 1156 lookup_enum_type(const enum_type_decl&, const corpus&); 1157 1158 enum_type_decl_sptr 1159 lookup_enum_type(const string&, const corpus&); 1160 1161 enum_type_decl_sptr 1162 lookup_enum_type(const interned_string&, const corpus&); 1163 1164 const type_base_wptrs_type* 1165 lookup_enum_types(const interned_string&, const corpus&); 1166 1167 const type_base_wptrs_type* 1168 lookup_enum_types(const string&, const corpus&); 1169 1170 enum_type_decl_sptr 1171 lookup_enum_type_per_location(const interned_string&, const corpus&); 1172 1173 enum_type_decl_sptr 1174 lookup_enum_type_per_location(const string&, const corpus&); 1175 1176 typedef_decl_sptr 1177 lookup_typedef_type(const typedef_decl&, const translation_unit&); 1178 1179 typedef_decl_sptr 1180 lookup_typedef_type(const typedef_decl&, const corpus&); 1181 1182 typedef_decl_sptr 1183 lookup_typedef_type(const interned_string& type_name, 1184 const translation_unit& tu); 1185 1186 typedef_decl_sptr 1187 lookup_typedef_type(const string& type_name, const translation_unit& tu); 1188 1189 typedef_decl_sptr 1190 lookup_typedef_type(const interned_string&, const corpus&); 1191 1192 typedef_decl_sptr 1193 lookup_typedef_type_per_location(const interned_string&, const corpus &); 1194 1195 typedef_decl_sptr 1196 lookup_typedef_type_per_location(const string&, const corpus &); 1197 1198 typedef_decl_sptr 1199 lookup_typedef_type(const string&, const corpus&); 1200 1201 type_base_sptr 1202 lookup_class_or_typedef_type(const string&, const translation_unit&); 1203 1204 type_base_sptr 1205 lookup_class_typedef_or_enum_type(const string&, const translation_unit&); 1206 1207 type_base_sptr 1208 lookup_class_or_typedef_type(const string&, const corpus&); 1209 1210 type_base_sptr 1211 lookup_class_typedef_or_enum_type(const string&, const corpus&); 1212 1213 qualified_type_def_sptr 1214 lookup_qualified_type(const qualified_type_def&, const translation_unit&); 1215 1216 qualified_type_def_sptr 1217 lookup_qualified_type(const string&, const translation_unit&); 1218 1219 qualified_type_def_sptr 1220 lookup_qualified_type(const qualified_type_def&, const corpus&); 1221 1222 qualified_type_def_sptr 1223 lookup_qualified_type(const interned_string&, const corpus&); 1224 1225 pointer_type_def_sptr 1226 lookup_pointer_type(const pointer_type_def&, const translation_unit&); 1227 1228 pointer_type_def_sptr 1229 lookup_pointer_type(const string&, const translation_unit&); 1230 1231 pointer_type_def_sptr 1232 lookup_pointer_type(const type_base_sptr& pointed_to_type, 1233 const translation_unit& tu); 1234 1235 pointer_type_def_sptr 1236 lookup_pointer_type(const pointer_type_def&, const corpus&); 1237 1238 pointer_type_def_sptr 1239 lookup_pointer_type(const interned_string&, const corpus&); 1240 1241 const reference_type_def_sptr 1242 lookup_reference_type(const reference_type_def&, const translation_unit&); 1243 1244 const reference_type_def_sptr 1245 lookup_reference_type(const string&, const translation_unit&); 1246 1247 const reference_type_def_sptr 1248 lookup_reference_type(const type_base_sptr& pointed_to_type, 1249 bool lvalue_reference, 1250 const translation_unit& tu); 1251 1252 reference_type_def_sptr 1253 lookup_reference_type(const reference_type_def&, const corpus&); 1254 1255 reference_type_def_sptr 1256 lookup_reference_type(const interned_string&, const corpus&); 1257 1258 array_type_def_sptr 1259 lookup_array_type(const array_type_def&, const translation_unit&); 1260 1261 array_type_def_sptr 1262 lookup_array_type(const string&, const translation_unit&); 1263 1264 array_type_def_sptr 1265 lookup_array_type(const array_type_def&, const corpus&); 1266 1267 array_type_def_sptr 1268 lookup_array_type(const interned_string&, const corpus&); 1269 1270 function_type_sptr 1271 lookup_function_type(const string&, 1272 const translation_unit&); 1273 1274 function_type_sptr 1275 lookup_function_type(const interned_string&, 1276 const translation_unit&); 1277 1278 function_type_sptr 1279 lookup_function_type(const function_type&, 1280 const translation_unit&); 1281 1282 function_type_sptr 1283 lookup_function_type(const function_type_sptr&, 1284 const translation_unit&); 1285 1286 function_type_sptr 1287 lookup_function_type(const function_type&, const corpus&); 1288 1289 function_type_sptr 1290 lookup_function_type(const function_type_sptr&, const corpus&); 1291 1292 function_type_sptr 1293 lookup_function_type(const function_type&, const corpus&); 1294 1295 function_type_sptr 1296 lookup_function_type(const interned_string&, const corpus&); 1297 1298 type_base_sptr 1299 lookup_type(const string&, const translation_unit&); 1300 1301 const type_base_sptr 1302 lookup_type(const type_base_sptr, const translation_unit&); 1303 1304 type_base_sptr 1305 lookup_type(const interned_string&, const corpus&); 1306 1307 type_base_sptr 1308 lookup_type_per_location(const interned_string&, const corpus&); 1309 1310 type_base_sptr 1311 lookup_type(const type_base&, const corpus&); 1312 1313 type_base_sptr 1314 lookup_type(const type_base_sptr&, const corpus&); 1315 1316 type_base_sptr 1317 lookup_type_through_scopes(const std::list<string>&, 1318 const translation_unit&); 1319 1320 type_base_sptr 1321 lookup_type_through_translation_units(const string&, const corpus&); 1322 1323 type_base_sptr 1324 lookup_type_from_translation_unit(const string& type_name, 1325 const string& tu_path, 1326 const corpus& corp); 1327 1328 function_type_sptr 1329 lookup_or_synthesize_fn_type(const function_type_sptr&, 1330 const corpus&); 1331 1332 type_base_sptr 1333 synthesize_type_from_translation_unit(const type_base_sptr&, 1334 translation_unit&); 1335 1336 function_type_sptr 1337 synthesize_function_type_from_translation_unit(const function_type&, 1338 translation_unit&); 1339 1340 const type_base_sptr 1341 lookup_type_in_scope(const string&, 1342 const scope_decl_sptr&); 1343 1344 const type_base_sptr 1345 lookup_type_in_scope(const std::list<string>&, 1346 const scope_decl_sptr&); 1347 1348 const decl_base_sptr 1349 lookup_var_decl_in_scope(const string&, 1350 const scope_decl_sptr&); 1351 1352 const decl_base_sptr 1353 lookup_var_decl_in_scope(const std::list<string>&, 1354 const scope_decl_sptr&); 1355 1356 string 1357 demangle_cplus_mangled_name(const string&); 1358 1359 type_base_sptr 1360 type_or_void(const type_base_sptr, const environment*); 1361 1362 type_base_sptr 1363 canonicalize(type_base_sptr); 1364 1365 type_base* 1366 type_has_non_canonicalized_subtype(type_base_sptr t); 1367 1368 bool 1369 type_has_sub_type_changes(type_base_sptr t_v1, 1370 type_base_sptr t_v2); 1371 1372 void 1373 keep_type_alive(type_base_sptr t); 1374 1375 size_t 1376 hash_type(const type_base *t); 1377 1378 size_t 1379 hash_type_or_decl(const type_or_decl_base *); 1380 1381 size_t 1382 hash_type_or_decl(const type_or_decl_base_sptr &); 1383 1384 bool 1385 is_non_canonicalized_type(const type_base *); 1386 1387 bool 1388 is_non_canonicalized_type(const type_base_sptr&); 1389 1390 /// For a given type, return its exemplar type. 1391 /// 1392 /// For a given type, its exemplar type is either its canonical type 1393 /// or the canonical type of the definition type of a given 1394 /// declaration-only type. If the neither of those two types exist, 1395 /// then the exemplar type is the given type itself. 1396 /// 1397 /// @param type the input to consider. 1398 /// 1399 /// @return the exemplar type. 1400 type_base* 1401 get_exemplar_type(const type_base* type); 1402 1403 bool 1404 function_decl_is_less_than(const function_decl&f, const function_decl &s); 1405 1406 bool 1407 types_have_similar_structure(const type_base_sptr& first, 1408 const type_base_sptr& second, 1409 bool indirect_type = false); 1410 1411 bool 1412 types_have_similar_structure(const type_base* first, 1413 const type_base* second, 1414 bool indirect_type = false); 1415 1416 } // end namespace ir 1417 1418 using namespace abigail::ir; 1419 1420 namespace suppr 1421 { 1422 class suppression_base; 1423 1424 /// Convenience typedef for a shared pointer to a @ref suppression. 1425 typedef shared_ptr<suppression_base> suppression_sptr; 1426 1427 /// Convenience typedef for a vector of @ref suppression_sptr 1428 typedef vector<suppression_sptr> suppressions_type; 1429 1430 } // end namespace suppr 1431 1432 namespace symtab_reader 1433 { 1434 1435 class symtab; 1436 /// Convenience typedef for a shared pointer to a @ref symtab 1437 typedef std::shared_ptr<symtab> symtab_sptr; 1438 1439 } // end namespace symtab_reader 1440 1441 void 1442 dump(const decl_base_sptr, std::ostream&); 1443 1444 void 1445 dump(const decl_base_sptr); 1446 1447 void 1448 dump(const type_base_sptr, std::ostream&); 1449 1450 void 1451 dump(const type_base_sptr); 1452 1453 void 1454 dump(const var_decl_sptr, std::ostream&); 1455 1456 void 1457 dump(const var_decl_sptr); 1458 1459 void 1460 dump(const translation_unit&, std::ostream&); 1461 1462 void 1463 dump(const translation_unit&); 1464 1465 void 1466 dump(const translation_unit_sptr, std::ostream&); 1467 1468 void 1469 dump(const translation_unit_sptr); 1470 1471 void 1472 dump_decl_location(const decl_base&); 1473 1474 void 1475 dump_decl_location(const decl_base*); 1476 1477 void 1478 dump_decl_location(const decl_base_sptr&); 1479 1480 #ifndef ABG_ASSERT 1481 /// This is a wrapper around the 'assert' glibc call. It allows for 1482 /// its argument to have side effects, so that it keeps working when 1483 /// the code of libabigail is compiled with the NDEBUG macro defined. 1484 #define ABG_ASSERT(cond) do {({bool __abg_cond__ = bool(cond); assert(__abg_cond__); !!__abg_cond__;});} while (false) 1485 #endif 1486 1487 } // end namespace abigail 1488 #endif // __ABG_IRFWD_H__ 1489