Commit b5ea9143 by Arnaud Charlet

[multiple changes]

2011-08-03  Eric Botcazou  <ebotcazou@adacore.com>

	* inline.adb: Revert previous change.

2011-08-03  Thomas Quinot  <quinot@adacore.com>

	* sem_cat.adb (Validate_RCI_Subprogram_Declaration): Reject a remote
	subprogram with a limited formal that does not support external
	streaming.

2011-08-03  Yannick Moy  <moy@adacore.com>

	* get_alfa.adb (Get_ALFA): add missing Skip_Spaces at start of
	continuation line
	* lib-xref-alfa.adb (Add_ALFA_File): split removal of scopes that are
	not from current unit in two phases, because it is not possible to
	change the table while iterating over its content.
	* put_alfa.adb (Put_ALFA): reset current file/scope at each new entity

2011-08-03  Sergey Rybin  <rybin@adacore.com>

	* vms_data.ads: Add qualifier for gnatmetric --no-static-loop option
	* gnat_ugn.texi: Update description of complexity metrics (gnatmetric)

From-SVN: r177255
parent 668a19bc
2011-08-03 Thomas Quinot <quinot@adacore.com>
* sem_cat.adb (Validate_RCI_Subprogram_Declaration): Reject a remote
subprogram with a limited formal that does not support external
streaming.
2011-08-03 Yannick Moy <moy@adacore.com>
* get_alfa.adb (Get_ALFA): add missing Skip_Spaces at start of
continuation line
* lib-xref-alfa.adb (Add_ALFA_File): split removal of scopes that are
not from current unit in two phases, because it is not possible to
change the table while iterating over its content.
* put_alfa.adb (Put_ALFA): reset current file/scope at each new entity
2011-08-03 Sergey Rybin <rybin@adacore.com>
* vms_data.ads: Add qualifier for gnatmetric --no-static-loop option
* gnat_ugn.texi: Update description of complexity metrics (gnatmetric)
2011-08-03 Ed Schonberg <schonberg@adacore.com>
* sem_res.adb (Resolve_Op_Concat_Arg): if the argument is an aggregate
......@@ -22,7 +42,6 @@
discriminants.
* sem_type.adb (Disambiguate): an immediately visible operator hides a
user-defined function that is only use-visible.
* inline.adb: init procs are inlineable.
2011-08-03 Robert Dewar <dewar@adacore.com>
......
......@@ -393,6 +393,7 @@ begin
Skip_EOL;
exit when Nextc /= '.';
Skipc;
Skip_Spaces;
end if;
if Nextc = '.' then
......
......@@ -14360,12 +14360,14 @@ McCabe cyclomatic complexity;
McCabe essential complexity;
@item
maximal loop nesting level
maximal loop nesting level;
@item
extra exit points (for subprograms);
@end itemize
@noindent
The McCabe complexity metrics are defined
The McCabe cyclomatic complexity metric is defined
in @url{http://www.mccabe.com/pdf/mccabe-nist235r.pdf}
According to McCabe, both control statements and short-circuit control forms
......@@ -14386,6 +14388,34 @@ cyclomatic complexity, which is the sum of these two values.
@end itemize
@noindent
The origin of cyclomatic complexity metric is the need to estimate the number
of independent paths in the control flow graph that in turn gives the number
of tests needed to satisfy paths coverage testing completeness criterion.
Considered from the testing point of view, a static Ada @code{loop} (that is,
the @code{loop} statement having static subtype in loop parameter
specification) does not add to cyclomatic complexity. By providing
@option{^--no-static-loop^NO_STATIC_LOOP^} option a user
may specify that such loops should not be counted when computing the
cyclomatic complexity metric
The Ada essential complexity metric is a McCabe cyclomatic complexity metric
counted for the code that is reduced by excluding all the pure structural Ada
control statements. An compound statement is considered as a non-structural
if it contains a @code{raise} or @code{return} statement as it subcomponent,
or if it contains a @code{goto} statement that transfers the control outside
the operator. A selective accept statement with @code{terminate} alternative
is considered as non-structural statement. When computing this metric,
@code{exit} statements are treated in the same way as @code{goto}
statements unless @option{^-ne^NO_EXITS_AS_GOTOS^} option is specified.
The Ada essential complexity metric defined here is intended to quantify
the extent to which the software is unstructured. It is adapted from
the McCabe essential complexity metric defined in
http://www.mccabe.com/pdf/nist235r.pdf but is modified to be more
suitable for typical Ada usage. For example, short circuit forms
are not penalized as unstructured in the Ada essential complexity metric.
When computing cyclomatic and essential complexity, @command{gnatmetric} skips
the code in the exception handlers and in all the nested program units.
......@@ -14439,6 +14469,10 @@ bodies, task bodies, entry bodies and statement sequences in package bodies
Do not consider @code{exit} statements as @code{goto}s when
computing Essential Complexity
@cindex @option{^--no-static-loop^/NO_STATIC_LOOP^} (@command{gnatmetric})
@item ^--no-static-loop^/NO_STATIC_LOOP^
Do not consider static loops when computing cyclomatic complexity
@item ^--extra-exit-points^/EXTRA_EXIT_POINTS^
Report the extra exit points for subprogram bodies. As an exit point, this
metric counts @code{return} statements and raise statements in case when the
......
......@@ -349,12 +349,6 @@ package body Inline is
Set_Is_Inlined (Pack);
Inlined_Bodies.Increment_Last;
Inlined_Bodies.Table (Inlined_Bodies.Last) := Pack;
-- an initialization procedure should be inlined, but it does
-- not require the body of the package.
elsif Is_Init_Proc (E) then
Set_Is_Inlined (Pack);
end if;
end if;
end;
......
......@@ -224,25 +224,47 @@ package body ALFA is
-- Update scope numbers
for S in From .. ALFA_Scope_Table.Last loop
declare
E : Entity_Id renames ALFA_Scope_Table.Table (S).Scope_Entity;
begin
if Lib.Get_Source_Unit (E) = U then
ALFA_Scope_Table.Table (S).Scope_Num := Int (S - From) + 1;
ALFA_Scope_Table.Table (S).File_Num := D;
declare
Count : Nat;
else
-- Remove scope S which is not located in unit U, for example
-- for scope inside generics that get instantiated.
begin
Count := 1;
for S in From .. ALFA_Scope_Table.Last loop
declare
E : Entity_Id renames ALFA_Scope_Table.Table (S).Scope_Entity;
begin
if Lib.Get_Source_Unit (E) = U then
ALFA_Scope_Table.Table (S).Scope_Num := Count;
ALFA_Scope_Table.Table (S).File_Num := D;
Count := Count + 1;
for J in S .. ALFA_Scope_Table.Last - 1 loop
ALFA_Scope_Table.Table (J) := ALFA_Scope_Table.Table (J + 1);
end loop;
ALFA_Scope_Table.Set_Last (ALFA_Scope_Table.Last - 1);
else
-- Mark for removal a scope S which is not located in unit
-- U, for example for scope inside generics that get
-- instantiated.
ALFA_Scope_Table.Table (S).Scope_Num := 0;
end if;
end;
end loop;
end;
declare
Snew : Scope_Index;
begin
Snew := From;
for S in From .. ALFA_Scope_Table.Last loop
-- Remove those scopes previously marked for removal
if ALFA_Scope_Table.Table (S).Scope_Num /= 0 then
ALFA_Scope_Table.Table (Snew) := ALFA_Scope_Table.Table (S);
Snew := Snew + 1;
end if;
end;
end loop;
end loop;
ALFA_Scope_Table.Set_Last (Snew - 1);
end;
-- Make entry for new file in file table
......
......@@ -141,8 +141,6 @@ begin
Write_Info_Char (S.Scope_Name (N));
end loop;
File := F.File_Num;
Scope := S.Scope_Num;
Entity_Line := 0;
Entity_Col := 0;
......@@ -175,6 +173,8 @@ begin
Entity_Line := R.Entity_Line;
Entity_Col := R.Entity_Col;
File := F.File_Num;
Scope := S.Scope_Num;
end if;
if Write_Info_Col > 72 then
......
......@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 1996-2010, Free Software Foundation, Inc. --
-- Copyright (C) 1996-2011, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -5456,6 +5456,14 @@ package VMS_Data is
-- Do not count EXIT statements as GOTOs when computing the Essential
-- Complexity.
S_Metric_No_Static_Loop : aliased constant S := "/NO_STATIC_LOOP " &
"--no-static-loop";
-- /STATIC_LOOP (D)
-- /NO_STATIC_LOOP
--
-- Do not count static FOR loop statements when computing the Cyclomatic
-- Complexity.
S_Metric_Mess : aliased constant S := "/MESSAGES_PROJECT_FILE=" &
"DEFAULT " &
"-vP0 " &
......@@ -5554,6 +5562,7 @@ package VMS_Data is
S_Metric_Mess 'Access,
S_Metric_No_Exits_As_Gotos'Access,
S_Metric_No_Local 'Access,
S_Metric_No_Static_Loop 'Access,
S_Metric_Project 'Access,
S_Metric_Quiet 'Access,
S_Metric_Suffix 'Access,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment