gdb: add back declarations for _initialize functions
[deliverable/binutils-gdb.git] / gdb / compile / compile-cplus-types.c
index 9425fc6ac7778162419decbf87cfda85e5ba79f4..a179bd6fe527015c0b6cdd9999cae68196cc08c2 100644 (file)
@@ -1,6 +1,6 @@
 /* Convert types from GDB to GCC
 
-   Copyright (C) 2014-2018 Free Software Foundation, Inc.
+   Copyright (C) 2014-2020 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 
 
 #include "defs.h"
-#include "common/preprocessor.h"
+#include "gdbsupport/preprocessor.h"
 #include "gdbtypes.h"
 #include "compile-internal.h"
 #include "compile-cplus.h"
-#include "gdb_assert.h"
+#include "gdbsupport/gdb_assert.h"
 #include "symtab.h"
 #include "source.h"
 #include "cp-support.h"
 #include "cp-abi.h"
-#include "symtab.h"
 #include "objfiles.h"
 #include "block.h"
 #include "gdbcmd.h"
 #include "c-lang.h"
-#include "compile-c.h"                 /* Included for c_get_range_decl_name
-                                  et al.  */
+#include "compile-c.h"
 #include <algorithm>
 
 /* Default compile flags for C++.  */
@@ -43,11 +41,11 @@ const char *compile_cplus_instance::m_default_cflags = "-std=gnu++11";
 
 /* Flag to enable internal debugging.  */
 
-static int debug_compile_cplus_types = 0;
+static bool debug_compile_cplus_types = false;
 
 /* Flag to enable internal scope switching debugging.  */
 
-static int debug_compile_cplus_scopes = 0;
+static bool debug_compile_cplus_scopes = false;
 
 /* Forward declarations.  */
 
@@ -63,11 +61,11 @@ compile_cplus_instance::decl_name (const char *natural)
   if (natural == nullptr)
     return nullptr;
 
-  char *name = cp_func_name (natural);
+  gdb::unique_xmalloc_ptr<char> name = cp_func_name (natural);
   if (name != nullptr)
-    return gdb::unique_xmalloc_ptr<char> (name);
+    return name;
 
-  return gdb::unique_xmalloc_ptr<char> (xstrdup (natural));
+  return make_unique_xstrdup (natural);
 }
 
 /* Get the access flag for the NUM'th field of TYPE.  */
