Skip to content

Optional diagnostics for CFG #2007

@fm-117

Description

@fm-117

The goal of this issue is to add new options that let the client choose the severity level for some of the checks performed by the CFG builder. 3 checks are concerned:

  • BasicBlockGroupGoesBeyondTheLimit when the target of a PERFORM may not return because of a premature exit
  • BadPerformProcedureThru when start and end of a PERFORM THRU are not in correct order
  • RecursiveBlockOnPerformProcedure when a PERFORM is recursive on at least one of its paths

BadAlterIntrWithNoSiblingGotoInstr is not concerned as unresolved altered GO TOs are considered as an error no matter what.

Technical

Instead of directly creating those diagnostic when detected, the CFG builder will store information in current graph for later use. At the end of the building, the diagnostics will be created depending on the severity level chosen by the user (see ITypeCobolCheckOptions and existing optional diagnostics CheckendAlignment or CheckEndProgram).

  • for BasicBlockGroupGoesBeyondTheLimit
    • add a new property Dictionary<PerformProcedure, List<Node>> PrematurePerformExits, key is the PERFORM statement which is prematurely ended, the corresponding list of nodes is all the instructions that break the flow of the PERFORM
  • for BadPerformProcedureThru
    • add a new property Dictionary<PerformProcedure, Tuple<Node, Node>> WrongOrderPerformThrus, key is the PERFORM THRU statement which has wrong procedure order, the tuple contains the resolved paragraph or sections. First item is the start of range (before THRU), second item is the end of range (after THRU). So Item1 is declared after Item2 in program.
  • for RecursiveBlockOnPerformProcedure
    • add a new property Dictionary<PerformProcedure, Node> RecursivePerforms, key is the recursive PERFORM statement, value is the first detected instruction that leads to recursivity.

New options are:

  • diag.cppe|diagnostic.checkPerformPrematureExits
  • diag.cpto|diagnostic.checkPerformThruOrder
  • diag.crp|diagnostic.checkRecursivePerforms

Those 3 options would be set to Warning by default, to match the IBM-compiler behavior.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions