10. Libadalang API breaking changes

10.1. New with_self argument to the parents node method

What used to be nodes’ parents property is now a method, which takes an optional with_self boolean argument. Uses of that property (.parents) must now be updated to use the call syntax (.parents()).


10.2. Consolidate meaning of RefResultKind values

Until now, the meaning of the different RefResultKind values that could be returned by e.g a P_Failsafe_Referenced_Decl query was a bit chaotic. For example, Precise could be returned together with a null node as value. Error would be sometimes returned for queries made on names that were not referenced instead of NoRef. This change sanitizes the output so that:

  • NoRef is always returned for queries made on names that are not references (e.g. defining names, attribute names) or references to entities that have no declaration (e.g. built-in operators)
  • Error is reserved to cases where Libadalang fails to resolve the name, either because of an internal problem or because of invalid input.
  • Precise is never returned with a null value.

10.3. Use iterators for the p_complete property

Previously, the p_complete property would return its result in an array, which could potentially be huge and cause storage errors. It now returns its result as an iterator.


10.4. Imprecise fallback on navigation properties

From now on, navigation properties (such as p_previous_part, p_body_part & co.) can be invoked in imprecise fallback mode, meaning that an ad-hoc routine will try to carry out the execution if the normal “precise” path fails. This breaks the Python API because adding a boolean parameter imprecise_fallback on those properties means that they must now be called with parentheses all the time.


10.5. Remove Short_Image APIs

For consistency, the functions called Short_Image or short_image are now either renamed or merged with the equivalent Image/image functions.


10.6. Remove Debug_Text APIs

The name of this function was misleading: it had the Debug prefix not because it was “safe for debug” to call it (just like Text, it would crash on a null node), but because it turned the node text into ASCII using escaping for non-ASCII parts of the source, which can be useful for debug or logging. Users should prefer the Image function for debug, which should be familiar to Ada users.

Current uses of Debug_Text can just call Text and transform its Text_Type result into a String using Langkit_Support.Text.Image, which is exactly what Debug_Text did. Or they can of course switch to Image, which is much better for debug/logging.


10.7. Rename Children_With_Trivia and make it return ghost nodes

For extra clarity, the Children_With_Trivia function in Libadalang.Analysis has been renamed Children_And_Trivia. Moreover, its returned array now includes children ghost nodes, so that the result of the Children function is always a subset of the result of the Children_And_Trivia result.


10.8. DefiningName.find_all_refs/calls returns RefResult array

DefiningName.find_all_references/calls returns RefResult array, which contains the information of whether the reference was obtained via precise or imprecise resolution.

Additionally, exceptions shouldn’t be raised as part of the normal control flow of those properties, and a name resolution failure won’t make them stop searching.


10.9. Enhance support for aggregate projects

Unit providers based on projects have been enhanced to better support aggregate projects.

First, the Ada API makes it possible to create multiple unit providers from a single aggregate project so that each unit providers has access to a consistent set of analysis units: see Libadalang.Project_Provider.Create_Project_Unit_Providers. This is useful when you want to analyze an aggregate project that contains alternative implementations of the same unit.

Second, the Ada API no longer provides a direct access to the Project_Unit_Provider type. Since Libadalang.Analysis.Create_Context takes a reference type (Unit_Provider_Reference), exposing the interface derivation is not necessary and just brings confusion.

Third, the C, Python and OCaml APIs now provide the ability to create a project unit provider with a view narrowed to a sub-project (see the project project unit provider constructor argument). If no sub-project is specified, then the constructor fallbacks to the project partition strategy described above: when the loaded project tree contains inconsistent units (i.e. multiple unit providers would be required), an error is raised.


10.10. Unify naming of *primitive_subp* properties

BasicSubpDecl.primitive_subp_of is now named BasicSubpDecl.primitive_subp_types.

BasicSubpDecl.first_primitive_subp_of is now named BasicSubpDecl.primitive_subp_type.


10.11. Change the grammar of AcceptStmt and EntryBody

To simplify the matching of those with an EntryDecl, a new intermediate node, EntryCompletionFormalParams has been added, and contains the spec of entry completion parameters.


10.12. Replace Name.p_referenced_id by Name.p_referenced_defining_name

referenced_defining_name doesn’t take any argument, and uses the result of referenced_decl on self.

Existing calls to self.referenced_id(self.referenced_decl) can just be replaced by self.referenced_defining_name.

Calls to self.referenced_id(other_decl) have no simple remplacement, but are considered non-important.


10.13. Get rid of Name.p_xref

Its behavior is considered non intuitive, and is not properly documented, nor tested.

The workaround is to replace calls to p_xref by the equivalent set of navigation property calls, such as p_previous_part/p_next_part for declarations and bodies.


10.14. Rename BasicDecl.p_is_unit_root into p_is_compilation_unit_root

To be closer to common Ada terminology, and disambiguate between compilation and analysis units.


11. Libadalang API new features

11.1. Introduce P_All_Parts property

This property will return all parts of the given entity. For example, when called on a subprogram, it will return its spec, body stub and body, as long as any of these is defined.


11.2. Name resolution for the Update attribute

This change adds name resolution support for the Update attribute, which was previously completely ignored. This means that associations in the aggregate argument are now fully resolved.


11.3. Raise Precondition_Failure exceptions on null arguments

Subprograms in the Ada API now raise Precondition_Failure exceptions when provided null arguments when that is invalid. Previously, the lack of defensive code to raise an exception let built-in Ada checks raise Constraint_Error execptions, which made it harder for users to distinguish invalid uses of Libadalang from Libadalang bugs.


11.4. Handle renaming clauses in Find_All_* queries

This change adds an optional Through_Renamings parameter to Find_All_References and Find_All_Calls properties, which when set to True will make sure the results of those queries includes references or calls made to entities that rename the original entity (with renaming chains of arbitrary length).


11.5. Improve Zip_With_Params with formal subps

This change improves the behavior of the Zip_With_Params property when invoked on a generic instantiation in which there are formal subprograms with default values (box expression or explicit name), by matching those with the effectively passed subprogram actuals.


11.6. Allow P_Is_Dispatching_Call on UnOp and Binop

