More cleanup for --enable-mapped-location.
authorPer Bothner <per@bothner.com>
Thu, 30 Sep 2004 23:23:52 +0000 (16:23 -0700)
committerPer Bothner <bothner@gcc.gnu.org>
Thu, 30 Sep 2004 23:23:52 +0000 (16:23 -0700)
* class.c (push_class):  If USE_MAPPED_LOCATION don't set
input_location here.  Instead do it in give_name_to_class.
(build_class_ref):  Set DECL_ARTIFICIAL, for the sake of dwarf2out.
* expr.c (expand_byte_code): Call linemap_line_start.
* expr.c (build_expr_wfl):  If USE_MAPPED_LOCATION, change final
parameters to a source_location.  Don't need EXPR_WFL_FILENAME_NODE.
(expr_add_location):  New function, if USE_MAPPED_LOCATION.
* class.c (maybe_layout_super_class):  Adjust build_expr_wfl call
to USE_MAPPED_LOCATION case.

From-SVN: r88365

gcc/java/ChangeLog
gcc/java/class.c
gcc/java/expr.c

index c738401d4434db9a60fc3209bd628a5d84867540..9211e502315b1d6641f3145ce1b6b2290c390004 100644 (file)
@@ -1,3 +1,16 @@
+2004-09-30  Per Bothner  <per@bothner.com>
+
+       More cleanup for --enable-mapped-location.
+       * class.c (push_class):  If USE_MAPPED_LOCATION don't set
+       input_location here.  Instead do it in give_name_to_class.
+       (build_class_ref):  Set DECL_ARTIFICIAL, for the sake of dwarf2out.
+       * expr.c (expand_byte_code): Call linemap_line_start.
+       * expr.c (build_expr_wfl):  If USE_MAPPED_LOCATION, change final
+       parameters to a source_location.  Don't need EXPR_WFL_FILENAME_NODE.
+       (expr_add_location):  New function, if USE_MAPPED_LOCATION.
+       * class.c (maybe_layout_super_class):  Adjust build_expr_wfl call
+       to USE_MAPPED_LOCATION case.
+
 2004-09-29  Per Bothner  <per@bothner.com>
 
        * java-tree.h:  Redefine some macros and add soem declaration
index 879775455b1cbcd84a2f1a7d4cb05a16bf6e649b..6a417a7ff1b96fa7b9818bddbc80ee7d290c9311 100644 (file)
@@ -428,10 +428,12 @@ push_class (tree class_type, tree class_name)
 {
   tree decl, signature;
   location_t saved_loc = input_location;
+#ifndef USE_MAPPED_LOCATION
   tree source_name = identifier_subst (class_name, "", '.', '/', ".java");
-  CLASS_P (class_type) = 1;
   input_filename = IDENTIFIER_POINTER (source_name);
   input_line = 0;
+#endif
+  CLASS_P (class_type) = 1;
   decl = build_decl (TYPE_DECL, class_name, class_type);
 
   /* dbxout needs a DECL_SIZE if in gstabs mode */
@@ -1037,6 +1039,7 @@ build_class_ref (tree type)
              TREE_STATIC (decl) = 1;
              TREE_PUBLIC (decl) = 1;
              DECL_EXTERNAL (decl) = 1;
+             DECL_ARTIFICIAL (decl) = 1;
              make_decl_rtl (decl);
              pushdecl_top_level (decl);
            }
@@ -1996,9 +1999,14 @@ maybe_layout_super_class (tree super_class, tree this_class)
          if (this_class)
            {
              tree this_decl = TYPE_NAME (this_class);
+#ifdef USE_MAPPED_LOCATION
+             this_wrap = build_expr_wfl (this_class,
+                                         DECL_SOURCE_LOCATION (this_decl));
+#else
              this_wrap = build_expr_wfl (this_class,
                                          DECL_SOURCE_FILE (this_decl),
                                          DECL_SOURCE_LINE (this_decl), 0);
+#endif
            }
          super_class = do_resolve_class (NULL_TREE, /* FIXME? */
                                          super_class, NULL_TREE, this_wrap);
