Commits

Anonymous committed 344056e

BUG: Namespace "std" is not always referenced, so add it when there is no start namespace.

Comments (0)

Files changed (2)

-/* XML output implementation for the C++ compiler.
+/*=========================================================================
 
-   Brad King (brad.king@kitware.com)
-   Kitware, Inc.   (www.kitware.com)
+  Program:   GCC-XML
+  Module:    $RCSfile$
+  Language:  C++
+  Date:      $Date$
+  Version:   $Revision$
 
-This file WILL HOPEFULLY BE part of GNU CC (eventually).
+  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
+  See Copyright.txt for details.
 
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
+     This software is distributed WITHOUT ANY WARRANTY; without even 
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+     PURPOSE.  See the above copyright notices for more information.
 
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING.  If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
-
+=========================================================================*/
 
 /* Organization of this source:
    The entry point is do_xml_output(), which is called from the end of
 
 #include "splay-tree.h"
 
+/* Use GCC_XML_GCC_VERSION to modify code based on the version of GCC
+   in which we are being built.  This is set in the patched version of
+   cp-tree.h.  The format is 0xMMmmpp, where MM is the major version
+   number, mm is the minor version number, and pp is the patch level.
+   Examples:  gcc 3.0.4 = 0x030004
+              gcc 3.2.0 = 0x030200  */
+#if defined(GCC_XML_GCC_VERSION) && (GCC_XML_GCC_VERSION >= 0x030100)
+# define XML_CP_ERROR cp_error_at
+#else
+# define XML_CP_ERROR cp_error
+# define XML_HAVE_FAKE_STD_NODE
+#endif
+
 /* A "dump node" corresponding to a particular tree node.  */
 typedef struct xml_dump_node
 {
   file = fopen (filename, "w");
   if (!file)
     {
-    cp_error ("could not open xml-dump file `%s'", filename);
+    XML_CP_ERROR ("could not open xml-dump file `%s'", filename);
     return;
     }
   
   xdi.file_queue_end = 0;
   xdi.file_index = 0;
   xdi.file_nodes = splay_tree_new (splay_tree_compare_pointers, 0, 0);
+  xdi.require_complete = 1;
   
   /* Add the starting nodes for the dump.  */
   if (flag_xml_start)
     {
     /* No start specified.  Use global namespace.  */
     xml_add_node (&xdi, global_namespace, 1);
+
+    /* Also add std namespace because it is not always referenced.  */
+    xml_add_node (&xdi, std_node, 1);
     }
   
   /* Start dump.  */
   fprintf (file, "<GCC_XML>\n");
   
   /* Dump the complete nodes.  */
-  xdi.require_complete = 1;
   xml_dump (&xdi);  
   
   /* Queue all the incomplete nodes.  */
   
   if(!xdi->require_complete && complete)
     {
-    cp_error ("XML dump bug: complete node added during incomplete phase.\n");
+    XML_CP_ERROR ("XML dump bug: complete node added during incomplete phase.\n");
     }
 
   /* Return node's index.  */
 static void
 xml_print_default_argument_attribute (xml_dump_info_p xdi, tree t)
 {
-  const char* value =
-    xml_get_encoded_string_from_string (expr_as_string (t, 0));  
+  const char* value;
+
+  switch (TREE_CODE(t))
+    {
+    case CAST_EXPR:
+      value = xml_get_encoded_string_from_string ("<gccxml-cast-expr>");
+      break;
+    default:
+      value = xml_get_encoded_string_from_string (expr_as_string (t, 0));
+      break;
+    };
   fprintf (xdi->file, " default=\"%s\"", value);
 }
 
       default:
         /* xml_output_unimplemented (xdi, ts, 0,
           "xml_dump_template_decl SPECIALIZATIONS");  */
+        break;
       }
     }
   
       default:
         /* xml_output_unimplemented (xdi, ts, 0,
            "xml_dump_template_decl INSTANTIATIONS");  */
