From 4d4d76dff362ffa8534a1746bbd33d00208c4d8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Th=C3=A9venoux?= Date: Tue, 12 Sep 2023 16:19:43 +0200 Subject: [PATCH] Allow to skip `Skip_Proof` annotations in `p_is_spark` The property `p_is_spark` can now take a boolean parameter (`include_skip_proof_annotations`, defaults to `True`) to specify whether the `GNATprove` `Skip_Proof` and `Skip_Flow_And_Proof` annotations should be ignored to determine if a subprogram is in SPARK or not. --- ada/ast.py | 4 ++-- .../tests/properties/is_spark/aspect/test.out | 18 +++++++++--------- .../tests/properties/is_spark/aspect/test.py | 4 ++-- .../is_spark/configuration_pragma_1/test.out | 10 +++++++++- .../is_spark/configuration_pragma_1/test.py | 12 ++++++++++-- .../is_spark/configuration_pragma_2/test.out | 2 +- .../is_spark/configuration_pragma_2/test.py | 4 ++-- .../is_spark/configuration_pragma_3/test.out | 2 +- .../is_spark/configuration_pragma_3/test.py | 4 ++-- .../is_spark/configuration_pragma_4/test.out | 2 +- .../is_spark/configuration_pragma_4/test.py | 4 ++-- .../is_spark/mixed_pragma_and_aspect/test.out | 18 +++++++++--------- .../is_spark/mixed_pragma_and_aspect/test.py | 4 ++-- .../is_spark/pkg_private_and_body/test.out | 12 ++++++------ .../is_spark/pkg_private_and_body/test.py | 4 ++-- .../tests/properties/is_spark/pragma/test.out | 18 +++++++++--------- .../tests/properties/is_spark/pragma/test.py | 4 ++-- .../is_spark/skip_flow_and_proof/test.out | 2 +- .../is_spark/skip_flow_and_proof/test.py | 4 ++-- .../properties/is_spark/skip_proof/test.out | 6 +++--- .../properties/is_spark/skip_proof/test.py | 4 ++-- user_manual/changes/libadalang/1074.yaml | 9 +++++++++ 22 files changed, 88 insertions(+), 63 deletions(-) create mode 100644 user_manual/changes/libadalang/1074.yaml diff --git a/ada/ast.py b/ada/ast.py index 56b9ab3dd..c6361dddf 100644 --- a/ada/ast.py +++ b/ada/ast.py @@ -20696,7 +20696,7 @@ def gnatprove_annotations(): return annotations.concat(pragmas).concat(enclosing_subp_annotations) @langkit_property(public=True, return_type=Bool, memoized=True) - def is_spark(): + def is_spark(include_skip_proof_annotations=(T.Bool, True)): """ Return whether this subprogram body is in SPARK or not, i.e. return whether SPARK proofs will be applied to that subprogram or not. @@ -20704,7 +20704,7 @@ def is_spark(): return Cond( # If `Skip_Proof` or `Skip_Flow_And_Proof` has been specified, this # is not in SPARK. - Not( + include_skip_proof_annotations & Not( Entity.gnatprove_annotations.find( lambda a: a.cast(Name).name_symbol.any_of( 'Skip_Proof', 'Skip_Flow_And_Proof' diff --git a/testsuite/tests/properties/is_spark/aspect/test.out b/testsuite/tests/properties/is_spark/aspect/test.out index f9e5b68ff..29fe72dfc 100644 --- a/testsuite/tests/properties/is_spark/aspect/test.out +++ b/testsuite/tests/properties/is_spark/aspect/test.out @@ -1,35 +1,35 @@ -=== Analysing unit: """ +=== Analysing unit: === Subprogram is skipped Subprogram is skipped -=== Analysing unit: """ +=== Analysing unit: === Subprogram is skipped Subprogram is skipped -=== Analysing unit: """ +=== Analysing unit: === Subprogram is skipped Subprogram is skipped -=== Analysing unit: """ +=== Analysing unit: === Subprogram is skipped -=== Analysing unit: """ +=== Analysing unit: === Subprogram is skipped Subprogram is skipped -=== Analysing unit: """ +=== Analysing unit: === Subprogram is analyzed -=== Analysing unit: """ +=== Analysing unit: === Subprogram is analyzed Subprogram is skipped -=== Analysing unit: """ +=== Analysing unit: === Subprogram is analyzed Subprogram is skipped Subprogram is analyzed -=== Analysing unit: """ +=== Analysing unit: === Subprogram is skipped Subprogram is skipped Subprogram is skipped diff --git a/testsuite/tests/properties/is_spark/aspect/test.py b/testsuite/tests/properties/is_spark/aspect/test.py index b12ee3de2..b2c577b35 100644 --- a/testsuite/tests/properties/is_spark/aspect/test.py +++ b/testsuite/tests/properties/is_spark/aspect/test.py @@ -13,10 +13,10 @@ unit = context.get_from_file(filename) subprograms = unit.root.findall(lal.BaseSubpBody) if subprograms: - print('=== Analysing unit: ', unit, '"""') + print('=== Analysing unit: ', unit, '===') for subprogram in subprograms: print("Subprogram {} is {}".format( subprogram, - "analyzed" if subprogram.p_is_spark else "skipped" + "analyzed" if subprogram.p_is_spark() else "skipped" )) print('') diff --git a/testsuite/tests/properties/is_spark/configuration_pragma_1/test.out b/testsuite/tests/properties/is_spark/configuration_pragma_1/test.out index 1e21a345a..135d885a8 100644 --- a/testsuite/tests/properties/is_spark/configuration_pragma_1/test.out +++ b/testsuite/tests/properties/is_spark/configuration_pragma_1/test.out @@ -1,4 +1,4 @@ -=== Analysing unit: """ +=== Analysing unit: === Subprogram is analyzed Subprogram is analyzed Subprogram is skipped @@ -6,3 +6,11 @@ Subprogram is skipped Subprogram is skipped Subprogram is analyzed +=== Re-analysing unit (ignoring Skip_Proof annotations): === +Subprogram is analyzed +Subprogram is analyzed +Subprogram is analyzed +Subprogram is analyzed +Subprogram is skipped +Subprogram is analyzed + diff --git a/testsuite/tests/properties/is_spark/configuration_pragma_1/test.py b/testsuite/tests/properties/is_spark/configuration_pragma_1/test.py index c885577de..700152bf3 100644 --- a/testsuite/tests/properties/is_spark/configuration_pragma_1/test.py +++ b/testsuite/tests/properties/is_spark/configuration_pragma_1/test.py @@ -13,10 +13,18 @@ unit = context.get_from_file(filename) subprograms = unit.root.findall(lal.BaseSubpBody) if subprograms: - print('=== Analysing unit: ', unit, '"""') + print('=== Analysing unit: ', unit, '===') for subprogram in subprograms: print("Subprogram {} is {}".format( subprogram, - "analyzed" if subprogram.p_is_spark else "skipped" + "analyzed" if subprogram.p_is_spark() else "skipped" + )) + print('') + print('=== Re-analysing unit (ignoring Skip_Proof annotations): ', + unit, '===') + for subprogram in subprograms: + print("Subprogram {} is {}".format( + subprogram, + "analyzed" if subprogram.p_is_spark(False) else "skipped" )) print('') diff --git a/testsuite/tests/properties/is_spark/configuration_pragma_2/test.out b/testsuite/tests/properties/is_spark/configuration_pragma_2/test.out index 8ac5dbf8e..65c9dbe8b 100644 --- a/testsuite/tests/properties/is_spark/configuration_pragma_2/test.out +++ b/testsuite/tests/properties/is_spark/configuration_pragma_2/test.out @@ -1,4 +1,4 @@ -=== Analysing unit: """ +=== Analysing unit: === Subprogram is skipped Subprogram is skipped Subprogram is skipped diff --git a/testsuite/tests/properties/is_spark/configuration_pragma_2/test.py b/testsuite/tests/properties/is_spark/configuration_pragma_2/test.py index c885577de..5c641fcbf 100644 --- a/testsuite/tests/properties/is_spark/configuration_pragma_2/test.py +++ b/testsuite/tests/properties/is_spark/configuration_pragma_2/test.py @@ -13,10 +13,10 @@ unit = context.get_from_file(filename) subprograms = unit.root.findall(lal.BaseSubpBody) if subprograms: - print('=== Analysing unit: ', unit, '"""') + print('=== Analysing unit: ', unit, '===') for subprogram in subprograms: print("Subprogram {} is {}".format( subprogram, - "analyzed" if subprogram.p_is_spark else "skipped" + "analyzed" if subprogram.p_is_spark() else "skipped" )) print('') diff --git a/testsuite/tests/properties/is_spark/configuration_pragma_3/test.out b/testsuite/tests/properties/is_spark/configuration_pragma_3/test.out index 58152ab61..961191622 100644 --- a/testsuite/tests/properties/is_spark/configuration_pragma_3/test.out +++ b/testsuite/tests/properties/is_spark/configuration_pragma_3/test.out @@ -1,4 +1,4 @@ -=== Analysing unit: """ +=== Analysing unit: === Subprogram is skipped Subprogram is skipped Subprogram is skipped diff --git a/testsuite/tests/properties/is_spark/configuration_pragma_3/test.py b/testsuite/tests/properties/is_spark/configuration_pragma_3/test.py index c885577de..5c641fcbf 100644 --- a/testsuite/tests/properties/is_spark/configuration_pragma_3/test.py +++ b/testsuite/tests/properties/is_spark/configuration_pragma_3/test.py @@ -13,10 +13,10 @@ unit = context.get_from_file(filename) subprograms = unit.root.findall(lal.BaseSubpBody) if subprograms: - print('=== Analysing unit: ', unit, '"""') + print('=== Analysing unit: ', unit, '===') for subprogram in subprograms: print("Subprogram {} is {}".format( subprogram, - "analyzed" if subprogram.p_is_spark else "skipped" + "analyzed" if subprogram.p_is_spark() else "skipped" )) print('') diff --git a/testsuite/tests/properties/is_spark/configuration_pragma_4/test.out b/testsuite/tests/properties/is_spark/configuration_pragma_4/test.out index 4f1a43b0e..72ba90a49 100644 --- a/testsuite/tests/properties/is_spark/configuration_pragma_4/test.out +++ b/testsuite/tests/properties/is_spark/configuration_pragma_4/test.out @@ -1,4 +1,4 @@ -=== Analysing unit: """ +=== Analysing unit: === Subprogram is skipped Subprogram is skipped Subprogram is skipped diff --git a/testsuite/tests/properties/is_spark/configuration_pragma_4/test.py b/testsuite/tests/properties/is_spark/configuration_pragma_4/test.py index b12ee3de2..b2c577b35 100644 --- a/testsuite/tests/properties/is_spark/configuration_pragma_4/test.py +++ b/testsuite/tests/properties/is_spark/configuration_pragma_4/test.py @@ -13,10 +13,10 @@ unit = context.get_from_file(filename) subprograms = unit.root.findall(lal.BaseSubpBody) if subprograms: - print('=== Analysing unit: ', unit, '"""') + print('=== Analysing unit: ', unit, '===') for subprogram in subprograms: print("Subprogram {} is {}".format( subprogram, - "analyzed" if subprogram.p_is_spark else "skipped" + "analyzed" if subprogram.p_is_spark() else "skipped" )) print('') diff --git a/testsuite/tests/properties/is_spark/mixed_pragma_and_aspect/test.out b/testsuite/tests/properties/is_spark/mixed_pragma_and_aspect/test.out index 3786370b5..5d4ee164b 100644 --- a/testsuite/tests/properties/is_spark/mixed_pragma_and_aspect/test.out +++ b/testsuite/tests/properties/is_spark/mixed_pragma_and_aspect/test.out @@ -1,35 +1,35 @@ -=== Analysing unit: """ +=== Analysing unit: === Subprogram is skipped Subprogram is skipped -=== Analysing unit: """ +=== Analysing unit: === Subprogram is skipped Subprogram is skipped -=== Analysing unit: """ +=== Analysing unit: === Subprogram is skipped Subprogram is skipped -=== Analysing unit: """ +=== Analysing unit: === Subprogram is skipped -=== Analysing unit: """ +=== Analysing unit: === Subprogram is skipped Subprogram is skipped -=== Analysing unit: """ +=== Analysing unit: === Subprogram is analyzed -=== Analysing unit: """ +=== Analysing unit: === Subprogram is analyzed Subprogram is skipped -=== Analysing unit: """ +=== Analysing unit: === Subprogram is analyzed Subprogram is skipped Subprogram is analyzed -=== Analysing unit: """ +=== Analysing unit: === Subprogram is skipped Subprogram is skipped Subprogram is skipped diff --git a/testsuite/tests/properties/is_spark/mixed_pragma_and_aspect/test.py b/testsuite/tests/properties/is_spark/mixed_pragma_and_aspect/test.py index b12ee3de2..b2c577b35 100644 --- a/testsuite/tests/properties/is_spark/mixed_pragma_and_aspect/test.py +++ b/testsuite/tests/properties/is_spark/mixed_pragma_and_aspect/test.py @@ -13,10 +13,10 @@ unit = context.get_from_file(filename) subprograms = unit.root.findall(lal.BaseSubpBody) if subprograms: - print('=== Analysing unit: ', unit, '"""') + print('=== Analysing unit: ', unit, '===') for subprogram in subprograms: print("Subprogram {} is {}".format( subprogram, - "analyzed" if subprogram.p_is_spark else "skipped" + "analyzed" if subprogram.p_is_spark() else "skipped" )) print('') diff --git a/testsuite/tests/properties/is_spark/pkg_private_and_body/test.out b/testsuite/tests/properties/is_spark/pkg_private_and_body/test.out index 91c808834..dab2fd66f 100644 --- a/testsuite/tests/properties/is_spark/pkg_private_and_body/test.out +++ b/testsuite/tests/properties/is_spark/pkg_private_and_body/test.out @@ -1,24 +1,24 @@ -=== Analysing unit: """ +=== Analysing unit: === Subprogram is skipped Subprogram is analyzed Subprogram is skipped -=== Analysing unit: """ +=== Analysing unit: === Subprogram is analyzed -=== Analysing unit: """ +=== Analysing unit: === Subprogram is analyzed Subprogram is skipped Subprogram is skipped Subprogram is skipped -=== Analysing unit: """ +=== Analysing unit: === Subprogram is analyzed Subprogram is skipped Subprogram is skipped Subprogram is skipped -=== Analysing unit: """ +=== Analysing unit: === Subprogram is analyzed Subprogram is analyzed Subprogram is skipped @@ -28,6 +28,6 @@ Subprogram is analyzed Subprogram is analyzed Subprogram is analyzed -=== Analysing unit: """ +=== Analysing unit: === Subprogram is analyzed diff --git a/testsuite/tests/properties/is_spark/pkg_private_and_body/test.py b/testsuite/tests/properties/is_spark/pkg_private_and_body/test.py index e8af6933b..6a8f9bdfa 100644 --- a/testsuite/tests/properties/is_spark/pkg_private_and_body/test.py +++ b/testsuite/tests/properties/is_spark/pkg_private_and_body/test.py @@ -12,10 +12,10 @@ unit = context.get_from_file(filename) subprograms = unit.root.findall(lal.BaseSubpBody) if subprograms: - print('=== Analysing unit: ', unit, '"""') + print('=== Analysing unit: ', unit, '===') for subprogram in subprograms: print("Subprogram {} is {}".format( subprogram, - "analyzed" if subprogram.p_is_spark else "skipped" + "analyzed" if subprogram.p_is_spark() else "skipped" )) print('') diff --git a/testsuite/tests/properties/is_spark/pragma/test.out b/testsuite/tests/properties/is_spark/pragma/test.out index 61a16f501..d1ec1d7b4 100644 --- a/testsuite/tests/properties/is_spark/pragma/test.out +++ b/testsuite/tests/properties/is_spark/pragma/test.out @@ -1,36 +1,36 @@ -=== Analysing unit: """ +=== Analysing unit: === Subprogram is skipped Subprogram is skipped -=== Analysing unit: """ +=== Analysing unit: === Subprogram is skipped Subprogram is skipped -=== Analysing unit: """ +=== Analysing unit: === Subprogram is skipped Subprogram is skipped -=== Analysing unit: """ +=== Analysing unit: === Subprogram is skipped -=== Analysing unit: """ +=== Analysing unit: === Subprogram is skipped Subprogram is skipped -=== Analysing unit: """ +=== Analysing unit: === Subprogram is analyzed -=== Analysing unit: """ +=== Analysing unit: === Subprogram is analyzed Subprogram is skipped Subprogram is skipped -=== Analysing unit: """ +=== Analysing unit: === Subprogram is analyzed Subprogram is skipped Subprogram is analyzed -=== Analysing unit: """ +=== Analysing unit: === Subprogram is skipped Subprogram is skipped Subprogram is skipped diff --git a/testsuite/tests/properties/is_spark/pragma/test.py b/testsuite/tests/properties/is_spark/pragma/test.py index b12ee3de2..b2c577b35 100644 --- a/testsuite/tests/properties/is_spark/pragma/test.py +++ b/testsuite/tests/properties/is_spark/pragma/test.py @@ -13,10 +13,10 @@ unit = context.get_from_file(filename) subprograms = unit.root.findall(lal.BaseSubpBody) if subprograms: - print('=== Analysing unit: ', unit, '"""') + print('=== Analysing unit: ', unit, '===') for subprogram in subprograms: print("Subprogram {} is {}".format( subprogram, - "analyzed" if subprogram.p_is_spark else "skipped" + "analyzed" if subprogram.p_is_spark() else "skipped" )) print('') diff --git a/testsuite/tests/properties/is_spark/skip_flow_and_proof/test.out b/testsuite/tests/properties/is_spark/skip_flow_and_proof/test.out index 11cce2462..f687e2628 100644 --- a/testsuite/tests/properties/is_spark/skip_flow_and_proof/test.out +++ b/testsuite/tests/properties/is_spark/skip_flow_and_proof/test.out @@ -1,4 +1,4 @@ -=== Analysing unit: """ +=== Analysing unit: === Subprogram is skipped Subprogram is skipped Subprogram is skipped diff --git a/testsuite/tests/properties/is_spark/skip_flow_and_proof/test.py b/testsuite/tests/properties/is_spark/skip_flow_and_proof/test.py index b12ee3de2..b2c577b35 100644 --- a/testsuite/tests/properties/is_spark/skip_flow_and_proof/test.py +++ b/testsuite/tests/properties/is_spark/skip_flow_and_proof/test.py @@ -13,10 +13,10 @@ unit = context.get_from_file(filename) subprograms = unit.root.findall(lal.BaseSubpBody) if subprograms: - print('=== Analysing unit: ', unit, '"""') + print('=== Analysing unit: ', unit, '===') for subprogram in subprograms: print("Subprogram {} is {}".format( subprogram, - "analyzed" if subprogram.p_is_spark else "skipped" + "analyzed" if subprogram.p_is_spark() else "skipped" )) print('') diff --git a/testsuite/tests/properties/is_spark/skip_proof/test.out b/testsuite/tests/properties/is_spark/skip_proof/test.out index 3593112a1..95af721f9 100644 --- a/testsuite/tests/properties/is_spark/skip_proof/test.out +++ b/testsuite/tests/properties/is_spark/skip_proof/test.out @@ -1,4 +1,4 @@ -=== Analysing unit: """ +=== Analysing unit: === Subprogram is skipped Subprogram is skipped Subprogram is skipped @@ -21,9 +21,9 @@ Subprogram is skipped Subprogram is skipped Subprogram is skipped -=== Analysing unit: """ +=== Analysing unit: === Subprogram is skipped -=== Analysing unit: """ +=== Analysing unit: === Subprogram is analyzed diff --git a/testsuite/tests/properties/is_spark/skip_proof/test.py b/testsuite/tests/properties/is_spark/skip_proof/test.py index b12ee3de2..b2c577b35 100644 --- a/testsuite/tests/properties/is_spark/skip_proof/test.py +++ b/testsuite/tests/properties/is_spark/skip_proof/test.py @@ -13,10 +13,10 @@ unit = context.get_from_file(filename) subprograms = unit.root.findall(lal.BaseSubpBody) if subprograms: - print('=== Analysing unit: ', unit, '"""') + print('=== Analysing unit: ', unit, '===') for subprogram in subprograms: print("Subprogram {} is {}".format( subprogram, - "analyzed" if subprogram.p_is_spark else "skipped" + "analyzed" if subprogram.p_is_spark() else "skipped" )) print('') diff --git a/user_manual/changes/libadalang/1074.yaml b/user_manual/changes/libadalang/1074.yaml new file mode 100644 index 000000000..aa44a1a35 --- /dev/null +++ b/user_manual/changes/libadalang/1074.yaml @@ -0,0 +1,9 @@ +type: api-change +short_title: Skip annotations in `p_is_spark` +title: Allow to skip `Skip_Proof` annotations in `p_is_spark` +description: | + The property `p_is_spark` can now take a boolean parameter + (`include_skip_proof_annotations`, defaults to `True`) to specify whether the + `GNATprove` `Skip_Proof` and `Skip_Flow_And_Proof` annotations should be + ignored to determine if a subprogram is in SPARK or not. +date: 2023-09-12