Skip to content

Commit

Permalink
Merge branch 'topic/84' into 'master'
Browse files Browse the repository at this point in the history
Fetch gnat-kp impact data from impact-db

See merge request eng/libadalang/langkit-query-language!337
  • Loading branch information
thvnx committed Jan 17, 2025
2 parents 4efe908 + 62200c7 commit 40f2fa9
Show file tree
Hide file tree
Showing 101 changed files with 317 additions and 169 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ PYTHON=python
MAVEN=mvn
BUILD_DIR=/undefined
LKQL_DIR=$(BUILD_DIR)/lkql
IMPACTDB_DIR=/undefined
GPRBUILD=gprbuild -j$(PROCS) -p -XBUILD_MODE=$(BUILD_MODE)
GPRINSTALL=gprinstall --prefix=$(PREFIX) -p -XBUILD_MODE=$(BUILD_MODE)
BUILD_FOR_JIT=false
Expand All @@ -36,6 +37,9 @@ doc: build_lkql_native_jit
cd user_manual && make clean html
cd lkql_checker/doc && make generate html-all

impacts:
PYTHONPATH=$(IMPACTDB_DIR) ./utils/impact-db_impacts_gen.py $(IMPACTDB_DIR)

format:
$(MAVEN) -f lkql_jit spotless:apply

Expand Down
2 changes: 1 addition & 1 deletion lkql_checker/share/lkql/kp/KP-18614.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fun multiple_of(v, multiple) = v / multiple * multiple == v