index 7cfc874e36f1a3538301ef4aa1a3d05989b3689a..3d878b523cf51cfeb74c1424dd0db087e4462d3d 100644 (file)
@@ -2695,7 +2695,12 @@ expand_byte_code (JCF *jcf, tree method)
              linenumber_pointer += 4;
              if (pc == PC)
                {
-                 input_location.line = GET_u2 (linenumber_pointer - 2);
+                 int line = GET_u2 (linenumber_pointer - 2);
+#ifdef USE_MAPPED_LOCATION
+                 input_location = linemap_line_start (&line_table, line, 1);
+#else
+                 input_location.line = line;
+#endif
                  if (!(instruction_bits[PC] & BCODE_HAS_MULTI_LINENUMBERS))
                    break;
                }
@@ -3225,21 +3230,33 @@ force_evaluation_order (tree node)
    recursively more than one file (Java is one of them).  */
 
 tree
-build_expr_wfl (tree node, const char *file, int line, int col)
+build_expr_wfl (tree node,
+#ifdef USE_MAPPED_LOCATION
+               source_location location
+#else
+               const char *file, int line, int col
+#endif
+)
 {
+  tree wfl;
+#ifdef USE_MAPPED_LOCATION
+  wfl = make_node (EXPR_WITH_FILE_LOCATION);
+  SET_EXPR_LOCATION (wfl, location);
+#else
+  wfl = make_node (EXPR_WITH_FILE_LOCATION);
+
   static const char *last_file = 0;
   static tree last_filenode = NULL_TREE;
-  tree wfl = make_node (EXPR_WITH_FILE_LOCATION);
 
-  EXPR_WFL_NODE (wfl) = node;
   EXPR_WFL_SET_LINECOL (wfl, line, col);
   if (file != last_file)
     {
       last_file = file;
       last_filenode = file ? get_identifier (file) : NULL_TREE;
     }
-
   EXPR_WFL_FILENAME_NODE (wfl) = last_filenode;
+#endif
+  EXPR_WFL_NODE (wfl) = node;
   if (node)
     {
       if (IS_NON_TYPE_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (node))))
@@ -3250,6 +3267,42 @@ build_expr_wfl (tree node, const char *file, int line, int col)
   return wfl;
 }
 
+#ifdef USE_MAPPED_LOCATION
+tree
+expr_add_location (tree node, source_location location, bool statement)
+{
+  tree wfl;
+#if 0
+  /* FIXME. This optimization causes failures in code that expects an
+     EXPR_WITH_FILE_LOCATION.  E.g. in resolve_qualified_expression_name. */
+  if (node && ! (statement && flag_emit_class_files))
+    {
+      source_location node_loc = EXPR_LOCATION (node);
+      if (node_loc == location || location == UNKNOWN_LOCATION)
+       return node;
+      if (node_loc == UNKNOWN_LOCATION
+         && IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (node))))
+       {
+         SET_EXPR_LOCATION (node, location);
+         return node;
+       }
+    }
+#endif
+  wfl = make_node (EXPR_WITH_FILE_LOCATION);
+  SET_EXPR_LOCATION (wfl, location);
+  EXPR_WFL_NODE (wfl) = node;
+  if (statement && debug_info_level != DINFO_LEVEL_NONE)
+    EXPR_WFL_EMIT_LINE_NOTE (wfl) = 1;
+  if (node)
+    {
+      if (IS_NON_TYPE_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (node))))
+       TREE_SIDE_EFFECTS (wfl) = TREE_SIDE_EFFECTS (node);
+      TREE_TYPE (wfl) = TREE_TYPE (node);
+    }
+
+  return wfl;
+}
+#endif
 
 /* Build a node to represent empty statements and blocks. */