]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Properly mark lambdas in GCOV (PR gcov-profile/86109).
authorMartin Liska <mliska@suse.cz>
Wed, 3 Oct 2018 08:30:10 +0000 (10:30 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Wed, 3 Oct 2018 08:30:10 +0000 (08:30 +0000)
2018-10-03  Martin Liska  <mliska@suse.cz>

PR gcov-profile/86109
* coverage.c (coverage_begin_function): Do not
mark lambdas as artificial.
* tree-core.h (struct GTY): Remove tm_clone_flag
and introduce new lambda_function.
* tree.h (DECL_LAMBDA_FUNCTION): New macro.
2018-10-03  Martin Liska  <mliska@suse.cz>

PR gcov-profile/86109
* parser.c (cp_parser_lambda_declarator_opt):
Set DECL_LAMBDA_FUNCTION for lambdas.
2018-10-03  Martin Liska  <mliska@suse.cz>

PR gcov-profile/86109
* g++.dg/gcov/pr86109.C: New test.

From-SVN: r264806

gcc/ChangeLog
gcc/coverage.c
gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/gcov/pr86109.C [new file with mode: 0644]
gcc/tree-core.h
gcc/tree.h

index 9906789b510f375c1914cd49dec012aaa0f5ec83..a6e1a8ebdf0d74463db36ade34925bc46bf12654 100644 (file)
@@ -1,3 +1,12 @@
+2018-10-03  Martin Liska  <mliska@suse.cz>
+
+       PR gcov-profile/86109
+       * coverage.c (coverage_begin_function): Do not
+       mark lambdas as artificial.
+       * tree-core.h (struct GTY): Remove tm_clone_flag
+       and introduce new lambda_function.
+       * tree.h (DECL_LAMBDA_FUNCTION): New macro.
+
 2018-10-02  Aaron Sawdey  <acsawdey@linux.ibm.com>
 
        PR target/87474
index 701460cf929fabe47283b817f0e02de535af02e1..599a3bb9aeb60c440775cd601bf40265a9a508ec 100644 (file)
@@ -630,7 +630,8 @@ coverage_begin_function (unsigned lineno_checksum, unsigned cfg_checksum)
   gcov_write_string (IDENTIFIER_POINTER
                     (DECL_ASSEMBLER_NAME (current_function_decl)));
   gcov_write_unsigned (DECL_ARTIFICIAL (current_function_decl)
-                      && !DECL_FUNCTION_VERSIONED (current_function_decl));
+                      && !DECL_FUNCTION_VERSIONED (current_function_decl)
+                      && !DECL_LAMBDA_FUNCTION (current_function_decl));
   gcov_write_filename (xloc.file);
   gcov_write_unsigned (xloc.line);
   gcov_write_unsigned (xloc.column);
index fd0fb8a720a3350678ef577c36e506a48d7d8450..53ff0eb0a27d5e13e2bf8b015bf52f0ad3620fc0 100644 (file)
@@ -1,3 +1,9 @@
+2018-10-03  Martin Liska  <mliska@suse.cz>
+
+       PR gcov-profile/86109
+       * parser.c (cp_parser_lambda_declarator_opt):
+       Set DECL_LAMBDA_FUNCTION for lambdas.
+
 2018-10-02  Richard Biener  <rguenther@suse.de>
 
        * name-lookup.c (check_local_shadow): Do not test DECL_FROM_INLINE.
index 6696f174d75565533f796a69c56b25843401a0ef..a17cc3f23f2ece1dd51a4afd47291b9f680a0175 100644 (file)
@@ -10641,6 +10641,7 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)
        DECL_ARTIFICIAL (fco) = 1;
        /* Give the object parameter a different name.  */
        DECL_NAME (DECL_ARGUMENTS (fco)) = closure_identifier;
+       DECL_LAMBDA_FUNCTION (fco) = 1;
       }
     if (template_param_list)
       {
index ce3b03b01a2c11643727e3eeed287aeed48727a1..a888b8ffa4d89e6ca234af8a414e8245c1e5fc3b 100644 (file)
@@ -1,3 +1,8 @@
+2018-10-03  Martin Liska  <mliska@suse.cz>
+
+       PR gcov-profile/86109
+       * g++.dg/gcov/pr86109.C: New test.
+
 2018-10-02  Marc Glisse  <marc.glisse@inria.fr>
 
        * gcc.dg/tree-ssa/muldiv-1.c: New file.
diff --git a/gcc/testsuite/g++.dg/gcov/pr86109.C b/gcc/testsuite/g++.dg/gcov/pr86109.C
new file mode 100644 (file)
index 0000000..9052d2e
--- /dev/null
@@ -0,0 +1,16 @@
+
+/* { dg-options "-fprofile-arcs -ftest-coverage -std=c++11" } */
+/* { dg-do run { target native } } */
+
+int main()
+{
+    auto partially_uncovered_lambda = [](int i) { /* count(1) */
+        if (i > 10) /* count(1) */
+            return 0; /* count(1) */
+        return 1; /* count(#####) */
+    };
+
+    return partially_uncovered_lambda(20); /* count(1) */
+}
+
+/* { dg-final { run-gcov pr86109.C } } */
index dee27f89dec8ebff3bceba5efe5d262f05223760..cd3a2bad08ce5109db3134ce1faad3220fd704ef 100644 (file)
@@ -1789,8 +1789,8 @@ struct GTY(()) tree_function_decl {
   unsigned pure_flag : 1;
   unsigned looping_const_or_pure_flag : 1;
   unsigned has_debug_args_flag : 1;
-  unsigned tm_clone_flag : 1;
   unsigned versioned_function : 1;
+  unsigned lambda_function: 1;
   /* No bits left.  */
 };
 
index 35536f372a300280e000c8f19170c7e9b0c295f4..a0f24b61ef187d21aacd0c62dfd544a299885c02 100644 (file)
@@ -3041,6 +3041,10 @@ extern vec<tree, va_gc> **decl_debug_args_insert (tree);
 #define DECL_CXX_DESTRUCTOR_P(NODE)\
    (FUNCTION_DECL_CHECK (NODE)->decl_with_vis.cxx_destructor)
 
+/* In FUNCTION_DECL, this is set if this function is a lambda function.  */
+#define DECL_LAMBDA_FUNCTION(NODE) \
+  (FUNCTION_DECL_CHECK (NODE)->function_decl.lambda_function)
+
 /* In FUNCTION_DECL that represent an virtual method this is set when
    the method is final.  */
 #define DECL_FINAL_P(NODE)\