From: Justin Seyster Date: Sat, 14 Aug 2010 02:30:14 +0000 (-0400) Subject: Fixed crash when initial block has no first_stmt. X-Git-Tag: release-v1.0~68 X-Git-Url: https://git.fsl.cs.stonybrook.edu/?a=commitdiff_plain;h=44dc7b0d4485f4bc300210984db4e4369a48503b;p=interaspect.git Fixed crash when initial block has no first_stmt. Still need to figure out how to correctly get the filename/lineno for functions that have an entry block with no first_stmt. --- diff --git a/src/aop-duplicate.c b/src/aop-duplicate.c index 89d6d57..69f1913 100644 --- a/src/aop-duplicate.c +++ b/src/aop-duplicate.c @@ -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); diff --git a/src/aop-pc-entry.c b/src/aop-pc-entry.c index a828a9e..f30d945 100644 --- a/src/aop-pc-entry.c +++ b/src/aop-pc-entry.c @@ -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; }