public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/c++-modules] Add mapper flags support
@ 2020-11-11 17:55 Nathan Sidwell
0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2020-11-11 17:55 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:0835527413f7efe5b6b40f658c88b863cb8c14a2
commit 0835527413f7efe5b6b40f658c88b863cb8c14a2
Author: Nathan Sidwell <nathan@acm.org>
Date: Tue Nov 10 11:58:38 2020 -0800
Add mapper flags support
c++tools/
* mapper.h (class mapper_client): Add flag support.
gcc/cp/
* mapper-client: Likewise.
* module.cc (maybe_translate_include): Likewise.
(preprocessed_module): Likewise.
Diff:
---
ChangeLog.modules | 7 ++++++
c++tools/mapper.h | 15 +++++++++++-
gcc/cp/mapper-client.cc | 2 +-
gcc/cp/module.cc | 61 ++++++++++++++++++++++++++++++-------------------
4 files changed, 59 insertions(+), 26 deletions(-)
diff --git a/ChangeLog.modules b/ChangeLog.modules
index 349133d0f78..07e1637107c 100644
--- a/ChangeLog.modules
+++ b/ChangeLog.modules
@@ -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.
diff --git a/c++tools/mapper.h b/c++tools/mapper.h
index 95eaf0e7739..5df56e35cea 100644
--- a/c++tools/mapper.h
+++ b/c++tools/mapper.h
@@ -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 *),
diff --git a/gcc/cp/mapper-client.cc b/gcc/cp/mapper-client.cc
index eb9f295348c..a9b86acbad5 100644
--- a/gcc/cp/mapper-client.cc
+++ b/gcc/cp/mapper-client.cc
@@ -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 ());
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index c7ffa76a544..ab95774a05b 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -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);
+ }
}
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-11-11 17:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-11 17:55 [gcc/devel/c++-modules] Add mapper flags support Nathan Sidwell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).