From: Arnaud Charlet <charlet@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Thomas Quinot <quinot@adacore.com>
Subject: [Ada] Coverage analysis of select statements
Date: Mon, 16 Jul 2012 13:04:00 -0000 [thread overview]
Message-ID: <20120716130421.GA32181@adacore.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 884 bytes --]
This change introduces generation of a null statement in alternatives
appearing in various forms of select statement, when they do not have
trailing statements. The purpose of the additional null statement is
to allow a nop to be generated with an appropriate source location indication
in debug information, for coverage analysis purposes.
Tested on x86_64-pc-linux-gnu, committed on trunk
2012-07-16 Thomas Quinot <quinot@adacore.com>
* exp_ch9.adb (Ensure_Statement_Present): New subprogram.
(Expand_N_Asynchronous_Select,
Expand_N_Selective_Accept.Process_Accept_Alternative,
Expand_N_Selective_Accept.Process_Delay_Alternative,
Expand_N_Timed_Entry_Call): For an alternative with no trailing
statements, introduce a null statement to carry the sloc of
the initial special statement (accept, delay, or entry call)
in the alternative, for coverage analysis purposes.
[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 4113 bytes --]
Index: exp_ch9.adb
===================================================================
--- exp_ch9.adb (revision 189534)
+++ exp_ch9.adb (revision 189535)
@@ -339,6 +339,17 @@
-- step of the expansion must to be done after private data has been moved
-- to its final resting scope to ensure proper visibility of debug objects.
+ procedure Ensure_Statement_Present (Loc : Source_Ptr; Alt : Node_Id);
+ -- If control flow optimizations are suppressed, and Alt is an accept,
+ -- delay, or entry call alternative with no trailing statements, insert a
+ -- null trailing statement with the given Loc (which is the sloc of the
+ -- accept, delay, or entry call statement). There might not be any
+ -- generated code for the accept, delay, or entry call itself (the
+ -- effect of these statements is part of the general processsing done
+ -- for the enclosing selective accept, timed entry call, or asynchronous
+ -- select), and the null statement is there to carry the sloc of that
+ -- statement to the back-end for trace-based coverage analysis purposes.
+
procedure Extract_Dispatching_Call
(N : Node_Id;
Call_Ent : out Entity_Id;
@@ -5468,6 +5479,19 @@
end loop;
end Debug_Private_Data_Declarations;
+ ------------------------------
+ -- Ensure_Statement_Present --
+ ------------------------------
+
+ procedure Ensure_Statement_Present (Loc : Source_Ptr; Alt : Node_Id) is
+ begin
+ if Opt.Suppress_Control_Flow_Optimizations
+ and then Is_Empty_List (Statements (Alt))
+ then
+ Set_Statements (Alt, New_List (Make_Null_Statement (Loc)));
+ end if;
+ end Ensure_Statement_Present;
+
----------------------------
-- Entry_Index_Expression --
----------------------------
@@ -6587,7 +6611,7 @@
Abortable_Block : Node_Id;
Actuals : List_Id;
Astats : List_Id;
- Blk_Ent : Entity_Id;
+ Blk_Ent : constant Entity_Id := Make_Temporary (Loc, 'A');
Blk_Typ : Entity_Id;
Call : Node_Id;
Call_Ent : Entity_Id;
@@ -6632,15 +6656,16 @@
Process_Statements_For_Controlled_Objects (Trig);
Process_Statements_For_Controlled_Objects (Abrt);
+ Ecall := Triggering_Statement (Trig);
+
+ Ensure_Statement_Present (Sloc (Ecall), Trig);
+
-- Retrieve Astats and Tstats now because the finalization machinery may
-- wrap them in blocks.
Astats := Statements (Abrt);
Tstats := Statements (Trig);
- Blk_Ent := Make_Temporary (Loc, 'A');
- Ecall := Triggering_Statement (Trig);
-
-- The arguments in the call may require dynamic allocation, and the
-- call statement may have been transformed into a block. The block
-- may contain additional declarations for internal entities, and the
@@ -10301,6 +10326,8 @@
Alt_Stats := New_List;
end if;
+ Ensure_Statement_Present (Sloc (Astmt), Alt);
+
-- After the call, if any, branch to trailing statements, if any.
-- We create a label for each, as well as the corresponding label
-- declaration.
@@ -10330,6 +10357,7 @@
-------------------------------
procedure Process_Delay_Alternative (Alt : Node_Id; Index : Int) is
+ Dloc : constant Source_Ptr := Sloc (Delay_Statement (Alt));
Choices : List_Id;
Cond : Node_Id;
Delay_Alt : List_Id;
@@ -10433,6 +10461,8 @@
Append_List (Delay_Alt, Delay_List);
+ Ensure_Statement_Present (Dloc, Alt);
+
-- If the delay alternative has a statement part, add choice to the
-- case statements for delays.
@@ -11884,6 +11914,8 @@
Process_Statements_For_Controlled_Objects (E_Alt);
Process_Statements_For_Controlled_Objects (D_Alt);
+ Ensure_Statement_Present (Sloc (D_Stat), D_Alt);
+
-- Retrieve E_Stats and D_Stats now because the finalization machinery
-- may wrap them in blocks.
reply other threads:[~2012-07-16 13:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120716130421.GA32181@adacore.com \
--to=charlet@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=quinot@adacore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).