llvm/flang/lib
Tim Keith 813e48dc21 [flang] Create framework for checking statement semantics
Add `SemanticsVisitor` as the visitor class to perform statement
semantics checks. Its template parameters are "checker" classes
that perform the checks. They have `Enter` and `Leave` functions
that are called for the corresponding parse tree nodes (`Enter`
before the children, `Leave` after). Unlike `Pre` and `Post` in
visitors they cannot prevent the parse tree walker from visiting
child nodes.

Existing checks have been incorporated into this framework:
- `ExprChecker` replaces `AnalyzeExpressions()`
- `AssignmentChecker` replaces `AnalyzeAssignments()`
- `DoConcurrentChecker` replaces `CheckDoConcurrentConstraints()`

Adding a new checker requires:
- defining the checker class:
  - with BaseChecker as virtual base class
  - constructible from `SemanticsContext`
  - with Enter/Leave functions for nodes of interest
- add the checker class to the template parameters of `StatementSemantics`

Because these checkers and also `ResolveNamesVisitor` require tracking
the current statement source location, that has been moved into
`SemanticsContext`. `ResolveNamesVisitor` and `SemanticsVisitor`
update the location when `Statement` nodes are encountered, making it
available for error messages.

`AnalyzeKindSelector()` now has access to the current statement through
the context and so no longer needs to have it passed in.

Test `assign01.f90` was added to verify that `AssignmentChecker` is
actually doing something.

Original-commit: flang-compiler/f18@3a222c3673
Reviewed-on: https://github.com/flang-compiler/f18/pull/315
Tree-same-pre-rewrite: false
2019-03-05 16:52:50 -08:00
..
common [flang] Use value()/has_value() on Indirection class templates instead of operator*/operator-> 2019-03-05 12:28:08 -08:00
evaluate [flang] Use value()/has_value() on Indirection class templates instead of operator*/operator-> 2019-03-05 12:28:08 -08:00
FIR [flang] Rename to Fortran.h, update style guide, run clang-format 2019-02-28 11:48:15 -08:00
parser [flang] Use value()/has_value() on Indirection class templates instead of operator*/operator-> 2019-03-05 12:28:08 -08:00
semantics [flang] Create framework for checking statement semantics 2019-03-05 16:52:50 -08:00
CMakeLists.txt [flang] Rearrange some facilities into a new lib/common. 2018-06-18 11:05:17 -07:00