Skip to content

Commit

Permalink
Try to fix mismatch in macro locations for definitions and expansions
Browse files Browse the repository at this point in the history
  • Loading branch information
eunovm committed Aug 21, 2019
1 parent 28cd3a0 commit 7ede2f9
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions libcpp/ldv-cpp-pointcut-matcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ ldv_match_macro (cpp_reader *pfile, cpp_hashnode *node, const cpp_token ***arg_v
ldv_cp_ptr c_pointcut = NULL;
ldv_i_match_ptr match = NULL;
ldv_i_macro_ptr macro = NULL;
rich_location richloc (pfile->line_table, node->value.macro->line);
expanded_location xloc;
const line_map_ordinary *map = NULL;
const char *token_file_path = NULL;
unsigned int token_line;
Expand Down Expand Up @@ -280,25 +282,19 @@ ldv_match_macro (cpp_reader *pfile, cpp_hashnode *node, const cpp_token ***arg_v
macro->macro_name = ldv_create_id ();
ldv_puts_id ((const char *) (NODE_NAME (node)), macro->macro_name);

/* Given token location corresponds to either define or expand location. */
map = LINEMAPS_LAST_ORDINARY_MAP (pfile->line_table);
token_file_path = ldv_get_realpath (LINEMAP_FILE (map));
token_line = SOURCE_LINE(map, pfile->cur_token[-1].src_loc);
if (pp_kind == LDV_PP_DEFINE)
{
macro->file_path = token_file_path;
macro->line = token_line;
}
else
/* Obtain macro location in the same way for definitions and expansions. */
xloc = richloc.get_expanded_location(0);
macro->file_path = xloc.file;
macro->line = xloc.line;

/* Given token location corresponds to expansion location. */
if (pp_kind == LDV_PP_EXPAND)
{
map = LINEMAPS_LAST_ORDINARY_MAP (pfile->line_table);
token_file_path = ldv_get_realpath (LINEMAP_FILE (map));
token_line = SOURCE_LINE(map, pfile->cur_token[-1].src_loc);
macro->expansion_file_path = token_file_path;
macro->expansion_line = token_line;

/* For macro expansions we need to store locations of macros themselves. */
rich_location richloc (pfile->line_table, node->value.macro->line);
expanded_location xloc = richloc.get_expanded_location(0);
macro->file_path = xloc.file;
macro->line = xloc.line;
}

macro->macro_param = NULL;
Expand Down

0 comments on commit 7ede2f9

Please sign in to comment.