+        break;
       }
     }
   
   switch (TREE_CODE (n))
     {
     case NAMESPACE_DECL:
+#if defined(XML_HAVE_FAKE_STD_NODE)
       if(n != fake_std_node)
+#endif
         {
         return xml_add_node_real (xdi, n, complete);
         }
 void
 xml_add_start_nodes (xml_dump_info_p xdi, const char* in_start_list)
 {
+  size_t len = strlen(in_start_list);
   int pos=0;
-  char* start_list = strdup(in_start_list);
+  char* start_list = (char*)xmalloc(len+1);
   char* cur_start = start_list;
   tree node = 0;
+  strcpy(start_list, in_start_list);
   
   /* Parse out the comma-separated list.  */
   while (start_list[pos])
-/* XML output implementation for the C++ compiler.
+/*=========================================================================
 
-   Brad King (brad.king@kitware.com)
-   Kitware, Inc.   (www.kitware.com)
+  Program:   GCC-XML
+  Module:    $RCSfile$
+  Language:  C++
+  Date:      $Date$
+  Version:   $Revision$
 
-This file WILL HOPEFULLY BE part of GNU CC (eventually).
+  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
+  See Copyright.txt for details.
 
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
+     This software is distributed WITHOUT ANY WARRANTY; without even 
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+     PURPOSE.  See the above copyright notices for more information.
 
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING.  If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
-
+=========================================================================*/
 
 /* Organization of this source:
    The entry point is do_xml_output(), which is called from the end of
 
 #include "splay-tree.h"
 
+/* Use GCC_XML_GCC_VERSION to modify code based on the version of GCC
+   in which we are being built.  This is set in the patched version of
+   cp-tree.h.  The format is 0xMMmmpp, where MM is the major version
+   number, mm is the minor version number, and pp is the patch level.
+   Examples:  gcc 3.0.4 = 0x030004
+              gcc 3.2.0 = 0x030200  */
+#if defined(GCC_XML_GCC_VERSION) && (GCC_XML_GCC_VERSION >= 0x030100)
+# define XML_CP_ERROR cp_error_at
+#else
+# define XML_CP_ERROR cp_error
+# define XML_HAVE_FAKE_STD_NODE
+#endif
+
 /* A "dump node" corresponding to a particular tree node.  */
 typedef struct xml_dump_node
 {
   file = fopen (filename, "w");
   if (!file)
     {
-    cp_error ("could not open xml-dump file `%s'", filename);
+    XML_CP_ERROR ("could not open xml-dump file `%s'", filename);
     return;
     }
   
   xdi.file_queue_end = 0;
   xdi.file_index = 0;
   xdi.file_nodes = splay_tree_new (splay_tree_compare_pointers, 0, 0);
+  xdi.require_complete = 1;
   
   /* Add the starting nodes for the dump.  */
   if (flag_xml_start)
     {
     /* No start specified.  Use global namespace.  */
     xml_add_node (&xdi, global_namespace, 1);
+
+    /* Also add std namespace because it is not always referenced.  */
+    xml_add_node (&xdi, std_node, 1);
     }
   
   /* Start dump.  */
   fprintf (file, "<GCC_XML>\n");
   
   /* Dump the complete nodes.  */
-  xdi.require_complete = 1;
   xml_dump (&xdi);  
   
   /* Queue all the incomplete nodes.  */
   
   if(!xdi->require_complete && complete)
     {
-    cp_error ("XML dump bug: complete node added during incomplete phase.\n");
+    XML_CP_ERROR ("XML dump bug: complete node added during incomplete phase.\n");
     }
 
   /* Return node's index.  */
 static void
 xml_print_default_argument_attribute (xml_dump_info_p xdi, tree t)
 {
-  const char* value =
-    xml_get_encoded_string_from_string (expr_as_string (t, 0));  
+  const char* value;
+
+  switch (TREE_CODE(t))
+    {
+    case CAST_EXPR:
+      value = xml_get_encoded_string_from_string ("<gccxml-cast-expr>");
+      break;
+    default:
+      value = xml_get_encoded_string_from_string (expr_as_string (t, 0));
+      break;
+    };
   fprintf (xdi->file, " default=\"%s\"", value);
 }
 
       default:
         /* xml_output_unimplemented (xdi, ts, 0,
           "xml_dump_template_decl SPECIALIZATIONS");  */
+        break;
       }
     }
   
       default:
         /* xml_output_unimplemented (xdi, ts, 0,
            "xml_dump_template_decl INSTANTIATIONS");  */
+        break;
       }
     }
   
   switch (TREE_CODE (n))
     {
     case NAMESPACE_DECL:
+#if defined(XML_HAVE_FAKE_STD_NODE)
       if(n != fake_std_node)
+#endif
         {
         return xml_add_node_real (xdi, n, complete);
         }
 void
 xml_add_start_nodes (xml_dump_info_p xdi, const char* in_start_list)
 {
+  size_t len = strlen(in_start_list);
   int pos=0;
-  char* start_list = strdup(in_start_list);
+  char* start_list = (char*)xmalloc(len+1);
   char* cur_start = start_list;
   tree node = 0;
+  strcpy(start_list, in_start_list);
   
   /* Parse out the comma-separated list.  */
   while (start_list[pos])
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.