Fixed crash when initial block has no first_stmt.
authorJustin Seyster <jseyster@cs.sunysb.edu>
Sat, 14 Aug 2010 02:30:14 +0000 (22:30 -0400)
committerJustin Seyster <jseyster@cs.sunysb.edu>
Sat, 14 Aug 2010 02:30:14 +0000 (22:30 -0400)
Still need to figure out how to correctly get the filename/lineno for
functions that have an entry block with no first_stmt.

src/aop-duplicate.c
src/aop-pc-entry.c

index 89d6d57f91e79d88c2981f7636100ca6f9011aac..69f191335d33703ac8dcae4716a81b832e6291f8 100644 (file)
@@ -150,8 +150,17 @@ duplicate_function_body (const char *tmpvar_name, gimple call)
   source_location orig_loc;
 
   /* Remember the source location in the original first block. */
-  cur_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION (cfun);
-  orig_loc = gimple_location (first_stmt (cur_bb->next_bb));
+    {
+      basic_block bb;
+      gimple stmt;
+
+      bb = ENTRY_BLOCK_PTR_FOR_FUNCTION (cfun);
+      stmt = first_stmt (bb->next_bb);
+      if (stmt != NULL)
+       orig_loc = gimple_location (first_stmt (bb->next_bb));
+      else
+       orig_loc = 0;
+    }
 
   bb_pairs = VEC_alloc (bb_pair, gc, INITIAL_PAIRS);
   label_pairs = VEC_alloc (label_pair, heap, INITIAL_PAIRS);
index a828a9ebed5151d73ef88291d611422db57df82a..f30d94501cf94391755df41e9215475b607ffb6b 100644 (file)
@@ -49,9 +49,22 @@ get_function_entry_xloc()
 {
   basic_block bb;
   expanded_location xloc;
-  
+  gimple stmt;
+
+  /* TODO: How do we figure out the line number and file number when
+     their is no first_stmt? */
   bb = ENTRY_BLOCK_PTR_FOR_FUNCTION (cfun);
-  xloc = expand_location (gimple_location (first_stmt (bb->next_bb)));
+  stmt = first_stmt (bb->next_bb);
+  if (stmt != NULL)
+    {
+      xloc = expand_location (gimple_location (stmt));
+    }
+  else
+    {
+      xloc.line = 0;
+      xloc.file = NULL;
+    }
+
   return xloc;
 }