r232159 - Make a module "use" also count as use of all its submodules

Daniel Jasper djasper at google.com
Fri Mar 13 07:32:48 PDT 2015


Yeah, right. I think it is generally nice, but it is actually more code in
this case as you need to access begin and end iterator instead of the
range-based for loop. Also not sure which is better.

On Fri, Mar 13, 2015 at 3:27 PM, David Blaikie <dblaikie at gmail.com> wrote:

>
> On Mar 13, 2015 4:31 AM, "Daniel Jasper" <djasper at google.com> wrote:
> >
> > Author: djasper
> > Date: Fri Mar 13 06:26:16 2015
> > New Revision: 232159
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=232159&view=rev
> > Log:
> > Make a module "use" also count as use of all its submodules
> >
> > Added:
> >     cfe/trunk/test/Modules/Inputs/declare-use/sub.h
> > Modified:
> >     cfe/trunk/lib/Lex/ModuleMap.cpp
> >     cfe/trunk/test/Modules/Inputs/declare-use/module.map
> >     cfe/trunk/test/Modules/declare-use1.cpp
> >
> > Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=232159&r1=232158&r2=232159&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
> > +++ cfe/trunk/lib/Lex/ModuleMap.cpp Fri Mar 13 06:26:16 2015
> > @@ -208,9 +208,11 @@ ModuleMap::findHeaderInUmbrellaDirs(cons
> >  // Returns true if RequestingModule directly uses RequestedModule.
> >  static bool directlyUses(const Module *RequestingModule,
> >                           const Module *RequestedModule) {
> > -  return std::find(RequestingModule->DirectUses.begin(),
> > -                   RequestingModule->DirectUses.end(),
> > -                   RequestedModule) !=
> RequestingModule->DirectUses.end();
> > +  for (const Module* DirectUse : RequestingModule->DirectUses) {
>
> This could be written using std::any_of - just a thought, not necessarily
> better, but might be.
>
> > +    if (RequestedModule->isSubModuleOf(DirectUse))
> > +      return true;
> > +  }
> > +  return false;
> >  }
> >
> >  static bool violatesPrivateInclude(Module *RequestingModule,
> >
> > Modified: cfe/trunk/test/Modules/Inputs/declare-use/module.map
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/declare-use/module.map?rev=232159&r1=232158&r2=232159&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/test/Modules/Inputs/declare-use/module.map (original)
> > +++ cfe/trunk/test/Modules/Inputs/declare-use/module.map Fri Mar 13
> 06:26:16 2015
> > @@ -39,6 +39,7 @@ module XG {
> >    use XE
> >    use XJ
> >    use XK
> > +  use XN
> >  }
> >
> >  module XH {
> > @@ -66,5 +67,11 @@ module XM {
> >    textual header "m2.h"
> >  }
> >
> > +module XN {
> > +  module sub {
> > +    header "sub.h"
> > +  }
> > +}
> > +
> >  module XS {
> >  }
> >
> > Added: cfe/trunk/test/Modules/Inputs/declare-use/sub.h
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/declare-use/sub.h?rev=232159&view=auto
> >
> ==============================================================================
> > --- cfe/trunk/test/Modules/Inputs/declare-use/sub.h (added)
> > +++ cfe/trunk/test/Modules/Inputs/declare-use/sub.h Fri Mar 13 06:26:16
> 2015
> > @@ -0,0 +1,4 @@
> > +#ifndef SUB_H
> > +#define SUB_H
> > +const int sub = 42;
> > +#endif
> >
> > Modified: cfe/trunk/test/Modules/declare-use1.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/declare-use1.cpp?rev=232159&r1=232158&r2=232159&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/test/Modules/declare-use1.cpp (original)
> > +++ cfe/trunk/test/Modules/declare-use1.cpp Fri Mar 13 06:26:16 2015
> > @@ -5,4 +5,5 @@
> >  #include "e.h"
> >  #include "f.h" // expected-error {{module XG does not depend on a
> module exporting 'f.h'}}
> >  #include "i.h"
> > -const int g2 = g1 + e + f + aux_i;
> > +#include "sub.h"
> > +const int g2 = g1 + e + f + aux_i + sub;
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150313/2a352c03/attachment.html>


More information about the cfe-commits mailing list