This adds support for the P_Is_Dispatching_Call property on unary and binary operation nodes, as those can also be dynamically dispatching calls. There was no way to compute this information easily previously.


11.7. Add a SubtypeDecl.get_type property

This new property returns the type of a given subtype decl.


11.8. Add project file helpers to Libadalang.Helpers

Add Helpers.Load_Project`, ``Helpers.Project_To_Provider, Helpers.List_Sources_From_Project, subprograms to help handling project files in Libadalang applications when needed outside of the context of a command line application based upon Libadalang.Helpers.App.


11.9. Attributes “Model_Small”, “Delta” and “Caller”.

This change adds name resolution support for the Model_Small floating-point attribute, the Delta fixed-point attribute and the Caller entry attribute.


11.10. Resolve object formals of generic subprograms

This change brings navigation support for generic formal objects of generic subprograms, whereas they were previously only supported on generic packages.


11.11. Add is_inherited_primitive property

Given a type and a primitive of this type, this property returns true if the primitive is inherited.

apis:ada, python, ocaml

11.12. Handle the Enum_Val attribute

This adds name resolution support for the Enum_Val attribute, meaning instances should now resolve to the correct expected type.


11.13. Handle Asm_Input/Asm_Output attributes

This adds name resolution support for those two attributes, so that they should now resolve to the correct expected types.


11.14. Resolve references to implicitly derived /=

Until now, references of /= to the subprogram implicitly derived from a user defined = operator would never be resolved, as such subprograms do not exist in the sources. From now on, those will resolve to the user defined = operator.


11.15. New BodyStub.p_syntactic_fully_qualified_name property

The new BodyStub.p_syntactic_fully_qualified_name property allows one to query the name of a body stub purely based on the syntax. Unlike BasicDecl.p_fully_qualified_name, this does not populate lexical environments, and so is more efficient for this restricted use case.


11.16. Static evaluation of string expressions

Add the possibility of evaluating static expressions as strings to the static evaluator.

apis:ada, python, ocaml

11.17. New abstract class CondExpr

We introduce a new abstract base class, CondExpr, from which IfExpr and CaseExpr derive, to map to the Ada Reference Manual notion of conditional expression. It exposes one property, P_Dependent_Expressions, which returns the list of dependent expressions.


11.18. Add Expr.P_Is_Dynamically_Tagged property

We introduce a new property, P_Is_Dynamically_Tagged, which will return whether an expression is dynamically tagged or not.


11.19. Add p_private_part_decl property

The current p_public_part_decl property allows one to retrieve the public declaration of a given constant object declaration from its private view. However, there was no equivalent property for the other way around. This adds the p_private_part_decl property, which can be called on the public declaration of a constant object in order to retrieve its completion in the private part.


11.20. Implement navigation on entries

It is now possible to call p_body_part on an entry declaration to retrieve its body, and likewise to call p_decl_part on an entry body to retrieve its declaration.


11.21. Implement name resolution for Test_Case aspect

Names and types inside a Test_Case aspect, in particular in the right-hand side of the Requires and Ensures associations are now resolved as expected.


11.22. Add xref for stream attributes references

From now on, stream attributes in stream attribute references such as in R'Output (S, X) resolve to the declaration of the subprogram used as override for the corresponding attribute, if it has been set with the appropriate attribute def clause. Otherwise, it still resolves to None, indicating that the attribute has not been overridden.


11.23. Name resolution for task and entry attributes

This adds name resolution support for entry attribute 'Count and task attributes 'Terminated.


11.24. New Origin_Filename and Origin_Charset functions

The Libadalang.Common packages defines two new primitives for Token_Reference. The Origin_Filename function returns the name of the file from which the token was extracted, or an empty string if it comes from a memory buffer. The Origin_Charset function returns the name of the encoding used to decode the source buffer from which the token was extracted, or an empty string if the source buffer was already decoded.


11.25. Expose p_discriminants_list property

This property can be called on any type and will return the list of its discriminants.


11.26. Handle -j0 in the App framework

The App framework (in Libadalang.Helpers) defines a --jobs/-j command-line argument, taking a positive number of jobs to create. This argument nows also accepts zero, to create one job per CPU.


11.27. Add P_Shapes property

This property, when called on the ComponentList of a record definition, will return the list of all possible shapes that a record value of this type can take. Consider the following record definition:

type R (A : Integer; B : Integer) is record
   X : Integer;
   case A is
      when 1 .. 10 =>
         Y_1 : Integer;
         case B is
            when 1 .. 10 =>
               Z_1 : Integer;
            when others => null;
         end case;
      when 11 .. 20 =>
         Y_2 : Integer;
         case B is
            when 1 .. 10 =>
               Z_2 : Integer;
            when others => null;
         end case;
      when others => null;
   end case;
end record;

For this instance, this property will return the following results:

    [X, Y_1, Z_1],
    [X, Y_1],
    [X, Y_2, Z_2],
    [X, Y_2],

11.28. More frequent precise element type in field docs

Up to now, the documentation for node fields that contain list nodes could already include the list of precise types for list elements. For instance, the documentation of the AbortStmt.f_names field, which contains “a list of Names” was:

This field contains a list that itself contains one of the following

* Attribute_Ref

* Call_Expr

* ...

While this precise type information is useful, it was not always present. For instance, the GenericSubpInstantiation.f_params field, which contains AssocList nodes, i.e. lists of BasicAssoc nodes, was lacking a documentation that states that these AssocList nodes actually contain only ParamAssoc nodes. This oversight is now fixed, so this information is now in all documentations, where useful.


11.29. Add failsafe referenced_decl/name properties

Add Name.failsafe_referenced_decl and Name.failsafe_referenced_def_name properties. Those properties act like their non failsafe counterpart, except that they’ll never raise an exception, and they will track in the result whether it was found through precise or imprecise resolution.

Note that for most purposes, those are purely better version of referenced_decl` and referenced_defining_name, should be used in priority, and might replace those in a future version of LAL.


11.30. Handle others designator in zip_with_params

So far, zip_with_params would completely leave out the others designator in an assoc list, not providing any binding for it in the resulting array. Now, it will return one additional binding per unmatched parameter, from that parameter to the expression associated to others.


