OLD | NEW |
1 /* Helper routines for C++ support in GDB. | 1 /* Helper routines for C++ support in GDB. |
2 Copyright (C) 2003-2004, 2007-2012 Free Software Foundation, Inc. | 2 Copyright (C) 2003-2004, 2007-2012 Free Software Foundation, Inc. |
3 | 3 |
4 Contributed by David Carlton and by Kealia, Inc. | 4 Contributed by David Carlton and by Kealia, Inc. |
5 | 5 |
6 This file is part of GDB. | 6 This file is part of GDB. |
7 | 7 |
8 This program is free software; you can redistribute it and/or modify | 8 This program is free software; you can redistribute it and/or modify |
9 it under the terms of the GNU General Public License as published by | 9 it under the terms of the GNU General Public License as published by |
10 the Free Software Foundation; either version 3 of the License, or | 10 the Free Software Foundation; either version 3 of the License, or |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 sym = lookup_symbol_aux_block (name, global_block, domain); | 653 sym = lookup_symbol_aux_block (name, global_block, domain); |
654 } | 654 } |
655 else | 655 else |
656 { | 656 { |
657 sym = lookup_symbol_global (name, block, domain); | 657 sym = lookup_symbol_global (name, block, domain); |
658 } | 658 } |
659 | 659 |
660 return sym; | 660 return sym; |
661 } | 661 } |
662 | 662 |
663 /* Look up a type named NESTED_NAME that is nested inside the C++ | 663 /* Look up a symbol named NESTED_NAME that is nested inside the C++ |
664 class or namespace given by PARENT_TYPE, from within the context | 664 class or namespace given by PARENT_TYPE, from within the context |
665 given by BLOCK. Return NULL if there is no such nested type. */ | 665 given by BLOCK. Return NULL if there is no such nested type. */ |
666 | 666 |
667 struct type * | 667 struct symbol * |
668 cp_lookup_nested_type (struct type *parent_type, | 668 cp_lookup_nested_symbol (struct type *parent_type, |
669 » » const char *nested_name, | 669 » » » const char *nested_name, |
670 » » const struct block *block) | 670 » » » const struct block *block) |
671 { | 671 { |
672 /* type_name_no_tag_required provides better error reporting using the | 672 /* type_name_no_tag_required provides better error reporting using the |
673 original type. */ | 673 original type. */ |
674 struct type *saved_parent_type = parent_type; | 674 struct type *saved_parent_type = parent_type; |
675 | 675 |
676 CHECK_TYPEDEF (parent_type); | 676 CHECK_TYPEDEF (parent_type); |
677 | 677 |
678 switch (TYPE_CODE (parent_type)) | 678 switch (TYPE_CODE (parent_type)) |
679 { | 679 { |
680 case TYPE_CODE_STRUCT: | 680 case TYPE_CODE_STRUCT: |
681 case TYPE_CODE_NAMESPACE: | 681 case TYPE_CODE_NAMESPACE: |
682 case TYPE_CODE_UNION: | 682 case TYPE_CODE_UNION: |
683 { | 683 { |
684 /* NOTE: carlton/2003-11-10: We don't treat C++ class members | 684 /* NOTE: carlton/2003-11-10: We don't treat C++ class members |
685 of classes like, say, data or function members. Instead, | 685 of classes like, say, data or function members. Instead, |
686 they're just represented by symbols whose names are | 686 they're just represented by symbols whose names are |
687 qualified by the name of the surrounding class. This is | 687 qualified by the name of the surrounding class. This is |
688 just like members of namespaces; in particular, | 688 just like members of namespaces; in particular, |
689 lookup_symbol_namespace works when looking them up. */ | 689 lookup_symbol_namespace works when looking them up. */ |
690 | 690 |
691 const char *parent_name = type_name_no_tag_or_error (saved_parent_type); | 691 const char *parent_name = type_name_no_tag_or_error (saved_parent_type); |
692 struct symbol *sym | 692 struct symbol *sym |
693 = cp_lookup_symbol_in_namespace (parent_name, nested_name, | 693 = cp_lookup_symbol_in_namespace (parent_name, nested_name, |
694 block, VAR_DOMAIN); | 694 block, VAR_DOMAIN); |
695 char *concatenated_name; | 695 char *concatenated_name; |
696 | 696 |
697 » if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF) | 697 » if (sym != NULL) |
698 » return SYMBOL_TYPE (sym); | 698 » return sym; |
699 | 699 |
700 /* Now search all static file-level symbols. Not strictly | 700 /* Now search all static file-level symbols. Not strictly |
701 correct, but more useful than an error. We do not try to | 701 correct, but more useful than an error. We do not try to |
702 guess any imported namespace as even the fully specified | 702 guess any imported namespace as even the fully specified |
703 namespace seach is is already not C++ compliant and more | 703 namespace seach is is already not C++ compliant and more |
704 assumptions could make it too magic. */ | 704 assumptions could make it too magic. */ |
705 | 705 |
706 concatenated_name = alloca (strlen (parent_name) + 2 | 706 concatenated_name = alloca (strlen (parent_name) + 2 |
707 + strlen (nested_name) + 1); | 707 + strlen (nested_name) + 1); |
708 sprintf (concatenated_name, "%s::%s", | 708 sprintf (concatenated_name, "%s::%s", |
709 parent_name, nested_name); | 709 parent_name, nested_name); |
710 » sym = lookup_static_symbol_aux (concatenated_name, | 710 » sym = lookup_static_symbol_aux (concatenated_name, VAR_DOMAIN); |
711 » » » » » VAR_DOMAIN); | 711 » if (sym != NULL) |
712 » if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF) | 712 » return sym; |
713 » return SYMBOL_TYPE (sym); | |
714 | 713 |
715 return NULL; | 714 return NULL; |
716 } | 715 } |
717 default: | 716 default: |
718 internal_error (__FILE__, __LINE__, | 717 internal_error (__FILE__, __LINE__, |
719 » » _("cp_lookup_nested_type called " | 718 » » _("cp_lookup_nested_symbol called " |
720 "on a non-aggregate type.")); | 719 "on a non-aggregate type.")); |
721 } | 720 } |
722 } | 721 } |
723 | 722 |
724 /* The C++-version of lookup_transparent_type. */ | 723 /* The C++-version of lookup_transparent_type. */ |
725 | 724 |
726 /* FIXME: carlton/2004-01-16: The problem that this is trying to | 725 /* FIXME: carlton/2004-01-16: The problem that this is trying to |
727 address is that, unfortunately, sometimes NAME is wrong: it may not | 726 address is that, unfortunately, sometimes NAME is wrong: it may not |
728 include the name of namespaces enclosing the type in question. | 727 include the name of namespaces enclosing the type in question. |
729 lookup_transparent_type gets called when the type in question | 728 lookup_transparent_type gets called when the type in question |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 _initialize_cp_namespace (void) | 806 _initialize_cp_namespace (void) |
808 { | 807 { |
809 struct cmd_list_element *cmd; | 808 struct cmd_list_element *cmd; |
810 | 809 |
811 cmd = add_cmd ("namespace", class_maintenance, | 810 cmd = add_cmd ("namespace", class_maintenance, |
812 maintenance_cplus_namespace, | 811 maintenance_cplus_namespace, |
813 _("Deprecated placeholder for removed functionality."), | 812 _("Deprecated placeholder for removed functionality."), |
814 &maint_cplus_cmd_list); | 813 &maint_cplus_cmd_list); |
815 deprecate_cmd (cmd, NULL); | 814 deprecate_cmd (cmd, NULL); |
816 } | 815 } |
OLD | NEW |