llvm/flang/lib/semantics
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
..
assignment.cc [flang] Create framework for checking statement semantics 2019-03-05 16:52:50 -08:00
assignment.h [flang] Create framework for checking statement semantics 2019-03-05 16:52:50 -08:00
attr.cc [flang] Changed .clang-format so that it will not add a comment after the closing brace of each namespace. Removed all such previous comments from all .cc and .h files 2018-10-25 05:55:23 -07:00
attr.h [flang] Changed .clang-format so that it will not add a comment after the closing brace of each namespace. Removed all such previous comments from all .cc and .h files 2018-10-25 05:55:23 -07:00
canonicalize-do.cc [flang] Use value()/has_value() on Indirection class templates instead of operator*/operator-> 2019-03-05 12:28:08 -08:00
canonicalize-do.h [flang] Changed .clang-format so that it will not add a comment after the closing brace of each namespace. Removed all such previous comments from all .cc and .h files 2018-10-25 05:55:23 -07:00
check-do-concurrent.cc [flang] Create framework for checking statement semantics 2019-03-05 16:52:50 -08:00
check-do-concurrent.h [flang] Create framework for checking statement semantics 2019-03-05 16:52:50 -08:00
CMakeLists.txt [flang] C1594 constraint checking on pointer components in struct constructors 2019-03-04 16:30:24 -08:00
dump-parse-tree.h [flang] basic skeleton of assignment analyzer 2019-01-17 10:41:08 -08:00
expression.cc [flang] Create framework for checking statement semantics 2019-03-05 16:52:50 -08:00
expression.h [flang] Create framework for checking statement semantics 2019-03-05 16:52:50 -08:00
mod-file.cc [flang] Use value()/has_value() on Indirection class templates instead of operator*/operator-> 2019-03-05 12:28:08 -08:00
mod-file.h [flang] Fix .mod file for symbols with same name as generic 2019-02-28 10:38:17 -08:00
resolve-labels.cc [flang] Fix for both issues 274 and 278 2019-02-08 10:53:18 -08:00
resolve-labels.h [flang] Changed .clang-format so that it will not add a comment after the closing brace of each namespace. Removed all such previous comments from all .cc and .h files 2018-10-25 05:55:23 -07:00
resolve-names.cc [flang] Create framework for checking statement semantics 2019-03-05 16:52:50 -08:00
resolve-names.h [flang] Changed .clang-format so that it will not add a comment after the closing brace of each namespace. Removed all such previous comments from all .cc and .h files 2018-10-25 05:55:23 -07:00
rewrite-parse-tree.cc [flang] Use value()/has_value() on Indirection class templates instead of operator*/operator-> 2019-03-05 12:28:08 -08:00
rewrite-parse-tree.h [flang] Changed .clang-format so that it will not add a comment after the closing brace of each namespace. Removed all such previous comments from all .cc and .h files 2018-10-25 05:55:23 -07:00
scope.cc [flang] Type checking on values in structure components 2019-03-04 16:30:22 -08:00
scope.h [flang] Type checking on values in structure components 2019-03-04 16:30:22 -08:00
semantics.cc [flang] Create framework for checking statement semantics 2019-03-05 16:52:50 -08:00
semantics.h [flang] Create framework for checking statement semantics 2019-03-05 16:52:50 -08:00
symbol.cc [flang] snapshot of work in progress 2019-03-04 16:30:23 -08:00
symbol.h [flang] Rename to Fortran.h, update style guide, run clang-format 2019-02-28 11:48:15 -08:00
tools.cc [flang] Tweak API per review 2019-03-05 13:11:57 -08:00
tools.h [flang] Tweak API per review 2019-03-05 13:11:57 -08:00
type.cc [flang] Type checking on values in structure components 2019-03-04 16:30:22 -08:00
type.h [flang] Type checking on values in structure components 2019-03-04 16:30:22 -08:00
unparse-with-symbols.cc [flang] Change when symbol is set in parser::Name 2018-12-06 07:16:52 -08:00
unparse-with-symbols.h [flang] Changed .clang-format so that it will not add a comment after the closing brace of each namespace. Removed all such previous comments from all .cc and .h files 2018-10-25 05:55:23 -07:00