@check(help="possible occurrence of KP 18614",
message="possible occurrence of KP 18614 if compiled with optimization",
impact="2[0-3].*", target="powerpc*,leon*,sparc*")
target="powerpc*,leon*,sparc*")
fun kp_18614(node) =
node is Aggregate(p_expression_type():
t@BaseTypeDecl(p_is_array_type(): true)
Expand Down
2 changes: 1 addition & 1 deletion lkql_checker/share/lkql/kp/KP-18636.lkql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Flag 'Image applied to objects of a class-wide interface type

@check(message="possible occurrence of KP 18636", impact="22.*,23.*")
@check(message="possible occurrence of KP 18636")
fun kp_18636(node) =
node is AttributeRef
when node.f_attribute.p_name_is("Image")
Expand Down
2 changes: 1 addition & 1 deletion lkql_checker/share/lkql/kp/KP-18637.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import stdlib

@check(message="possible occurrence of KP 18637", impact="23.*")
@check(message="possible occurrence of KP 18637")
fun kp_18637(node) =
node is CallExpr(
f_name: Name(
Expand Down
2 changes: 1 addition & 1 deletion lkql_checker/share/lkql/kp/KP-18701.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import stdlib

@check(message="possible occurrence of KP 18701", impact="23.*")
@check(message="possible occurrence of KP 18701")
fun kp_18701(node) =
node is Aggregate
when node.p_expression_type() is BaseTypeDecl(
Expand Down
3 changes: 1 addition & 2 deletions lkql_checker/share/lkql/kp/KP-18718.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
# variant part

@check(help="possible occurrence of KP 18718",
message="possible occurrence of KP 18718 if compiled with optimization",
impact="23.*")
message="possible occurrence of KP 18718 if compiled with optimization")
fun kp_18718(node) =
node is ObjectDecl(
# An ObjectDecl with a default expression being a function call
Expand Down
3 changes: 1 addition & 2 deletions lkql_checker/share/lkql/kp/KP-18801.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ fun check_params(n) = {
}

@check(help="possible occurrence of KP 18801",
message="possible occurrence of KP 18801",
impact="23.*")
message="possible occurrence of KP 18801")
fun kp_18801(node) =
node is (BinOp(f_op: OpEq) |
CallExpr(p_kind(): "call") when node.f_name.p_name_is("\"=\""))
Expand Down
3 changes: 1 addition & 2 deletions lkql_checker/share/lkql/kp/KP-18926.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ fun is_flagged_aspect(aspect) =
| * => false

@check(help="possible occurrence of KP 18926",
message="possible occurrence of KP 18926",
impact="23.*,24.1")
message="possible occurrence of KP 18926")
fun kp_18926(node) =
node is BracketAggregate
when is_flagged_aspect(node.p_expression_type().p_get_aspect("Aggregate"))
Expand Down
3 changes: 1 addition & 2 deletions lkql_checker/share/lkql/kp/KP-19038.lkql
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@check(help="possible occurrence of KP 19038",
message="possible occurrence of KP 19038",
impact="24.1")
message="possible occurrence of KP 19038")
fun kp_19038(node) =
|" Detect all occurrences of aspect "Exclusive_Functions".
node is AspectAssoc(
Expand Down
3 changes: 1 addition & 2 deletions lkql_checker/share/lkql/kp/KP-19134.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ fun is_unck_conv_to_array_of_int(call) =
}

@check(help="possible occurrence of KP 19134",
message="possible occurrence of KP 19134",
impact="23.*,24.*")
message="possible occurrence of KP 19134")
fun kp_19134(node) =
node is CallExpr(p_is_call(): true)
when stdlib.any([is_unck_conv_to_array_of_int(p.actual)
Expand Down
3 changes: 1 addition & 2 deletions lkql_checker/share/lkql/kp/KP-19142.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ fun is_unconstrained_discriminated(type_decl) =
| * => false

@check(help="possible occurrence of KP 19142",
message="possible occurrence of KP 19142",
impact="24.*")
message="possible occurrence of KP 19142")
fun kp_19142(node) =
node is SubpBody
# Check that the subprogram is overriding
Expand Down
3 changes: 1 addition & 2 deletions lkql_checker/share/lkql/kp/KP-19159.lkql
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import stdlib

@check(help="possible occurrence of KP 19159",
message="possible occurrence of KP 19159",
impact="23.*,24.*")
message="possible occurrence of KP 19159")
fun kp_19159(node) =
|" Look for a value conversion between array types directly
|" passed as an actual parameter in a call to a subprogram.
Expand Down
2 changes: 1 addition & 1 deletion lkql_checker/share/lkql/kp/KP-19198.lkql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@check(help="possible occurrence of KP 19198", message="possible occurrence of KP 19198", impact="24.*")
@check(help="possible occurrence of KP 19198", message="possible occurrence of KP 19198")
fun kp_19198(node) =
|" Flag object declaration which specify the "address" aspect and have a
|" aggregate default value.
Expand Down
3 changes: 1 addition & 2 deletions lkql_checker/share/lkql/kp/KP-19237.lkql
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@check(help="possible occurrence of KP 19237",
message="possible occurrence of KP 19237",
impact="23.*,24.*")
message="possible occurrence of KP 19237")
fun kp_19237(node) =
|" Search for indirect calls to functions returning limited tagged objects.
node is CallExpr(
Expand Down
3 changes: 1 addition & 2 deletions lkql_checker/share/lkql/kp/KP-19279.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ fun contains_dynamic_bounds(agg) =
)

@check(help="possible occurrence of KP 19279",
message="possible occurrence of KP 19279",
impact="23.*,24.*")
message="possible occurrence of KP 19279")
fun kp_19279(node) =
|" Flag object intialization / assignment where the assigned expression is a
|" multi-dimention array aggregate with one of the sub-aggregate having
Expand Down
3 changes: 1 addition & 2 deletions lkql_checker/share/lkql/kp/KP-19312.lkql
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@check(help="possible occurrence of KP 19312",
message="possible occurrence of KP 19312",
impact="24.*")
message="possible occurrence of KP 19312")
fun kp_19312(node) =
|" Flag "for" loop specs which define an iteration filter and which iterate
|" over a type which defines the "iterable" aspect.
Expand Down
3 changes: 1 addition & 2 deletions lkql_checker/share/lkql/kp/KP-19341.lkql
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import stdlib

