Fix dwarf2loc.h::dwarf2_evaluate_property function description.
[deliverable/binutils-gdb.git] / gdb / cp-namespace.c
index 755aeef89d9cf73c9c16e2f9e47f8ba529536869..c6e1102e0bde6629ba9a9c3d42f18375922d827b 100644 (file)
@@ -1,5 +1,5 @@
 /* Helper routines for C++ support in GDB.
-   Copyright (C) 2003-2013 Free Software Foundation, Inc.
+   Copyright (C) 2003-2014 Free Software Foundation, Inc.
 
    Contributed by David Carlton and by Kealia, Inc.
 
@@ -23,7 +23,6 @@
 #include "gdb_obstack.h"
 #include "symtab.h"
 #include "symfile.h"
-#include "gdb_assert.h"
 #include "block.h"
 #include "objfiles.h"
 #include "gdbtypes.h"
@@ -473,7 +472,8 @@ cp_lookup_symbol_imports_or_template (const char *scope,
          char *name_copy = xstrdup (SYMBOL_NATURAL_NAME (function));
          struct cleanup *cleanups = make_cleanup (xfree, name_copy);
          const struct language_defn *lang = language_def (language_cplus);
-         struct gdbarch *arch = SYMBOL_SYMTAB (function)->objfile->gdbarch;
+         struct gdbarch *arch
+           = get_objfile_arch (SYMBOL_SYMTAB (function)->objfile);
          const struct block *parent = BLOCK_SUPERBLOCK (block);
 
          while (1)
@@ -668,6 +668,11 @@ lookup_symbol_file (const char *name,
            }
 
          type = check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (this)));
+         /* If TYPE_NAME is NULL, abandon trying to find this symbol.
+            This can happen for lambda functions compiled with clang++,
+            which outputs no name for the container class.  */
+         if (TYPE_NAME (type) == NULL)
+           return NULL;
          klass = xstrdup (TYPE_NAME (type));
          nested = xstrdup (name);
        }
@@ -702,6 +707,34 @@ lookup_symbol_file (const char *name,
   return sym;
 }
 
+/* Search through the base classes of PARENT_TYPE for a base class
+   named NAME and return its type.  If not found, return NULL.  */
+
+struct type *
+find_type_baseclass_by_name (struct type *parent_type, const char *name)
+{
+  int i;
+
+  CHECK_TYPEDEF (parent_type);
+  for (i = 0; i < TYPE_N_BASECLASSES (parent_type); ++i)
+    {
+      struct type *type = check_typedef (TYPE_BASECLASS (parent_type, i));
+      const char *base_name = TYPE_BASECLASS_NAME (parent_type, i);
+
+      if (base_name == NULL)
+       continue;
+
+      if (streq (base_name, name))
+       return type;
+
+      type = find_type_baseclass_by_name (type, name);
+      if (type != NULL)
+       return type;
+    }
+
+  return NULL;
+}
+
 /* Search through the base classes of PARENT_TYPE for a symbol named
    NAME in block BLOCK.  */
 
@@ -783,6 +816,11 @@ cp_lookup_nested_symbol (struct type *parent_type,
     case TYPE_CODE_STRUCT:
     case TYPE_CODE_NAMESPACE:
     case TYPE_CODE_UNION:
+    case TYPE_CODE_ENUM:
+    /* NOTE: Handle modules here as well, because Fortran is re-using the C++
+       specific code to lookup nested symbols in modules, by calling the
+       function pointer la_lookup_symbol_nonlocal, which ends up here.  */
+    case TYPE_CODE_MODULE:
       {
        /* NOTE: carlton/2003-11-10: We don't treat C++ class members
           of classes like, say, data or function members.  Instead,
This page took 0.025142 seconds and 4 git commands to generate.