aboutsummaryrefslogtreecommitdiff
path: root/gcc/gcov.c
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2021-01-03 21:40:04 +0100
committerThomas Koenig <tkoenig@gcc.gnu.org>2021-01-03 21:40:04 +0100
commitafae4a55ccaa0de95ea11e5f634084db6ab2f444 (patch)
treed632cc867d10410ba9fb750523be790b86846ac4 /gcc/gcov.c
parent9d9a82ec8478ff52c7a9d61f58cd2a7b6295b5f9 (diff)
parentd2eb616a0f7bea78164912aa438c29fe1ef5774a (diff)
downloadgcc-afae4a55ccaa0de95ea11e5f634084db6ab2f444.zip
gcc-afae4a55ccaa0de95ea11e5f634084db6ab2f444.tar.gz
gcc-afae4a55ccaa0de95ea11e5f634084db6ab2f444.tar.bz2
Merge branch 'master' into devel/coarray_native
Diffstat (limited to 'gcc/gcov.c')
-rw-r--r--gcc/gcov.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/gcc/gcov.c b/gcc/gcov.c
index 36938bd..8dcec94 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -293,7 +293,7 @@ public:
/* Index of source file where the function is defined. */
unsigned src;
- /* Vector of line information. */
+ /* Vector of line information (used only for group functions). */
vector<line_info> lines;
/* Next function. */
@@ -1165,21 +1165,22 @@ output_json_intermediate_file (json::array *json_files, source_info *src)
json::array *lineso = new json::array ();
root->set ("lines", lineso);
- function_info *last_non_group_fn = NULL;
+ vector<function_info *> last_non_group_fns;
for (unsigned line_num = 1; line_num <= src->lines.size (); line_num++)
{
vector<function_info *> *fns = src->get_functions_at_location (line_num);
if (fns != NULL)
- /* Print first group functions that begin on the line. */
+ /* Print info for all group functions that begin on the line. */
for (vector<function_info *>::iterator it2 = fns->begin ();
it2 != fns->end (); it2++)
{
if (!(*it2)->is_group)
- last_non_group_fn = *it2;
+ last_non_group_fns.push_back (*it2);
vector<line_info> &lines = (*it2)->lines;
+ /* The LINES array is allocated only for group functions. */
for (unsigned i = 0; i < lines.size (); i++)
{
line_info *line = &lines[i];
@@ -1190,9 +1191,17 @@ output_json_intermediate_file (json::array *json_files, source_info *src)
/* Follow with lines associated with the source file. */
if (line_num < src->lines.size ())
- output_intermediate_json_line (lineso, &src->lines[line_num], line_num,
- (last_non_group_fn != NULL
- ? last_non_group_fn->m_name : NULL));
+ {
+ unsigned size = last_non_group_fns.size ();
+ function_info *last_fn = size > 0 ? last_non_group_fns[size - 1] : NULL;
+ const char *fname = last_fn ? last_fn->m_name : NULL;
+ output_intermediate_json_line (lineso, &src->lines[line_num], line_num,
+ fname);
+
+ /* Pop ending function from stack. */
+ if (last_fn != NULL && last_fn->end_line == line_num)
+ last_non_group_fns.pop_back ();
+ }
}
}