@check(help="possible occurrence of KP 19341",
message="possible occurrence of KP 19341",
impact="24.*")
message="possible occurrence of KP 19341")
fun kp_19341(node) =
|" Flag all array type declarations that define the 'pack' or
|" the 'component_size' aspect, and which have aliased composite
Expand Down
3 changes: 1 addition & 2 deletions lkql_checker/share/lkql/kp/KP-19423.lkql
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@check(help="possible occurrence of KP 19423",
message="possible occurrence of KP 19423",
impact="22.*,23.*,24.*")
message="possible occurrence of KP 19423")
fun kp_19423(node) =
|" Flag all "for ... in" loops which iterate over expressions of the
|" form "F'Range", where F is a function call.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@check(help="possible occurrence of KP 19447",
message="possible occurrence of KP 19447",
impact="24.*")
message="possible occurrence of KP 19447")
fun kp_19447(node) =
|" To be safe, this KP detector flags all references to the Finalization_Size
|" attribute.
Expand Down
3 changes: 1 addition & 2 deletions lkql_checker/share/lkql/kp/KP-19501.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ fun array_index_has_kp(expr, array_decl, child_n) =
| * => array_index_has_kp(expr, array_decl, child_n + 1)

@check(help="possible occurrence of KP 19501",
message="possible occurrence of KP 19501",
impact="7.1.*,7.2.*,7.3.*,7.4.*,17.*,18.*,19.*,20.*,21.*,22.*,23.*,24.*")
message="possible occurrence of KP 19501")
fun kp_19501(node) =
|" Flag constructions involving an integer valued attribute reference known
|" at compile time, when the attribute reference is:
Expand Down
3 changes: 1 addition & 2 deletions lkql_checker/share/lkql/kp/KP-19529.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ fun is_composite_object(name) =
}

@check(help="possible occurrence of KP 19529",
message="possible occurrence of KP 19529",
impact="24.*")
message="possible occurrence of KP 19529")
fun kp_19529(node) =
|" Flag assign statement between two composite objects that are declared
|" in a subprogram and assigned in a nested sub-program.
Expand Down
2 changes: 1 addition & 1 deletion lkql_checker/share/lkql/kp/KP-OB03-009.lkql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Flag record types with aspect Implicit_Dereference that have an
# access-to-class-wide discriminant.

@check(message="possible occurrence of KP OB03-009", impact="19.*")
@check(message="possible occurrence of KP OB03-009")
fun kp_ob03_009(node) =
# Look for record types with discriminants and Implicit_Dereference aspect
node is TypeDecl(f_discriminants: part@KnownDiscriminantPart,
Expand Down
3 changes: 1 addition & 2 deletions lkql_checker/share/lkql/kp/KP-P226-024.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ fun has_no_local_po_restriction(unit) =
when n.p_name_is("No_Local_Protected_Objects"))

@check(help="possible occurrence of KP P226-024 - global analysis required",
message="possible occurrence of KP P226-024",
impact="7.[123].*,7.4.[1-3].*")
message="possible occurrence of KP P226-024")
fun kp_p226_024(node) =
node is ObjectDecl
when has_no_local_po_restriction(node.p_enclosing_compilation_unit())
Expand Down
2 changes: 1 addition & 1 deletion lkql_checker/share/lkql/kp/KP-Q309-014.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ fun is_untagged_packed_discr(n) =
.p_referenced_decl())
| * => false

@check(message="possible occurrence of KP Q309-014", impact="7.[1-4].*,17.*")
@check(message="possible occurrence of KP Q309-014")
fun kp_q309_014(node) =
node is DerivedTypeDef when is_untagged_packed_discr(node)
3 changes: 1 addition & 2 deletions lkql_checker/share/lkql/kp/KP-Q609-033.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ fun has_no_local_timing_events_restriction(unit) =
when n.p_name_is("No_Local_Timing_Events"))