11.31. Resolve generic formal objects

When analyzing generic code from an instantiation, libadalang’s name resolution mechanism now resolves references to generic formal objects to their actual wrapped in a synthetic object declaration, instead of resolving to the declaration of the formal. Take for example:

    X : Integer;
package Foo_G is
    type T is range 1 .. X;
end Foo_G;

package Foo_10 is new Foo_G (X => 10);
subtype U is Foo_10.T;

By calling P_Designated_Type_Decl on node Foo_10.T, you will reach type T is range 1 .. X. Previously, calling P_Referenced_Decl on X, would return the declaration X : Integer from the generic formal part.

Now, it will instead generate a new object decl which contains the expression of the actual used for X, which would be 10 here, thus allowing users to reflect upon the value used in the instantiation.

Thanks to this, the static expression evaluator can now correctly evaluate static expressions inside generic code that refer to static formal objects. As such, calling P_Eval_As_Int on X taken from above will now correctly yield 10 instead of an error.


11.32. Add p_valid_keywords property

When called on any node, This property will return the list of keywords that are admissible at the location of the node.


This is work in progress. It will return all keywords for now, without looking at the context.


11.33. Add p_is_visible property

This property can be called on a BasicDecl to determine if this declaration is visible from the point of view of a given node.


Only package-level (public or private) declarations are supported for now.


11.34. Preserve casing in fully_qualified_name output

So far, the p_fully_qualified_name would always output the fully qualified name as a string in lower case. This fixes it by reusing the casing of the names that compose the fully qualified name as they appear in the source code.


11.35. Handle membership expr in static evaluator

This adds support for Ada’s membership expression evaluation in libadalang’s static expression evaluator.


11.36. Handle type’s static predicates in nameres

Until now, the name resolution mechanism would not take into account static predicates defined on a type when it should, for example to infer which variant of a record is being initialized by an aggregate, where the case conditions are types with static predicates.


11.37. Resolve task types’ parent interfaces names

Previously, interface names appearing in the parent list of a task type or a protected type would not be resolved at all, which means cross references where not available on those names. This change fixes that.


11.38. Add a root_type property

When called on a base type declaration, this property returns the root of the derivation hierarchy.


11.39. Add p_is_interface_type property

Add a p_is_interface_type property on BaseTypeDecl nodes. It returns whether the given type corresponds to an interface type.


11.40. Add properties for computing unit dependencies

This change adds three new properties that are about computing the set of units upon with a given one depends.

  • P_Withed_Units returns the set of units that are “with”ed by the given unit.
  • P_Imported_Units returns the set of units that are directly imported by the given unit, which the set of “with”ed units along with the parent unit in case it’s a child unit, etc.
  • P_Unit_Dependencies is like P_Imported_Units but includes transitive dependencies, effectively returning the whole closure of units which the given one depends upon.

11.41. Add built-in AdaNode.full_sloc_image

A new built-in method has been added on nodes, full_sloc_image. It will return a GNU conformant source location in the format file:line:column:, to make it easier to build diagnostics from nodes.


11.42. Add node iterator predicate Kind_In

The new Kind_In node predicate in the Libadalang.Iterators API allows one to filter nodes whose kind is in a given range. This makes it easy to look for nodes that derive from an abstract type.

For instance, the following iterator will return all nodes that derive from Basic_Decl:

Find (Root, Kind_In (Ada_Basic_Decl'First, Ada_Basic_Decl'Last));

11.43. Add property p_get_enum_representation_clause

Add the p_get_enum_representation_clause property on BaseTypeDecl, which will return the EnumRepClause associated to the given type if that type designates an enum declaration and such a representation clause exists.


11.44. Add a base_subp_declarations property

When called on a given subprogram, this property returns a list of all subprograms which are overriden by the given subprogram.


11.45. Add Python3 compatibility

The Python binding is now compatible with Python3.


11.46. Introduce BasicSubpDecl.primitive_subp_tagged_type

Introduce a new property, BasicSubpDecl.primitive_subp_tagged_type, that returns the tagged type of which the subprogram is a primitive of, if applicable.


11.47. More helpful error message for As_* node converters

As_* node conversion functions raise a Constraint_Error when the input value does not fit in the output type. The message attached to this exception has been enhanced to contain input/output type information and mention Libadalang, so that it is easier to investigate complex code raising such Constraint_Error exceptions.


11.48. Implement SingleTokNode.canonical_text

Return the text of a single token node, but canonicalized, e.g. case folded and with GNAT brackets encoding decoded.


11.49. Add a Name.is_operator_name property

The new Name.is_operator_name property returns whether a given name designates an operator.


11.50. Add a command line app framework for Ada API

Add a new package Libadalang.Helpers, with a generic package App, that allows users to easily create command line applications with default features such as automatic project handling/scenario variables handling. Learn more in Libadalang’s Ada tutorial, or Ada API doc.


11.51. Add a p_is_array_slice property

Add a p_is_array_slice property, which tells whether the given CallExpr represents an array slice.


11.52. Add several utility properties on BaseTypeDecl

Those properties include several predicates, allowing to transparently query aspects of a type, without caring about it’s syntactic/semantic aspects:

  • p_is_record_type returns whether the type is a record type.
  • p_is_char_type returns whether the type is a Character type.
  • p_is_tagged_type returns whether the type is a tagged type.
  • p_is_enum_type returns whether the type is an enum type.

Also included is p_base_types which will return all the base types of a tagged type.

Note that all those properties take an origin optional parameter, which will be used to determine the view that is available to you on the type. By default, the view is from the node you query.

Some existing properties (p_is_float_type and p_is_fixed_point) now take an origin parameter. That means that, in the Python API at least, you now need to put parentheses when you call them:

# Before:

# After:

11.53. Improved handling of aggregate projects

Until now, project unit providers used to reject all aggregate projects. This is impractical as it is not always possible to load directly aggregated projects. Hence, the goal of this enhancement is to enable Libadalang users to load aggregate projects as long as we can guarantee non-ambiguous resolution of dependencies.

The project unit provider in all APIs now accepts aggregate projects as long as there is only one aggregated project.

