diff options
author | chefmax <chefmax@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-01-18 16:06:31 +0000 |
---|---|---|
committer | chefmax <chefmax@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-01-18 16:06:31 +0000 |
commit | c8b0900d94852427c0458aaadf0ecbc2461f1662 (patch) | |
tree | 7bc51d9df5797da527b28b3f4b7ecb580608b1e4 /gcc/asan.c | |
parent | 32d3ed1dc7c10d9037c3450a4fec1723aeab3163 (diff) | |
download | gcc-c8b0900d94852427c0458aaadf0ecbc2461f1662.tar.gz |
PR lto/79061
gcc/
* asan.c (get_translation_unit_decl): New function.
(asan_add_global): Extract modules file name from globals
TRANSLATION_UNIT_DECL in lto mode.
* tree.c (build_translation_unit_decl): Add source location for newly
built TRANSLATION_UNIT_DECL.
gcc/lto/
* lto.c (lto_read_decls): accept location cache for
TRANSLATION_UNIT_DECL.
gcc/testsuite/
* gcc.dg/cpp/mi1.c: Adjust testcase.
* gcc.dg/pch/cpp-3.c: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@244581 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/asan.c')
-rw-r--r-- | gcc/asan.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/gcc/asan.c b/gcc/asan.c index 74500448a12..9a59fe4f100 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -2372,6 +2372,22 @@ asan_needs_odr_indicator_p (tree decl) && TREE_PUBLIC (decl)); } +/* For given DECL return its corresponding TRANSLATION_UNIT_DECL. */ + +static const_tree +get_translation_unit_decl (tree decl) +{ + const_tree context = decl; + while (context && TREE_CODE (context) != TRANSLATION_UNIT_DECL) + { + if (TREE_CODE (context) == BLOCK) + context = BLOCK_SUPERCONTEXT (context); + else + context = get_containing_scope (context); + } + return context; +} + /* Append description of a single global DECL into vector V. TYPE is __asan_global struct type as returned by asan_global_struct. */ @@ -2391,7 +2407,14 @@ asan_add_global (tree decl, tree type, vec<constructor_elt, va_gc> *v) pp_string (&asan_pp, "<unknown>"); str_cst = asan_pp_string (&asan_pp); - pp_string (&module_name_pp, main_input_filename); + const char *filename = main_input_filename; + if (in_lto_p) + { + const_tree translation_unit_decl = get_translation_unit_decl (decl); + if (translation_unit_decl) + filename = DECL_SOURCE_FILE (translation_unit_decl); + } + pp_string (&module_name_pp, filename); module_name_cst = asan_pp_string (&module_name_pp); if (asan_needs_local_alias (decl)) |