@@ -114,7 +112,7 @@ debug_print_scope (const compile_scope &scope)
   for (const auto &comp: scope)
     {
       const char *symbol = (comp.bsymbol.symbol != nullptr
-                           ? SYMBOL_NATURAL_NAME (comp.bsymbol.symbol)
+                           ? comp.bsymbol.symbol->natural_name ()
                            : "<none>");
 
       printf_unfiltered ("\tname = %s, symbol = %s\n", comp.name.c_str (),
@@ -247,19 +245,22 @@ operator!= (const compile_scope &lhs, const compile_scope &rhs)
 /* See description in compile-cplus.h.  */
 
 void
-compile_cplus_instance::enter_scope (compile_scope &new_scope)
+compile_cplus_instance::enter_scope (compile_scope &&new_scope)
 {
   bool must_push = m_scopes.empty () || m_scopes.back () != new_scope;
 
   new_scope.m_pushed = must_push;
 
   /* Save the new scope.  */
-  m_scopes.push_back (new_scope);
+  m_scopes.push_back (std::move (new_scope));
 
   if (must_push)
     {
       if (debug_compile_cplus_scopes)
-       fprintf_unfiltered (gdb_stdlog, "entering new scope %p\n", new_scope);
+       {
+         fprintf_unfiltered (gdb_stdlog, "entering new scope %s\n",
+                             host_address_to_string (&m_scopes.back ()));
+       }
 
       /* Push the global namespace. */
       plugin ().push_namespace ("");
@@ -267,7 +268,7 @@ compile_cplus_instance::enter_scope (compile_scope &new_scope)
       /* Push all other namespaces.  Note that we do not push the last
         scope_component -- that's the actual type we are converting.  */
       std::for_each
-       (new_scope.begin (), new_scope.end () - 1,
+       (m_scopes.back ().begin (), m_scopes.back ().end () - 1,
         [this] (const scope_component &comp)
         {
          gdb_assert (TYPE_CODE (SYMBOL_TYPE (comp.bsymbol.symbol))
@@ -303,7 +304,10 @@ compile_cplus_instance::leave_scope ()
   if (current.m_pushed)
     {
       if (debug_compile_cplus_scopes)
-       fprintf_unfiltered (gdb_stdlog, "leaving scope %p\n", current);
+       {
+         fprintf_unfiltered (gdb_stdlog, "leaving scope %s\n",
+                             host_address_to_string (&current));
+       }
 
       /* Pop namespaces.  */
       std::for_each
@@ -354,7 +358,7 @@ compile_cplus_instance::new_scope (const char *type_name, struct type *type)
             class, the previous call will give us that type's gcc_type.
             Upper layers are expecting to get the original type's
             gcc_type!  */
-         get_cached_type (type, scope.m_nested_type);
+         get_cached_type (type, &scope.m_nested_type);
          return scope;
        }
     }
@@ -520,7 +524,7 @@ compile_cplus_convert_typedef (compile_cplus_instance *instance,
     = compile_cplus_instance::decl_name (TYPE_NAME (type));
 
   /* Make sure the scope for this type has been pushed.  */
-  instance->enter_scope (scope);
+  instance->enter_scope (std::move (scope));
 
   /* Convert the typedef's real type.  */
   gcc_type typedef_type = instance->convert_type (check_typedef (type));
@@ -816,7 +820,7 @@ compile_cplus_convert_struct_or_union (compile_cplus_instance *instance,
     }
 
   /* Push all scopes.  */
-  instance->enter_scope (scope);
+  instance->enter_scope (std::move (scope));
 
   /* First we create the resulting type and enter it into our hash
      table.  This lets recursive types work.  */
@@ -906,7 +910,7 @@ static gcc_type
 compile_cplus_convert_enum (compile_cplus_instance *instance, struct type *type,
                            enum gcc_cp_symbol_kind nested_access)
 {
-  int scoped_enum_p = FALSE;
+  bool scoped_enum_p = false;
 
   /* Create a new scope for this type.  */
   compile_scope scope = instance->new_scope (TYPE_NAME (type), type);
@@ -922,7 +926,7 @@ compile_cplus_convert_enum (compile_cplus_instance *instance, struct type *type,
     = compile_cplus_instance::decl_name (TYPE_NAME (type));
 
   /* Push all scopes.  */
-  instance->enter_scope (scope);
+  instance->enter_scope (std::move (scope));
 
   gcc_type int_type
     = instance->plugin ().get_int_type (TYPE_UNSIGNED (type),
@@ -1055,7 +1059,7 @@ compile_cplus_instance::convert_qualified_base (gcc_type base,
 {
   gcc_type result = base;
 
-  if (quals != GCC_CP_REF_QUAL_NONE)
+  if (quals != 0)
     result = plugin ().build_qualified_type (base, quals);
 
   return result;
@@ -1103,7 +1107,7 @@ compile_cplus_convert_namespace (compile_cplus_instance *instance,
     = compile_cplus_instance::decl_name (TYPE_NAME (type));
 
   /* Push scope.  */
-  instance->enter_scope (scope);
+  instance->enter_scope (std::move (scope));
 
   /* Convert this namespace.  */
   instance->plugin ().push_namespace (name.get ());
@@ -1205,7 +1209,7 @@ compile_cplus_instance::convert_type (struct type *type,
 {
   /* Check if TYPE has already been converted.  */
   gcc_type result;
-  if (get_cached_type (type, result))
+  if (get_cached_type (type, &result))
     return result;
 
   /* It is the first time this type has been seen -- convert it
@@ -1238,9 +1242,9 @@ compile_cplus_instance::gcc_cplus_leave_scope
    gcc_decl.  */
 
 static void
-compile_cplus_debug_output_1 (gcc_type arg)
+compile_cplus_debug_output_1 (ULONGEST arg)
 {
-  fprintf_unfiltered (gdb_stdlog, "%lld", arg);
+  fprintf_unfiltered (gdb_stdlog, "%s", pulongest (arg));
 }
 
 static void
@@ -1400,6 +1404,7 @@ gcc_cp_plugin::pop_binding_level (const char *debug_name)
   return pop_binding_level ();
 }
 
+void _initialize_compile_cplus_types ();
 void
 _initialize_compile_cplus_types ()
 {
This page took 0.029263 seconds and 4 git commands to generate.