void add_class_entities (vec<tree, va_gc> *);
 
   public:    
-    void find_dependencies ();
+    void find_dependencies (module_state *);
     bool finalize_dependencies ();
     vec<depset *> connect ();
   };
       if (!DECL_TEMPLATE_PARM_P (t))
        WT (t->decl_minimal.context);
 
-      state->write_location (*this, t->decl_minimal.locus);
+      if (state)
+       state->write_location (*this, t->decl_minimal.locus);
     }
 
   if (CODE_CONTAINS_STRUCT (code, TS_TYPE_COMMON))
 
   if (CODE_CONTAINS_STRUCT (code, TS_EXP))
     {
-      state->write_location (*this, t->exp.locus);
+      if (state)
+       state->write_location (*this, t->exp.locus);
 
       /* Walk in forward order, as (for instance) REQUIRES_EXPR has a
          bunch of unscoped parms on its first operand.  It's safer to
 
       /* Miscellaneous common nodes.  */
     case BLOCK:
-      state->write_location (*this, t->block.locus);
-      state->write_location (*this, t->block.end_locus);
-      
+      if (state)
+       {
+         state->write_location (*this, t->block.locus);
+         state->write_location (*this, t->block.end_locus);
+       }
+
       /* DECL_LOCAL_DECL_P decls are first encountered here and
          streamed by value.  */
       chained_decls (t->block.vars);
        /* The ompcode is serialized in start.  */
        if (streaming_p ())
          WU (t->omp_clause.subcode.map_kind);
-       state->write_location (*this, t->omp_clause.locus);
+       if (state)
+         state->write_location (*this, t->omp_clause.locus);
 
        unsigned len = omp_clause_num_ops[OMP_CLAUSE_CODE (t)];
        for (unsigned ix = 0; ix != len; ix++)
       WT (((lang_tree_node *)t)->lambda_expression.extra_scope);
       /* pending_proxies is a parse-time thing.  */
       gcc_assert (!((lang_tree_node *)t)->lambda_expression.pending_proxies);
-      state->write_location
-       (*this, ((lang_tree_node *)t)->lambda_expression.locus);
+      if (state)
+       state->write_location
+         (*this, ((lang_tree_node *)t)->lambda_expression.locus);
       if (streaming_p ())
        {
          WU (((lang_tree_node *)t)->lambda_expression.default_capture_mode);
     case STATIC_ASSERT:
       WT (((lang_tree_node *)t)->static_assertion.condition);
       WT (((lang_tree_node *)t)->static_assertion.message);
-      state->write_location
-       (*this, ((lang_tree_node *)t)->static_assertion.location);
+      if (state)
+       state->write_location
+         (*this, ((lang_tree_node *)t)->static_assertion.location);
       break;
 
     case TEMPLATE_DECL:
                WT (m.binfo);
                WT (m.decl);
                WT (m.diag_decl);
-               state->write_location (*this, m.loc);
+               if (state)
+                 state->write_location (*this, m.loc);
              }
          }
       }
    entries on the same binding that need walking.  */
 
 void
-depset::hash::find_dependencies ()
+depset::hash::find_dependencies (module_state *module)
 {
-  trees_out walker (NULL, NULL, *this);
+  trees_out walker (NULL, module, *this);
   vec<depset *> unreached;
   unreached.create (worklist.length ());
 
   gcc_checking_assert (use_lwm <= bind_lwm);
   dump (dumper::MERGE) && dump ("Ordering %u/%u depsets", use_lwm, size);
 
-  table.find_dependencies ();
+  table.find_dependencies (nullptr);
 
   vec<depset *> order = table.connect ();
   gcc_checking_assert (order.length () == use_lwm);
     }
 
   /* Now join everything up.  */
-  table.find_dependencies ();
+  table.find_dependencies (this);
 
   if (!table.finalize_dependencies ())
     {