Additionally, the project unit provider in the Ada API (Libadalang.Project_Provider) provides two additional constructors (Create_Project_Unit_Provider and Create_Project_Unit_Provider_Reference) which take any project tree (including all aggregate ones) plus one non-aggregate project in that tree. The project provider will then consider only this sub-project to resolve dependencies unambiguously.


11.54. Add a BasicDecl.p_is_formal property

This new property retruns whether a declaration is the nested declaration inside a GenericFormal node.

Given the following Ada code:

   type T is private;
package T is end T;

You’ll get the following output:

>>> u.root.find(lal.TypeDecl).p_is_formal

# GenericFormals are not the nested declaration, so it will return false
>>> u.root.find(lal.GenericFormal).p_is_formal

11.55. Add property BaseTypeDecl.p_discrete_range

Add a property, BaseTypeDecl.p_discrete_range


11.56. Add a BasicDecl.p_is_preelaborable property

This new property returns whether a declaration is preelaborable. See ARM 10.2.1 for more details.


12. Libadalang API bug fixes

12.1. Reparsing of the Standard unit

It is now impossible to reparse Libadalang’s internal analysis unit that is used to implement Ada’s Standard built-in package. It used to be possible to get this unit from name resolution primitives, and then call Get_From_File on it with the Reparse flag set, which would destroy its tree and completely break name resolution for the whole analysis context. This is no longer possible.


12.2. Fix p_has_aspect property on generic decls

This change fixes a bug where p_has_aspect would always return False for aspects defined via aspect associations on generic declarations.


12.3. Fully qualified name in exit statements

This change fixes a bug where libadalang would fail to parse fully qualified names in exit statements.


12.4. Add support for 'Machine_Radix & 'Exponent

This change adds name resolution support for the Machine_Radix and Exponent attributes.


12.5. Fix nameres of CallExprs to predefined operators

This change fixes a bug where resolving a call to a predefined operator made with call expression (as in "and" (A, B)) would not fail.


12.6. Make Next_Sibling and Previous_Sibling work on root nodes

The Next_Sibling and Previous_Sibling properties used to raise a Property_Error exception when called on root nodes. They now just return a null node, and their documentation has been updated to make this explicit.


12.7. Fix navigation of protected bodies

This change fixes a bug where calling P_Decl_Part on a protected body which corresponding declaration was a SingleProtectedDecl would fail.


12.8. Add Long_Long_Long_Integer to standard unit

This change adds the Long_Long_Long_Integer declaration to Libadalang’s standard unit, so that it is available during name resolution. This fixes name resolution failures in the GNAT runtime library.


12.9. Fix P_[Get/Has]_Aspect for the Inline aspect

When called with the Inline aspect, those properties will check for this aspect on all parts of the given entity.


12.10. Fix P_Has_Aspect property for Pre/Post aspects

This change fixes a bug where evaluating this property on a subprogram with a precondition or a postcondition using Pre or Post as argument would crash due to Libadalang trying to evaluate the expression in the contract.


12.11. Add nameres support for more pragmas

This change adds name resolution support for the following pragmas:

- ``Atomic``
- ``Atomic_Components``
- ``No_Return``

12.12. Fix P_Fully_Qualified_Name on GenericSubpInternal

This change fixes a bug where calling the P_Fully_Qualified_Name property on a GenericSubpInternal node would yield a non-sensical result. It will now yield the fully qualified name of the underlying generic declaration.


12.13. Subtypes with inherited user-defined indexing

This change fixes a bug in Libadalang’s name resolution mechanism where user-defined indexing on a type would not be propagated to its subtypes, which in turn would make name resolution fail on expressions involving indexing of an instance of such a subtype.


12.14. Fix p_is_call on qualified subprogram name

This change fixes a bug where a qualified subprogram name could be wrongly tagged as a call, as in the following example:

function Foo (X : Integer) return Integer is
    return Foo.X;  -- `Foo` was wrongly considered a call
end Foo;

12.15. Generic subprograms and primitive_subp_types

This change fixes a bug where calling the primitive_subp_types and similar properties on the subprogram specification of a generic subprogram declaration would crash with a null dereference error. It will now return empty results instead.


12.16. Access types and primitive_subp_types

This change fixes a bug where calling the primitive_subp_types and similar properties on the subprogram specification part of an access to subprogram type declaration would crash with a null dereference error.


12.17. Fix Base_Subp_Declarations on incomplete types

This changes fixes a bug where calling the Base_Subp_Declarations property on a subprogram declared in a package body and defining a primitive over an incomplete type which completion is declared in that same package body would always return an empty list.


12.18. Crash with 'Wide[_Wide]_Value attributes

This change addresses a crash that would systematically occur when trying to resolve expressions containing the 'Wide_Value' or 'Wide_Wide_Value attributes.


12.19. Resolve Machine_Rounding attribute

This change fixes a crash that would occur when trying to resolve expressions containing the Machine_Rounding attribute.


12.20. SubtypeDecl.base_types doesn’t return all base types

When a subtype is of a type that inherit from interfaces, those would not be returned. This is now fixed.


12.21. Propagate use clauses from generic formal part

Previously, use clauses appearing inside the formal part of a generic declaration were not taken into account by Libadalang when resolving names inside the body of the generic. This change fixes that.


12.22. Nameres crash upon Test_Case aspect assoc

This change fixes a crash that would previously occur while trying to resolve names within a Test_Case aspect, in case the arguments were written without a left-hand side designator.


12.23. Invalid object cast with P_Is_Dispatching_Call

Calling the P_Is_Dispatching_Call property could sometimes crash with an Invalid object cast error, which was due to an erroneous assumption made in the implementation of that property. This change fixes it.


12.24. P_Is_Dispatching_Call crash on generic subp calls

This change fixes a crash that could occur when calling the P_Is_Dispatching_Call on a node representing a call to a generic subprogram.


12.25. Fix precedence of fields over subprograms

In the scenario of a tagged record type having a field Foo as well as a method Foo with a profile such that X.Foo could be seen as ambiguous, Ada resolves the ambiguity by always choosing the field access. This was not implemented by Libadalang, meaning it could in such cases resolve to the subprogram instead of the field. This change implements the correct behavior.


