[PATCH] Module use declarations (II)

Daniel Jasper djasper at google.com
Wed Sep 11 07:08:34 PDT 2013



================
Comment at: lib/Basic/Module.cpp:271
@@ +270,3 @@
+  }
+  // FIXME: Add handling of wildcard module specifications.
+}
----------------
Doug Gregor wrote:
> Daniel Jasper wrote:
> > Doug Gregor wrote:
> > > Why do we even have wildcards for uses? It seems that one would have to enumerate all of the uses separately for this feature to be useful.
> > I had the same initial thought. However, I think this might be useful e.g. because a project's internal modules might be treated differently from system modules. Internally, a project might want to specify all dependencies clearly. However, it could e.g. be useful to say "uses std.*" because including any header from std is always ok. (I don't feel certain about this, though).
> Interesting. Would simply saying
> 
>   uses std;
> 
> mean the same thing as 
> 
>   uses std.*;
> 
> ?
> 
> Anyway, I'm okay with this, it just feels unnecessary.
Ah, right. I hadn't thought of that. And I am also a big fan of keeping things simple. So, removed this.

================
Comment at: lib/Serialization/ASTReader.cpp:3032
@@ -3031,1 +3031,3 @@
+
+  //FIXME: How do we load the 'use'd modules?  They may not be submodules.
   
----------------
Doug Gregor wrote:
> Daniel Jasper wrote:
> > Doug Gregor wrote:
> > > You can read/write global "submodule IDs". The "sub" is misleading in this case; it means that one might be referring to either a top-level module or to a submodule.
> > I don't understand where the ID of a global module would come from. As far as I understand, all the (sub)modules within a single top-level module are numbered and then referred to by this number. How would that work for global modules?
> The writer conjures up (sub)module IDs when you call getSubmoduleID. Then the reader can turn that number into a reference to an actual Module* using getGlobalSubmoduleID/getSubmodule.
The problem is that using getSubmoduleID in the writer leads to an assertion as the writer generates more submodule IDs than the module has submodules. Not sure whether this is important.

However, I am also wondering whether the use declarations should actually be serialized. As it stands, they are used to enforce layering when building the module from the module map file and should not be required afterwards. Could we leave serialization out and add it if it turns out it is required?


http://llvm-reviews.chandlerc.com/D1546



More information about the cfe-commits mailing list