]> gcc.gnu.org Git - gcc.git/commitdiff
Add mapper flags support
authorNathan Sidwell <nathan@acm.org>
Tue, 10 Nov 2020 19:58:38 +0000 (11:58 -0800)
committerNathan Sidwell <nathan@acm.org>
Tue, 10 Nov 2020 19:58:38 +0000 (11:58 -0800)
c++tools/
* mapper.h (class mapper_client): Add flag support.
gcc/cp/
* mapper-client: Likewise.
* module.cc (maybe_translate_include): Likewise.
(preprocessed_module): Likewise.

ChangeLog.modules
c++tools/mapper.h
gcc/cp/mapper-client.cc
gcc/cp/module.cc

index 349133d0f784448900233f043c9f945d526e6ebf..07e1637107c25b1830fb327fe53ff3cca6bde564 100644 (file)
@@ -1,5 +1,12 @@
 2020-11-10  Nathan Sidwell  <nathan@acm.org>
 
+       c++tools/
+       * mapper.h (class mapper_client): Add flag support.
+       gcc/cp/
+       * mapper-client: Likewise.
+       * module.cc (maybe_translate_include): Likewise.
+       (preprocessed_module): Likewise.
+
        libcody/
        Rebase on upstream -- $flag support.
 
index 95eaf0e77392be98466793272e93e2ec250743f9..5df56e35ceaa8fd9026c1f21f92010c64dbc1024 100644 (file)
@@ -76,20 +76,26 @@ public:
   }
 
 public:
-  // Virtual overriders, names are controlle by Cody::Resolver
+  // Virtual overriders, names are controlled by Cody::Resolver
+  using parent::ConnectRequest;
   virtual module_resolver *ConnectRequest (Cody::Server *, unsigned version,
                                           std::string &agent,
                                           std::string &ident)
     override;
+  using parent::ModuleRepoRequest;
   virtual int ModuleRepoRequest (Cody::Server *) override;
+  using parent::ModuleExportRequest;
   virtual int ModuleExportRequest (Cody::Server *s, std::string &module)
     override;
+  using parent::ModuleImportRequest;
   virtual int ModuleImportRequest (Cody::Server *s, std::string &module)
     override;
+  using parent::IncludeTranslateRequest;
   virtual int IncludeTranslateRequest (Cody::Server *s, std::string &include)
     override;
 
 private:
+  using parent::GetCMISuffix;
   virtual char const *GetCMISuffix () override;
 
 private:
@@ -105,6 +111,7 @@ class module_client : public Cody::Client
 {
   pex_obj *pex = nullptr;
   sighandler_t sigpipe = SIG_IGN;
+  Cody::Flags flags = Cody::Flags::None;
 
 public:
   module_client (Cody::Server *s)
@@ -118,6 +125,12 @@ public:
   {
   }
 
+public:
+  Cody::Flags get_flags () const
+  {
+    return flags;
+  }
+
 public:
   static module_client *open_module_client (location_t loc, const char *option,
                                            void (*set_repo) (const char *),
index eb9f295348cc91e5b4b885e0738d1f9a6acf719b..a9b86acbad57363ac00b6722158e108f3c8d472b 100644 (file)
@@ -266,7 +266,7 @@ module_client::open_module_client (location_t loc, const char *o,
 
   auto &connect = packets[0];
   if (connect.GetCode () == Cody::Client::PC_CONNECT)
-    ;
+    c->flags = Cody::Flags (connect.GetInteger ());
   else if (connect.GetCode () == Cody::Client::PC_ERROR)
     error_at (loc, "failed mapper handshake %s", connect.GetString ().c_str ());
 
index c7ffa76a544c72353912e383818271103fbd58bc..ab95774a05b7aaa40750924a5e13366cd6534c70 100644 (file)
@@ -19038,7 +19038,7 @@ maybe_translate_include (cpp_reader *reader, line_maps *lmaps, location_t loc,
 
   size_t len = strlen (path);
   path = canonicalize_header_name (NULL, loc, true, path, len);
-  auto packet = mapper->IncludeTranslate (path, len);
+  auto packet = mapper->IncludeTranslate (path, Cody::Flags::None, len);
   int xlate = false;
   if (packet.GetCode () == Cody::Client::PC_BOOL)
     xlate = packet.GetInteger ();
@@ -19245,7 +19245,9 @@ preprocess_module (module_state *module, location_t from_loc,
 }
 
 /* We've completed phase-4 translation.  Emit any dependency
-   information for the direct imports, and fill in their file names.  */
+   information for the not-yet-loaded direct imports, and fill in
+   their file names.  We'll have already loaded up the direct header
+   unit wavefront.  */
 
 void
 preprocessed_module (cpp_reader *reader)
@@ -19261,39 +19263,50 @@ preprocessed_module (cpp_reader *reader)
   /* using iterator = hash_table<module_state_hash>::iterator;  */
 
   /* Walk the module hash, asking for the names of all unknown
-     direct imports.  */
+     direct imports and informing of an export (if that's what we
+     are).  Notice these are emitted even when preprocessing as they
+     inform the server of dependency edges.  */
   timevar_start (TV_MODULE_MAPPER);
 
   dump.push (NULL);
   dump () && dump ("Resolving direct import names");
 
-  mapper->Cork ();
-  iterator end = modules_hash->end ();
-  for (iterator iter = modules_hash->begin (); iter != end; ++iter)
+  if (!flag_preprocess_only
+      || bool (mapper->get_flags () & Cody::Flags::NameOnly)
+      || cpp_get_deps (reader))
     {
-      module_state *module = *iter;
-      if (module->is_direct () && !module->filename)
+      mapper->Cork ();
+      iterator end = modules_hash->end ();
+      for (iterator iter = modules_hash->begin (); iter != end; ++iter)
        {
-         if (module->module_p
-             && (module->is_partition () || module->exported_p))
-           mapper->ModuleExport (module->get_flatname ());
-         else
-           mapper->ModuleImport (module->get_flatname ());
+         module_state *module = *iter;
+         if (module->is_direct () && !module->filename)
+           {
+             Cody::Flags flags
+               = (flag_preprocess_only ? Cody::Flags::None
+                  : Cody::Flags::NameOnly);
+
+             if (module->module_p
+                 && (module->is_partition () || module->exported_p))
+               mapper->ModuleExport (module->get_flatname (), flags);
+             else
+               mapper->ModuleImport (module->get_flatname (), flags);
+           }
        }
-    }
 
-  auto response = mapper->Uncork ();
-  auto r_iter = response.begin ();
-  for (iterator iter = modules_hash->begin (); iter != end; ++iter)
-    {
-      module_state *module = *iter;
-      
-      if (module->is_direct () && !module->filename)
+      auto response = mapper->Uncork ();
+      auto r_iter = response.begin ();
+      for (iterator iter = modules_hash->begin (); iter != end; ++iter)
        {
-         Cody::Packet const &p = *r_iter;
-         ++r_iter;
+         module_state *module = *iter;
+
+         if (module->is_direct () && !module->filename)
+           {
+             Cody::Packet const &p = *r_iter;
+             ++r_iter;
 
-         module->set_filename (p);
+             module->set_filename (p);
+           }
        }
     }
 
This page took 0.099625 seconds and 5 git commands to generate.