12.26. Nameres bug of Identity attribute on tasks

The Identity attribute applied to a task (single task decl or object decl of a task type) should type to Ada.Task_Identification.Task_Id, which this change implements.


12.27. Load implicitly-withed runtime units when needed

Some runtime units such as Ada.Exceptions, Ada.Tags, Ada.Task_Identification, and a few others need to be loaded in order for libadalang to provide correct name resolution on constructs that refer or type to declarations from those units, which was not done beforehand. This change fixes that by loading those units as soon as it’s necessary.


12.28. Fully resolve operator actuals of generic formals

Until now, a fully qualified reference to an operator used as an actual for a generic formal would not be resolved, meaning navigation would fail on the prefix of the qualified name. This change addresses this.


12.29. Fix output of P_Base/Root_Subp_Declarations

Until now, those properties could return several subprogram declarations denoting the same entity (for example its specification and its body), and sometimes even twice the same subprogram specification or body. This change homogenizes the output of those property to prevent duplicate entries. As such, the canonical part of each subprogram is returned, after having removed duplicates.


12.30. CW types and P_Base_Subp_Declarations

The P_Base_Subp_Declarations property could return incorrect results when called on a subprogram which signature involved the classwide type of the tagged type of which the subprogram is a primitive. In such cases, P_Base_Subp_Declarations would always return the singleton list only containing the subprogram on which the property was called.


12.31. Fix GenericSubpInst.subp_spec_or_null

The subp_spec_or_null property would not work correctly on generic subprogram instantiations, and hence some other calls relying on that would also fail, such as is_dispatching_call on a call to a generic subprogram instantiation. This is now fixed.


12.32. Fix parsing of Wide_*Image attributes

Until now, such attributes would be parsed differently that the basic Image attribute. For example, Type'Image (X) would be parsed as a simple AttributeRef node with arguments, whereas Type'Wide_Image (X) would be parsed as a call to Type'Wide_Image. Since we don’t currently support function attributes, this change unifies the representations by making the second case behave like the first one.


12.33. Fix name resolution of Mod attribute

Until now, the Mod attribute would take an incorrect code path during name resolution, which could make some expressions involving it fail to resolve. In particular in expressions where the mod attribute is used as one of the operand of an arithmetic operation.


12.34. Nameres of CallExpr when name is an attribute