@check(help="possible occurrence of KP Q609-033 - global analysis required",
message="possible occurrence of KP Q609-033",
impact="7.[123].*,7.4.[1-3].*")
message="possible occurrence of KP Q609-033")
fun kp_q609_033(node) =
node is ObjectDecl
when has_no_local_timing_events_restriction(node.p_enclosing_compilation_unit())
Expand Down
1 change: 0 additions & 1 deletion lkql_checker/share/lkql/kp/KP-QC02-001.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ fun array_with_align(type) =
}

@check(message="possible occurrence of KP QC02-001",
impact="7.[1-4].*,17.*,18.[12]",
follow_generic_instantiations=true)
fun kp_qc02_001(node) =
node is AttributeRef(parent: not AttributeDefClause)
Expand Down
3 changes: 1 addition & 2 deletions lkql_checker/share/lkql/kp/KP-R316-001.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ fun get_type_def(t) =
| SubtypeDecl => get_type_def(t.f_subtype.f_name.p_referenced_decl())
| * => null

@check(message="possible occurrence of KP R316-001",
impact="18.*,19.[1-4],20.[12]")
@check(message="possible occurrence of KP R316-001")
fun kp_r316_001(node) =
node is (ClassicSubpDecl |
BaseSubpBody(p_previous_part(): null) |
Expand Down
2 changes: 1 addition & 1 deletion lkql_checker/share/lkql/kp/KP-R410-028.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fun check_subp(subp) =
when check_type(stdlib.full_root_type(spec.f_subp_returns
.p_designated_type_decl()))

@check(message="possible occurrence of KP R410-028", impact="7.[123].*")
@check(message="possible occurrence of KP R410-028")
fun kp_r410_028(node) =
node is BaseId(
p_is_call(): true,
Expand Down
3 changes: 1 addition & 2 deletions lkql_checker/share/lkql/kp/KP-R511-017.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import stdlib

@check(message="possible occurrence of KP R511-017",
impact="7.[1-4].*,17.*,18.*")
@check(message="possible occurrence of KP R511-017")
fun kp_r511_017(node) =
node is SubtypeDecl(
p_has_aspect("Object_Size"): true,
Expand Down
1 change: 0 additions & 1 deletion lkql_checker/share/lkql/kp/KP-R517-023.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ fun get_type(type) =
| * => type

@check(message="possible occurrence of KP R517-023",
impact="7.[1-4].*,17.*,18.[12]",
follow_generic_instantiations = true)
fun kp_r517_023(node) =
node is CallExpr(p_is_call(): true)
Expand Down
2 changes: 1 addition & 1 deletion lkql_checker/share/lkql/kp/KP-S114-015.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fun primitives(decl) =
| SubtypeDecl => decl.p_get_type().p_get_primitives()
| * => null

@check(message="possible occurrence of KP S124-035", impact="18.*,19.*")
@check(message="possible occurrence of KP S124-035")
fun kp_s114_015(node) =
# Look for variant record types
node is TypeDecl(f_discriminants: not null,
Expand Down
3 changes: 1 addition & 2 deletions lkql_checker/share/lkql/kp/KP-S124-035.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

import stdlib

@check(message="possible occurrence of KP S124-035",
impact="7.[1-4].*,1[7-9].*")
@check(message="possible occurrence of KP S124-035")
fun kp_s124_035(node) =
node is CallExpr(p_is_call(): true)
when node.f_name.p_referenced_decl() is i@GenericSubpInstantiation
Expand Down
2 changes: 1 addition & 1 deletion lkql_checker/share/lkql/kp/KP-S521-014.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import stdlib

@check(message="possible occurrence of KP S521-014", impact="19.*")
@check(message="possible occurrence of KP S521-014")
fun kp_s521_014(node) =
node is TypeDecl(p_is_tagged_type(): true,
f_discriminants: not null,
Expand Down
2 changes: 1 addition & 1 deletion lkql_checker/share/lkql/kp/KP-S621-051.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import stdlib

@check(message="possible occurrence of KP S621-051", impact="19.*")
@check(message="possible occurrence of KP S621-051")
fun kp_s621_051(node) =
node is ParamAssoc(
parent: AssocList(parent: c@CallExpr(
Expand Down
1 change: 0 additions & 1 deletion lkql_checker/share/lkql/kp/KP-S722-023.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ fun is_array_slice(expr) =
| o => false

@check(message="possible occurrence of KP S722-023",
impact="7.[1-4].*,17.*,18.[12],19.[123]",
follow_generic_instantiations=true)
fun kp_s722_023(node) =
node is AttributeRef
Expand Down
2 changes: 1 addition & 1 deletion lkql_checker/share/lkql/kp/KP-S724-042.lkql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Flag extended return statements with a default expression of a type with
# a Default_Initial_Condition aspect.

@check(message="possible occurrence of KP S724-042", impact="19.*,20.1")
@check(message="possible occurrence of KP S724-042")
fun kp_s724_042(node) =
node is ExtendedReturnStmt
when node.f_decl.f_default_expr is Expr
Expand Down
2 changes: 1 addition & 1 deletion lkql_checker/share/lkql/kp/KP-S814-034.lkql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import stdlib

@check(message="possible occurrence of KP S814-034", impact="17.*,18.*,19.*")
@check(message="possible occurrence of KP S814-034")
fun kp_s814_034(node) =
|" Flag array aggregates with an others choice if the array component type is a
|" record type that has a string subcomponent.
Expand Down
2 changes: 1 addition & 1 deletion lkql_checker/share/lkql/kp/KP-T420-033.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import stdlib

@check(message="possible occurrence of KP T420-033", impact="18.*,19.*,20.1")
@check(message="possible occurrence of KP T420-033")
fun kp_t420_033(node) =
node is ComponentDecl
when node.p_semantic_parent() is BaseTypeDecl(p_is_tagged_type(): true)
Expand Down
3 changes: 1 addition & 2 deletions lkql_checker/share/lkql/kp/KP-T528-043.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

import stdlib

@check(message="possible occurrence of KP T528-043",
impact="18.*,19.[1-5],20.[12]")
@check(message="possible occurrence of KP T528-043")
fun kp_t528_043(node) =
node is (ObjectDecl when
node.p_has_aspect("Address") and
Expand Down
2 changes: 1 addition & 1 deletion lkql_checker/share/lkql/kp/KP-T602-028.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fun is_access(attr) =
attr.p_name_is("Unchecked_Access") or
attr.p_name_is("Unrestricted_Access")

@check(message="possible occurrence of KP T602-028", impact="20.*")
@check(message="possible occurrence of KP T602-028")
fun kp_t602_028(node) =
# Look for '*Access
node is AttributeRef
Expand Down
2 changes: 1 addition & 1 deletion lkql_checker/share/lkql/kp/KP-T708-064.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fun has_variant_with_varsize(t) =
p_is_discriminant_constraint(): true))
when has_varsize_comp(s.f_name.p_referenced_decl())]

@check(message="possible occurrence of KP T708-064", impact="20.[12]")
@check(message="possible occurrence of KP T708-064")
fun kp_t708_064(node) =
node is TypeDecl
when node.f_type_def is RecordTypeDef
Expand Down
2 changes: 1 addition & 1 deletion lkql_checker/share/lkql/kp/KP-T805-037.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# default initialization of a component whose type is of a record type with
# discriminants.

@check(message="possible occurrence of KP T805-037", impact="20.[12]")
@check(message="possible occurrence of KP T805-037")
fun kp_t805_037(node) =
node is TypeDecl(
f_discriminants: part@KnownDiscriminantPart,
Expand Down
2 changes: 1 addition & 1 deletion lkql_checker/share/lkql/kp/KP-TA10-002.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import stdlib

@check(message="possible occurrence of KP TA10-002", impact="21.*,22.*,23.1")
@check(message="possible occurrence of KP TA10-002")
fun kp_ta10_002(node) =
node is CondExpr(any parent: ReturnStmt | ExprFunction)
when (from node select first c@BaseId(p_is_call(): true)
Expand Down
Loading

0 comments on commit 40f2fa9

Please sign in to comment.