Page MenuHomePhabricator

[flang][NFC] Add GetTopLevelUnitContaining functions
ClosedPublic

Authored by tskeith on Dec 2 2020, 9:15 AM.

Details

Summary

GetTopLevelUnitContaining returns the Scope nested in the global scope
that contains the given Scope or Symbol.

Use "Get" rather than "Find" in the name because "Find" implies it might
not be found, which can't happen. Following that logic, rename
FindProgramUnitContaining to GetProgramUnitContaining and have it
also return a reference rather that a pointer.

Note that the use of "ProgramUnit" is slightly confusing. In the Fortran
standard, "program-unit" refers to what is called a "TopLevelUnit" here.
What we are calling a "ProgramUnit" (here and in ProgramTree) includes
internal subprograms while "TopLevelUnit" does not.

Diff Detail

Event Timeline

tskeith created this revision.Dec 2 2020, 9:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 2 2020, 9:15 AM
tskeith requested review of this revision.Dec 2 2020, 9:15 AM
PeteSteinfeld accepted this revision.Dec 2 2020, 10:16 AM

All builds, tests, and looks good.

This revision is now accepted and ready to land.Dec 2 2020, 10:16 AM
klausler accepted this revision.Dec 2 2020, 10:16 AM
klausler added inline comments.
flang/include/flang/Semantics/tools.h
33

"top level unit" is self-defining and I like it. Can we avoid "program unit" altogether, though? (It can't be "subprogram", either.)

tskeith added inline comments.Dec 2 2020, 10:28 AM
flang/include/flang/Semantics/tools.h
33

Avoiding "program unit" would be good but I haven't been able to come up with a better term.

This revision was landed with ongoing or failed builds.Dec 2 2020, 10:29 AM
This revision was automatically updated to reflect the committed changes.