Skip to content

Check Template Uses

Andrei Tumbar edited this page Sep 24, 2026 · 3 revisions

This algorithm traverses a source model and checks that each use of a module template definition refers to a valid template definition. It also constructs the use-def map entries for template expansion specifiers.

Input

  1. A list tul of translation units.

  2. An analysis data structure a representing the results of analysis so far.

Output

  1. An analysis data structure a with updated use-def map.

Procedure

  1. Translation unit lists: Visit each translation unit tu in tul in order.

  2. Translation units: Visit a translation unit tu by visiting its members tum.

  3. Translation unit members: Visit a translation unit member tum as follows:

    1. Module definitions: If tum is a module definition d with name n, then

      1. Look up the module symbol sym associated with the unqualified name n in the nested scope of a, in the value name group.

      2. Look up the mapping from sym to s in the symbol-scope map of a. If no such mapping exists, then throw an internal error.

      3. Push s onto the nested scope of a.

      4. Visit each translation unit member of d.

      5. Pop s off the nested scope of a.

    2. Module template expansion: If tum is a template expansion specifier te, then

      1. Visit the template name t used in te using the same rules as for uses, resolving t in the template name group. This adds a mapping from the use to its definition in the use-def map of a.

    3. Otherwise do nothing.

Clone this wiki locally