On Fri, Mar 13, 2015 at 4:23 PM, David Blaikie <[email protected]> wrote:
> > > On Fri, Mar 13, 2015 at 7:32 AM, Daniel Jasper <[email protected]> wrote: > >> 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. >> > > Yep, pity we don't have range-based algorithms. > > >> Also not sure which is better. >> > > Perf wise, they'll be essentially the same. It's possible that the > range-based-for formulation would be a little slower in debug builds using > MSVC's standard library. The MSVC standard library has iterator range > checks which come at some cost - raw iterator code incurs many of those > checks (because it has to check on each operation) whereas algorithms can > conspire with the range checks, performing a single range-check up-front > before using unchecked operations to perform the actual work. > Thanks for elaborating. > > > - David > > >> >> On Fri, Mar 13, 2015 at 3:27 PM, David Blaikie <[email protected]> >> wrote: >> >>> >>> On Mar 13, 2015 4:31 AM, "Daniel Jasper" <[email protected]> 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 >>> > [email protected] >>> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits >>> >> >> >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
