Locate_Loop_Nesting
This command locates loops in programs that:
- Execute more than a given threshold number of times
- Are nested more than a given threshold level
Note: This is computed across subprogram calls; that is, if a subprogram call appears inside a loop, the subprogram's looping characteristics are added to the local statistics. Only the worst-case looping is reported for each subprogram.
Usage Tip: Areas where loops are highly nested or the repetition count is high are obvious areas for optimization of those statements inside the loops.
Command-Line Interface
Locate_Loop_Nesting
-Repetition_Threshold [integer-expression, default = 1000]
-Minimum_Nesting_Level [integer-expression, default = 3]
-Sort_By_Subsystem
-Use_Configuration [string-expression, default = ""]
-To_Report_Named [string-expression, default =
<default_output_directory>/loop_nesting_analysis]
<list of units>Nonstandard Parameters
- Repetition_Threshold: Specifies the minimum number of loop repetitions (when they can be statically computed) to include in the output.
- Minimum_Nesting_Level: Specifies the minimum amount of nesting required to be reported in the output table.
Sample Output
Locate_Misspellings
This command locates all misspellings in the following constructs:
- Comment words
- Declaration names (each segment is checked)
- String literals
The public domain GNU ispell program has been integrated into the Ada Analyzer to check spelling. The default dictionary is located in
$AA_HOME/lib/ispell/ispell.dict.If an ispell dictionary is already in use on your network or machine, you can specify that this dictionary be used by modifying the environment variable $ISPELL_DICTIONARY to the pathname of this dictionary. Users can expand the base dictionary with private words by creating a file called ispell.words in their home directory and adding words one to a line.
The file named allowed_name_abbreviations located in the standards_conformance subdirectory of the current configuration policy can also be updated to add acceptable words. These can be abbreviated forms that are used in the program but otherwise not in the dictionary.
It is also possible to report words that are spelled correctly but are considered prohibited for use by the project for some reason. The file named prohibited_names located in the standards_conformance subdirectory of the current configuration policy contains this list. A Boolean parameter is available to enable reporting of prohibited words.
Usage Tip: Misspellings are obviously not programming errors, but they detract from high-quality code. Prohibiting certain words can ensure that project-specific references do not appear in units that are designated for reuse.
Command-Line Interface
Locate_Misspellings
-Include_Comment_Checking
-Include_Declaration_Checking
-Include_String_Literal_Checking
-Include_Prohibited_Words
-Check_Words_Containing_Numbers
-Check_Words_Over_N_Characters [integer-expression, default = 1]
-Sort_By_Subsystem
-Use_Configuration [string-expression, default = ""]
-To_Report_Named [string-expression, default =
<default_output_directory>/misspelling_analysis]
<list of units>Nonstandard Parameters
- Include_*: Specifies whether to include misspelling located in the * kind of construct in the hypertable.
- Check_Words_Containing_Numbers: Specifies whether to check the spelling of words that contain numerals.
- Check_Words_Over_N_Characters: Specifies the minimum number of characters that a word must have to be checked for inclusion in the output.
- Include_Prohibited_Words: Specifies whether to check for the use of prohibited words. Prohibited words are listed in the file named prohibited_names located in the standards_conformance subdirectory of the current configuration policy.
Sample Output
Misspellings in Comments
Misspellings in Declarations
Misspellings in String Literals
Use of Prohibited Words
Locate_Name_Anomalies
This command checks all name declarations against the following criteria:
- Minimum length of the name
- Maximum length of the name
- Number of segments in the name
- Spelling of segments in the name
- Use of prohibited words/strings in the name
The user may set threshold or Boolean enable/disable parameters for each criterion. If a particular output is not desired, setting the threshold to an unreasonably high or low value will ensure no output for that item.
A description of the program that checks spelling and the associated dictionaries is located in the description of the Locate_Misspellings command on page 172.
Usage Tip: This command can be used to locate violations of project naming conventions.
Command-Line Interface
Locate_Name_Anomalies
-Minimum_Length [integer-expression, default = 3]
-Maximum_Length [integer-expression, default = 50]
-Maximum_Segment_Count [integer-expression, default = 4]
-Check_Spelling
-Check_Prohibited_Words
-Check_Words_Containing_Numbers
-Sort_By_Subsystem
-Use_Configuration [string-expression, default = ""]
-To_Report_Named [string-expression, default =
<default_output_directory>/naming_anomaly_analysis]
<list of units>Nonstandard Parameters
- Minimum_Length: Specifies the minimum length allowed for declared names.
- Maximum_Length: Specifies the maximum length allowed for declared names.
- Maximum_Segment_Count: Specifies the maximum allowable number of segments separated by underscore ( _ ) characters in a name.
- Check_Spelling: Specifies whether to check the spelling of declared names. If the name is not in the speller dictionary and also not in the file named allowed_name_abbreviations located in the standards_conformance subdirectory of the currently active configuration, it will be included in the output.
- Check_Prohibited_Words: Specifies whether to check names for the use of prohibited words. Prohibited words are listed in the file named prohibited_words located in the standards_conformance subdirectory of the currently active configuration.
- Check_Words_Containing_Numbers: Specifies whether to check the spelling of words that contain numerals.
Sample Output
Names That Are Too Short
Names That Are Too Long
Names with Too Many Segments
Misspelled Names
Use of Prohibited Names
Locate_Named_Declarations
This command locates all named declarations and sorts them by kind.
Usage Tip: This command can be used to check project naming conventions or to generate a dictionary of all names and their locations. It can also be used to find all declarations of a particular kind.
Command-Line Interface
Locate_Named_Declarations
-Include_Constants
-Include_Variables
-Include_Types
-Include_Packages
-Include_Procedures
-Include_Functions
-Include_Renames
-Include_Generics
-Include_Instantiations
-Include_Tasks
-Include_Entries
-Include_Exceptions
-Include_Parameters
-Include_Generic_Parameters
-Include_Record_Components
-Include_Discriminants
-Include_Enumeration_Literals
-Include_Loop_Identifiers
-Sort_By_Subsystem
-Use_Configuration [string-expression, default = ""]
-To_Report_Named [string-expression, default =
<default_output_directory>/naming_analysis]
<list of units>Nonstandard Parameters
- Include_*: Specifies whether to include names for the * kind of declarations.
Sample Output
Note: Hypertables containing other declaration names are identical in content and format.
Locate_Objects_By_Size
This command locates all object declarations and computes their type, scope, and size as it would be on the target machine. The file type_sizing_file in the current configuration policy contains sizing parameters that may need modification to match a specific target. The file type_sizing_name_map in the current configuration policy can be used to specify the exact size of a qualified type name. See page 42 for more details on configuring these parameters.
Usage Tip: Objects that are extremely large often impact code size and execution time. Some targets even limit object size. Objects that are not statically sized can also be of interest.
Command-Line Interface
Locate_Objects_By_Size
-Include_Constants
-Include_Non_Statically_Sized_Objects
-Display_In_Bytes
-Display_In_Words
-Size_Minimum [integer-expression, default = 0]
-Sort_By_Subsystem
-Use_Configuration [string-expression, default = ""]
-To_Report_Named [string-expression, default =
<default_output_directory>/object_size_analysis]
<list of units>Nonstandard Parameters
- Include_Constants: Specifies whether to include constants in the output.
- Include_Non_Statically_Sized_Objects: Specifies whether to include objects whose size cannot be statically computed in the output.
- Display_In_Bytes: Specifies the units in which the output should be displayed. The default is Bits. Values are rounded up to the nearest whole byte. The Size_Minimum parameter is also interpreted in bytes.
- Display_In_Words: Specifies the units in which the output should be displayed. The default is Bits. Values are rounded up to the nearest whole word. The Size_Minimum parameter is also interpreted in words.
Note: Only one of the Display_In_Bytes and Display_In_Words options should be enabled at any one time. If both are present, the last one in the options string takes precedence.
- Size_Minimum: Specifies the minimum size an object must be to be included in the output.
Sample Output
Size: Units depend on parameter selection.
ObjContext: There are three parts to the context:
Var = variable; Cst = constant
Gen = generic; Blank = nongeneric
Pkg = package; Proc = procedure; Func = function; Task = task
Locate_Objects_Set_And_Used
This command locates all parameter and variable declarations and collects all sets (writes) and uses (reads) of those objects.
Usage Tip: The number and location of all sets and uses of an object can be important to understanding the flow of data in the system and its synchronization requirements. Obviously, if an object has either no sets or no uses it should be investigated further.
Command-Line Interface
Locate_Objects_Set_And_Used
-Expand
-From_References
-Separate_Record_Component_References
-Include_Initialization
-Sort_By_Subsystem
-Use_Configuration [string-expression, default = ""]
-To_Report_Named [string-expression, default =
<default_output_directory>/object_set_used_analysis]
<list of units>Nonstandard Parameters
- Expand: Specifies that the output should be expanded so that each set and use of a variable is listed as a separate entry in the hypertable.
- From_References: Specifies that the list of variable sets and uses should be computed from the variable references located in the list of Ada units to analyze rather than from the variable declarations themselves. There are two methods to compute sets and uses of a variable. One method is to start with a variable declaration and ask who references it and the kind of reference. This is expensive because the unit-level dependencies must be computed and a second-level search of those units must be performed. A second method (enabled with this option) is to collect all variable references during the first-level search and sort them by variable name after all units have been scanned. This option can be significantly faster and result in the same set/use list if all units in the program closure are included in the <list of units>.
- Separate_Record_Component_References: Specifies that references to record components should be explicitly listed in addition to the update of the record variable itself.
- Include_Initialization: Specifies whether to add variables that are explicitly initialized at the point of declaration to the report. If the Separate_Record_Component_References option is also enabled, variables that are partially initialized via record-component default initialization will be added to the report. Suppressing this from the report will identify variables which are unused or are essentially constants.
Sample Output
Expanded Output
The appearance of P_Set, P_Use, and P_Both in the usage column means that a composite object has been partially set, partially used, or both. That is, one component of a record object has been referenced and not the entire object.
Locate_Obsolescent_Ada83_Features
This command will locate the use of all features specified in Annex J, "Obsolescent Features," of the Ada 95 language definition. The Ada 95 LRM defined several largely redundant features to maintain compatibility with Ada 83 programs. These features may be removed from the Ada language definition at some point and are not recommended in newly written Ada programs. The features located by this command are:
- Renamings of Ada 83 library units
- Reduced accuracy subtypes
- Constrained attributes
- Reference to package Ascii
- Numeric_Error exception
- At clauses
- Interrupt entries
- Mod clauses
- Storage_Size attributes
Usage Tip: This command can be used to check Ada 95 code for features which may become obsolete in future definitions of the Ada language standard. It will report the incomplete results when run against Ada 83 code.
Command-Line Interface
Locate_Obsolescent_Ada83_Features
-Sort_By_Subsystem
-Use_Configuration [string-expression, default = ""]
-To_Report_Named [string-expression, default =
<default_output_directory>/calling_relationships]
<list of units>Nonstandard Parameters
All parameters are standard parameters.
Sample Output
Library Unit Renamings
Reduced Accuracy Subtypes
Constrained Attributes
Reference to Package Ascii
Numeric_Error Exceptions
At Clauses
Interrupt Entries
Mod Clauses
Storage Size Attributes
Locate_Operators
This command locates all numeric and string operators. Certain operators are often very expensive in terms of execution time; location of these operators can be important to optimization efforts.
The output is sorted to help locate redundant expressions. The default sorts only the left operand of the expression. The output can be resorted to sort on the right operand.
Usage Tip: The use of some operators (concatenate, for example) can be very expensive on some targets. Knowing where these operators are used can be important to optimization efforts. It is also true that when requirements are stated functionally, they often include redundant algorithmic requirements for clarity. These can lead to redundant expressions in disparate parts of the software. This command can aid in locating these redundancies.
Command-Line Interface
Locate_Operators
-Include_Concatenate_Operators
-Include_Plus_Operators
-Include_Minus_Operators
-Include_Times_Operators
-Include_Divide_Operators
-Include_Unary_Minus_Operators
-Include_Unary_Plus_Operators
-Include_Modulo_Operators
-Include_Remainder_Operators
-Include_Power_Operators
-Include_Absolute_Value_Operators
-Sort_By_Subsystem
-Use_Configuration [string-expression, default = ""]
-To_Report_Named [string-expression, default =
<default_output_directory>/operator_selection_analysis]
<list of units>Nonstandard Parameters
- Include_*: Specifies whether to include the * kind of operators in the hypertable output.
Sample Output
Note: Hypertables for all other operators contain output identical in content and format except unary operators which, of course, have only one operand.
Locate_Others_Clauses
This command locates all uses of Ada others clauses, including:
- Case statement when others
- Exception handler when others
- Aggregate others choices
Usage Tip: Use of others clauses can be dangerous because they automatically pick up newly added discrete values, record components, or exceptions. Without any notification from the compiler, the new item is picked up under the others umbrella. This may be the desired effect, but in some cases it is inappropriate. This command will locate all when others and others choices for inspection.
Command-Line Interface
Locate_Others_Clauses
-Include_Case_When_Others
-Include_Handler_When_Others
-Include_Aggregate_Others
-Sort_By_Subsystem
-Use_Configuration [string-expression, default = ""]
-To_Report_Named [string-expression, default =
<default_output_directory>/others_clause_analysis]
<list of units>Nonstandard Parameters
- Include_*: Specifies whether to include the * kind of others clause in the hypertable output.
Sample Output
Case Statement When Others
Exception Handler When Others
Aggregate Others Choice
Locate_Packages_With_State
This command locates packages that have state (that is, static variable declarations that would have to be protected from multiple access in a multitasking system).
Usage Tip: It is useful to know when a package offers a "pure" abstraction that will always behave the same way or whether some state is updated as a side effect of calling package subprograms. In multitasking, it is typically necessary to synchronize such data.
Command-Line Interface
Locate_Packages_With_State
-Sort_By_Subsystem
-Use_Configuration [string-expression, default = ""]
-To_Report_Named [string-expression, default =
<default_output_directory>/packages_with_state_analysis]
<list of units>Nonstandard Parameters
All parameters are standard parameters.
Sample Output
Locate_Potential_Programming_Errors
This command locates several coding constructs that have a high potential for error. These constructs include:
- Subprogram calls using default values
- Division where the divisor has a potential zero value
- Use of unsafe relational operators with real values (the equal operator, for example, may always return False even though the values are close enough to be considered equal; the operators "<=" and ">=" should be used instead)
- Use of static nonattribute values for loop ranges (it is better to use a subtype indication or 'FIRST, 'LAST, or 'RANGE attributes)
- Use of static, nonattribute values for slice ranges
- Operator rename clauses that rename a different operator
- Exception handlers that check for Numeric_Error but not Constraint_Error in the same handler block
- Function exception handlers that contain neither a return nor a raise statement
- Protected operations that contain potentially blocking operations (LRM 9.5.1 (8)) or calls to subprograms that contain potentially blocking operations
- Infinite recursion where a subprogram calls itself without some form of termination. In addition, for a controlled type CT: Initialize procedures that create an uninitialized object of type CT, Adjust procedures that assign an object of type CT, and Finalize procedures in which an object of type CT goes out of existence are also located.
Usage Tip: Usage of the above constructs is not always an error. They are located for inspection to determine whether a problem exists.
Command-Line Interface
Locate_Potential_Programming_Errors
-Include_Calls_With_Defaults
-Include_Divide_By_Zero_Potential
-Include_Real_Relational_Operators
-Include_Static_Loop_Ranges
-Include_Static_Slice_Ranges
-Include_Operator_Renames
-Include_Handlers_Of_Numeric_Error
-Include_Function_Exception_Handlers
-Include_Blocking_Protected_Operations
-Include_Infinite_Recursion
-Sort_By_Subsystem
-Use_Configuration [string-expression, default = ""]
-To_Report_Named [string-expression, default =
<default_output_directory>/misc_programming_error_analysis]
<list of units>Nonstandard Parameters
- Include_*: Specifies whether to include the * kind of potential error in the hypertable output.
Sample Output
Calls with Defaults
Divide-by-Zero Potential
Real Relational Operators
Static Loop Ranges
Static Slice Ranges
Operator Renames
Handlers for Numeric_Error without Constraint_Error
Protected Operations with Blocking Operations
Function Handlers without Raise or Return Statements
Infinite Recursion
Rational Software Corporation
http://www.rational.com support@rational.com techpubs@rational.com Copyright © 1993-2000, Rational Software Corporation. All rights reserved. |