Until now, libadalang would fail to resolve most CallExpr expressions when the name of such CallExpr would be an AttributeRef, typically meaning that the CallExpr represents a subscript operation over the array returned by the AttributeRef (as in X'Image (2 .. 3)). This is now correctly handled.


12.35. Fix navigation on child subprograms

Until now, some navigation properties such as p_previous_part would return None when invoked on a child subprogram body defined in the library-level. This will now correctly return its spec, if it exists.


12.36. Fix semantic_parent/parent_basic_decl on EnumSubpSpec

Until now, semantic_parent/parent_basic_decl on EnumSubpSpec would return the parent enum type declaration, rather than the parent enum literal declaration. This is now fixed.


12.37. Nameres bug with error message of raise stmt

Libadalang would sometimes fail to nameres a raise statement/expression that comes with an error message, if the expression for the error message would involve a string concatenation between calls to overloaded functions.


12.38. Bug with qualified expr used as prefix of call

Until now, Libadalang would fail to nameres an expression containing a qualified expression being the prefix of a call. This is now correctly handled.


12.39. Add support for the Enum_Rep attribute

Previously, name resolution would crash when trying to resolve an expression containing the Enum_Rep attribute. This is now fixed, by typing the result of this attribute to universal integer.


12.40. Crash on dotted name with ambiguous suffix

This changes fixes a bug where name resolution could crash when resolving the suffix of a dotted name, if that suffix taken out of context could designate both an access type component of a tagged record type, or a procedure of that same tagged record type. In particular, this bug would trigger when such a dotted name would be used in the context of a comparison with the Null literal.


12.41. Crash on renaming of Ada.Wide_*Text_IO package

This fixes an issue where Libadalang would fail to do any kind of name analysis on a source that would “use” a package renaming an instantiation of the Ada.Wide_Text_IO or Ada.Wide_Wide_Text_IO packages, such as Ada.Integer_Wide_Text_IO.


12.42. Imprecise fallback on suffix of dotted names

Until now, the imprecise fallback of nameres queries such as p_referenced_decl would never behave correctly when called on the suffix of dotted names (e.g. Subprogram in Pkg.Subprogram). The fallback should now provide better results.


12.43. Name resolution for Standard’Max_Integer_Size

This change adds support for the Standard'Max_Integer_Size attribute, as well as the ‘Default_Bit_Order’ in libadalang’s name resolution mechanism.


12.44. Interface primitive visibility and use clause

This fixes a bug where obtaining visibility through a use clause of a primitive for a type T inherited from an interface I would not work.


12.45. Name resolution for float attributes

This change adds name resolution support for new floating-point attributes, such as Copy_Sign, Remainder and Adjacent. It also adds support for the GNAT-specific Invalid_Value attribute.


12.46. Fix P_Is_Defining on dotted defining names

Previously, P_Is_Defining would always return True for the suffix of any dotted name appearing inside a defining name. For example, for the declaration of an unit A.B.C, P_Is_Defining would incorrectly return True on B. Now, only the outermost dotted name and its suffix will be considered defining (here, A.B.C and C).


12.47. Handle library-level use all type clauses

Previously, such clauses appearing at the library-level of a unit would be totally ignored, which could cause name resolution failures on nodes using this construct to gain visibility on a type’s operations, including the case where the clause is used to make direct references to the literals of an enum type. This is now fixed.


12.48. Name resolution robustness of if/case stmts

Previously, the entire name resolution of an if stmt or case stmt would fail whenever any of their alternatives’ resolution would fail. Each alternative is now resolved independently, so that a failing one does not impact the others. Note that this change does not impact resolution of if/case expressions.


12.49. Nameres failure on generic instantiations

Some generic instantiations could previously cause name resolution to crash, in particular when another generic declaration having the same name as one intended to be instantiated would be available to the resolution mechanism. The fix was to specifically filter out those declarations by only keeping those that are visible in the Ada sense.


12.50. Nameres crash on instantiations of Modular_IO

Previously, name resolution would crash when trying to resolve names in a package instantiation whose designated generic package was Modular_IO from Ada.Text_IO. This was because the special handling of child units of Ada.Text_IO was missing a case for the Modular_IO package.


12.51. Nameres call to incomplete types’ primitives

Name resolution could crash when trying to resolve a call to a primitive of a type when a primitive of the same name but defined on a different incomplete type is visible. In that case, the first visible primitive would always be chosen, which is erroneous if a call to the second one was intended.


12.52. Fix name resolution crash on runtime files

Name resolution would crash when trying to analyze the following files from the runtime: a-stzfix.ads a-stzhas.ads a-szfzha.ads. The pattern leading to the crash was identified and was fixed altogether, thus name resolution will not be affected by new occurrences of it.


12.53. Fix Is_Write_Reference for dot calls

Previously, calling the Is_Write_Reference property on the prefix of a dot call would always yield False. This is now fixed, by correctly identifying dot calls and checking that the first paremeter is out/in out.


12.54. Prevent name resolution in Convention aspect

The convention used for an entity, such as C in the Convention => C aspect association was incorrectly resolved to the first visible entity named C. This now behaves correctly, meaning the identifier used as the convention is never resolved to anything.


12.55. Fix name resolution in type contracts

Previously, name resolution could fail in type contracts (inside aspect associations such as Type_Invariant, Predicate, etc.) when references were made to entities defined after the entity on which the contract applies. This now behaves as expected.


12.56. Fix P_Get_Aspect ("unchecked_union")

Previously, calling P_Get_Aspect ("unchecked_union") on a type would always return an empty result, even when a Pragma Unchecked_Union was associated to it.


12.57. Name resolution on separate (X) clause

Previously, libadalang would crash when calling P_Referenced_Decl on X of a separate (X) ... clause. It will now correctly return the entity in which the subunit is rooted.


12.58. Implement name resolution for entry barriers

Previously, entry barriers were not resolved at all, meaning any xref or navigation inside the expression of the barrier would fail. It is now working as expected.


12.59. Name resolution of use at clauses

Implement name resolution of address clauses (for .. use at ..), which were previously not resolved at all.


12.60. Do not consider Subp'Address a call

Previously, the mentionned pattern would be resolved as a call to Subp, meaning that P_Is_Call would return True when invoked on Subp.


12.61. Name resolution for generic renaming decls

Implements name resolution for generic renaming declarations, which were previously not resolved at all. Properties such as P_Referenced_Decl will now work as expected on those.


12.62. Fix zip_with_params on incomplete type decls

This fixes an issue with calling P_Zip_With_Params on an discriminant constraint that constrains the incomplete view of a discriminated type would yield an empty result.


12.63. Fix exception message for invalid conversions in As_* functions

On attempts to run invalid node conversions, such as:

D : constant Subp_Decl := ...;
P : constant Pragma := D.As_Pragma;

The As_* functions used to raise Constraint_Error exceptions with a wrong message:

invalid type conversion from Pragma to SubpDecl

This is now fixed and sends the correct message:

invalid type conversion from SubpDecl to Pragma

12.64. Libadalang.Analysis.*_Text raise a Constraint_Error

When called on null nodes, Libadalang.Analysis.Text and Libadalang.Analysis.Debug_Text raise a Constraint_Error exception. These functions now raise Property_Error exception instead, clearly showing that calling them on null nodes is not valid.


12.65. Inconsistent results of navigation properties

This fixes a bug where navigation properties such as P_Previous_Part, P_Canonical_Part and so on could yield different results across calls on a same Body node retrieved in different ways. This should not happen because the previous part of a node is predetermined and must not depend on the path taken to reach said node.


12.66. Name resolution bug with custom string literals

String literals for custom string types were inaccurately typed and could make name resolution involving such literals imprecise as well.


12.67. Fix name resolution for Access attribute

A bug in the resolution of the Access attribute would trigger resolution failures on valid expressions.


12.68. Name resolution for Storage_Size attribute.

The attribute Storage_Size applied to an access type reference is now correctly recognized and does not trigger a Property_Error anymore.


12.69. Fix name resolution for some attributes

Some expressions involving attributes such as 'First would not be entirely resolved. In particular, when the expression is of the form X.Y'First, X would not be resolved at all.


12.70. Fix type conversion of explicit dereference

This fixes a bug in libadalang’s name resolution mechanism, where we would not check in certain cases that a type was indeed dereferencable before assigning it to the prefix of an explicit dereference.


12.71. Missed child units during find_all_references

Until now, child units defining a subprogram body at the top-level without a corresponding specification unit would be “forgotten” in calls to find_all_references & co. This is now fixed.


12.72. Fix defining name’s navigation queries crash

Previously, any navigation property (next_part, previous_part, etc.) called on a defining name would crash whenever its associated basic decl would not have the requested part. As such, calling p_next_part on the defining name of an abstract subprogram would always crash.


12.73. Fix is_static_decl for array types

Previously, calling is_static_decl on the declaration of an array type would always yield False. This now returns True when all array indices are static.


12.74. Nameres bug for subp defined in a declare block

This fixes a bug where libadalang would fail to retrieve the body part of a subprogram declaration made in a declare block.


12.75. Resolve Truncation attribute

The Truncation attribute was not resolved correctly.


12.76. Fix navigation for subps inside of separate pkg

Navigation would previously not work when trying to go to the body of a subprogram declared in a package whose body was separate.


12.77. Fix nameres of quantifier expressions

So far, resolving any name or type inside a quantifier expression could result in a invalid equation for logic resolution error. This is now fixed.


12.78. Zip_with_params bug on variant record access

Until now, zip_with_params would not yield any result when trying to match an actual from a discriminant constraint with the discriminant when the constraint type was an access on the variant record. This is now fixed.


12.79. Make relative_name work on decls with no name

Some declarations (like exception handlers that don’t declare an object) have no defining name. Make sure the relative_name property works correctly on those.


12.80. Resolve formal in discriminant constraint

Libadalang now correctly resolves references to the discriminant inside discriminant constraints, as in:

type R (X : Integer) is null record;
type R_Access is access T;

subtype T is R_Access (X => 12);
--                     ^ This reference is now resolved

12.81. Handle static object renamings.

Previously, LAL would never consider an object renaming a static declaration, even when its renamed entity was static. This fix changes the behavior of p_is_static_decl (and transitively that of p_is_static_expr) to take this case into account, and also updates the static expression evaluator accordingly.


12.82. Missing Numeric_Error declaration from standard

This change adds the missing Numeric_Error exception declaration into Libadalang’s standard package so that it is available in every analysis unit. This fixes bugs where references to Numeric_Error would not be resolved correctly.


12.83. Various bug fixes in name resolution

This fixes various bugs in libadalang’s name resolution mechanism, including:

  • A bug related to the use of a package renaming as an actual for a generic formal package.
  • A bug related to visibility on a generic package’s formals when using a qualified name to access it.
  • A crash when trying to resolve a subprogram renaming a built-in attribute.

12.84. Various bug fixes in name resolution

This fixes various bugs in libadalang’s name resolution mechanism, including:

  • A crash when trying to resolve a formal subprogram’s default value being a built-in attribute reference.
  • A bug where library-level subprogram would not have visibility on the private part of their parent package.

12.85. Resolve range constraints in case constructs.

Until now, Libadalang would not even try to resolve names appearing in a range constraint of a subtype indication used in a case statement or expression. Such constraints should now be correctly resolved.


12.86. Fix visibility issue for binary operators

This change fixes a bug where an operator could previously be considered by libadalang as referring to a declaration appearing after the usage of the operator, which is not legal.


12.87. Fix name resolution of builtin concat operator

Previously, Libadalang would generate too weak constraints when resolving the concatenation operator, which in turn could make its LHS and RHS refer to erroneous entities. This change fixes that.


12.88. Add support for additional SPARK aspects.

This change adds support for the Abstract_State, Refined_State, Refined_Depends and Refined_Global aspects.


12.89. Fix the p_primitive_subp_* properties for subp body specs

Previously, calling one of the p_primitive_subp_* properties (e.g. p_primitive_subp_tagged_type) on the subprogram spec of the body of a subprogram would always yield a null node instead of the expected result.


12.90. Derived type with discriminant constraints

This changes fixes a name resolution failure that would occur on aggregate of a derived type constraining the discriminants of its parent type, as in the following example:

type T (X : Boolean) is record
    case X is
        when True =>
            F : Integer;
        when others =>
    end case;
end record;
type U is new T (True);

V : U := (X => True, F => 42);  -- Libadalang would crash here

Libadalang now correctly handles such patterns.


12.91. Fix name resolution of index constraints.

Consider the following subtype declaration:

type Arr_Type is (Character range <>) of Integer;
subtype Arr_A_E of Arr_Type ('A' .. 'E');

Previously, the literals 'A' and 'E' would be assigned incorrect types because we did not take into account the expected index type (here Character) of the constraint array type.


12.92. Fix name resolution on AttributeDefClause nodes

Libadalang would previously crash when resolving names on AttributeDefClause nodes of the form for X'Address use Y'Address when the System package was not visible from the clause.


12.93. Fix name resolution of binary operations when at least one operand has a universal type

Libadalang would often wrongly assume that both operands of a binary operation have the same type, overlooking the case where one of the operands has an universal type, in which case it can get implicitly converted to the type of the other operand.


12.94. Invalid xref for overloaded enclosing subprogram

This change fixes a bug in the following code pattern:

procedure Foo is null;
procedure Foo (X : Integer) is
    Foo;  -- this used to resolve to the enclosing subprogram
end Foo;

The call to Foo now correctly resolve to the first subprogram declaration.


12.95. Fix P_Base_Subp_Declarations on incomplete types

This change fixes the behavior of the P_Base_Subp_Declarations property when called on a primitive subprogram of an incomplete type which full view is a tagged type with a possible base type. Before this patch, it was not possible to find base declarations of such subprograms because Libadalang would always work from the view of the subprogram, thus missing information about the base type. This change fixes that issue.


12.96. Crash in the P_Doc property

Using the P_Doc property on files that contain carriage return characters trigger assertion failures. This is now fixed, and carriage returns that are the last line characters are now discarded from P_Doc‘s result.


12.97. Fix static evaluator on character literals

The static evaluator was wrongly evaluating a character literal whose type derives Standard.Character.


12.98. Crash when resolving exception renaming clause

Until now, name resolution would crash when attempting to resolve any name appearing on the right-hand side of an exception renaming clause.


12.99. Fix crash on top-level subprogram renamings

Libadalang used to crash when the nameres mechanism encountered an analysis unit containing a single subprogram renaming at the top-level.


12.100. Fix fully_qualified_name for generic decls

Consider the following snippet:

package Foo is
    package Bar is
        X : Integer;
    end Bar;

    package My_Bar is new Bar;
end Foo;

Previously, calling fully_qualified_name on the declaration of X would return Foo.Bar.X no matter how X was retrieved.

With this change, when the declaration of X is reached from an instantiation of Bar (e.g. through My_Bar.X), fully_qualified_name will return the qualified name to that particular instance of X, i.e. Foo.My_Bar.X.


12.101. Exception when calling property via introspection

When calling a property via the Libadalang.Introspection API, if the self parameter was null, it would raise a Constraint_Error exception.


12.102. Memory leak in properties to find-all-references

All calls to the find-all-references properties (p_find_all_references, p_find_all_overrides, p_find_all_calls, p_find_all_derived_types) used to trigger memory leaks. This is now fixed.


12.103. Resolve defaults for generic formal subprograms

Defaults for generic formal subprograms were not correctly resolved, and would cause crashes when trying to find the referenced declaration.

procedure Foo;

    with procedure Bar is Foo;
    --                    ^ Not resolved
package Baz is
end Baz;

12.104. Fix nameres involving generic instantiations with formal objects

In some complex name resolution situations, we would try to resolve a formal object in an instance. That would cause a crash if the formal object was completed by a literal.


12.105. Fix static evaluation of range attributes

Before this fix, static evaluation of range attributes on derived type definitions would not evaluate the constraints on the base type, only the explicit constraints on the derived type, such evaluating the range of type B in the following code would crash:

type A is range 1 .. 10;
type B is new A;

Similarly, subtypes would not be handled at all, so the evaluation of the range of any subtypes would crash.

type A is range 1 .. 10;
subtype B is A;  --  CRASH
subtype B is A range 1 .. 5;  --  CRASH

12.106. Resolution of calls to primitives

So far for calls of the form X.Foo, libadalang would always resolve Foo to the base-most declaration of the subprogram Foo. This is not accurate in case the type of X is statically known to be a child type which provides an override of Foo. After this change, Foo in X.Foo now correctly resolves to the most precise override available of Foo for X.


12.107. Package navigation in presence of homonyms

Before this change, the p_package_previous_part private property would return a wrong result when applied on given package if this package contained a entity with the same name as the package itself. These wrong results would then propagate to common navigation properties such as p_decl_part.


12.109. Fix behavior of BasicDecl.has_aspect

The behavior of the BasicDecl.has_aspect property was invalid when the aspect was non boolean-valued. It is now fixed.


12.110. Crash when resolving ambiguous case stmts

Consider the following code pattern:

function Foo return Integer;
procedure Foo;


case Foo is
    when ... => ...
end case;

Name resolution would crash here while attempting to construct the xref equation for the case statement due to the presence of procedure Foo, which by definition has no return type and therefore would provoke a null dereference. This is now fixed.


12.111. P_syntactic_fully_qualified_name can crash in presence of parsing errors

The p_syntactic_fully_qualified_name property could crash when called on a unit with parsing errors because we didn’t handle the case where its body would be an ErrorDecl. This is now fixed.


12.112. Nameres crash with calls on shadowed types

In case a type was shadowed by an object, resolving a call on that object could crash because the construction of the xref equation would assume the type was a possible target for the call. This was fixed by early discarding types when resolving calls in which the context does not allow a type.


12.113. Find_all_references crash with empty files

Find_all_references could crash if one or several source files in the project was empty. This is because those are parsed as empty lists of compilation units which was unexpected. This is now correctly handled.


12.114. Fix BasicDecl.doc not working on generic packages

The BasicDecl.doc property was not working correctly on generic packages, returning wrong or no documentation.


12.115. Resolution of array slices

So far name resolution would fail on complex array accesses involving slices. That was because those were not taken into account at all in our many parts of our name resolution mechanism. This patch adds support for them in the bottom-up name resolution mechanism.


12.116. Fix doc‘s leading whitespace stripping

The p_doc property previously stripped leading whitespace according to the leading whitespace of the first line, and raised a Property_Error if that caused stripping non whitespace characters on subsequent lines. Now, it takes the least indented line as a reference for stripping.


12.117. Resolution of top-level child generic subp bodies

So far name resolution could fail in certain cases when trying to resolve references inside a top-level generic child subprogram body, in particular those that would refer to names declared in the private part of the parent unit, because the body would not have full visibility on the parent. This change fixes this by adjusting the env spec of generic subp decls to rectify the parent env.


12.118. Duplicates in the output of p_find_all_overrides

The output of the p_find_all_overrides property could in certain cases contain multiple instances of the same override. This change makes sure it does not anymore.


12.119. Resolution of separate generic subprograms

So far name resolution would fail when trying to resolve references to generic parameters in the body of separate generic subprogram. That was because the lexical env containing the generic parameters was not accessible from within the separate. This change fixes this by weakening the condition necessary to add a referenced_env to the generic formal part, which separate bodies now satisfy.


12.120. Resolution of calls to entries of SingleTaskTypeDecl

So far name resolution was failing on calls to an entry defined in a Task declaration (not a task type declaration). This was because SingleTaskTypeDecl would not reimplement the defining_env primitive which we use to retrieve names defined by this type. This change provides the implementation of this primitive for a SingleTaskTypeDecl node.


12.121. Handle parsing errors in with clauses

When working on incomplete with clauses (for instance due to a parsing error), name resolution used to raise a Constraint_Error. This is now fixed.


12.122. Handle full type view resolution correctly in case of hiding

In some complex situations where an entity similarly caused hiding, full view of a type might not be resolved correctly, causing name resolution failures.


12.123. Handle Pred/Succ attributes in static evaluator

So far, the static evaluator wouldn’t properly evaluate Pred and Succ attributes, which could in turn cause failures in name resolution. This is now handled.


12.124. Fix association of pragma Volatile

pragma Volatile is now correctly associated with the declaration referenced by the first argument.


12.125. Handle full type view resolution correctly for operators

So far, when using user defined operators, the full view of the type might not be correctly resolved. This is now fixed.


12.126. Handle missing standard & implementation defined attributes

We implemented name resolution for a lot of attributes that were missing, both standard and implementation defined. The common characteristic is being supported by GNAT.

Here is the full list: Ceiling, Floor, Rounding, Callable, Type_Class, Storage_Pool, Width, Component_Size, Position, Mantissa, Model_Mantissa, Machine_Mantissa, Fore, Aft, Digits, Modulus, Epsilon, Model_Epsilon, Safe_Large, Safe_Small.

In addition, resolution for unhandled attributes now fails explicitly.


12.127. Resolution of binop for private types with scalar completion

So far name resolution did fail on some very simple cases where a type is private but is a scalar type in the private view, such as:

procedure Test_Binop_Res is
   package P is
      type A is private;
      type A is range 1 .. 20;
   end P;

   package body P is
      C : A := 12;
      B : A := 12 * C;
      pragma Test_Statement;
   end P;
end Test_Binop_Res;

This is because the resolution of built-in operators resolved to the canonical type to get the base subtype, which is wrong. This is now fixed.


12.128. Resolve more SPARK specific attributes and pragmas

Some SPARK specific pragmas and attributes were not yet resolved. The Loop_Invariant pragma and the Loop_Entry attribute were not resolved correctly. In addition, some bugs wrt. indexing the result of some attributes, such as 'Old/'Loop_Invariant have been fixed.