<div dir="ltr">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.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 13, 2015 at 3:27 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><p dir="ltr"><br>
On Mar 13, 2015 4:31 AM, "Daniel Jasper" <<a href="mailto:djasper@google.com" target="_blank">djasper@google.com</a>> wrote:<br>
><br>
> Author: djasper<br>
> Date: Fri Mar 13 06:26:16 2015<br>
> New Revision: 232159<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=232159&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=232159&view=rev</a><br>
> Log:<br>
> Make a module "use" also count as use of all its submodules<br>
><br>
> Added:<br>
> cfe/trunk/test/Modules/Inputs/declare-use/sub.h<br>
> Modified:<br>
> cfe/trunk/lib/Lex/ModuleMap.cpp<br>
> cfe/trunk/test/Modules/Inputs/declare-use/module.map<br>
> cfe/trunk/test/Modules/declare-use1.cpp<br>
><br>
> Modified: cfe/trunk/lib/Lex/ModuleMap.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=232159&r1=232158&r2=232159&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=232159&r1=232158&r2=232159&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Lex/ModuleMap.cpp (original)<br>
> +++ cfe/trunk/lib/Lex/ModuleMap.cpp Fri Mar 13 06:26:16 2015<br>
> @@ -208,9 +208,11 @@ ModuleMap::findHeaderInUmbrellaDirs(cons<br>
> // Returns true if RequestingModule directly uses RequestedModule.<br>
> static bool directlyUses(const Module *RequestingModule,<br>
> const Module *RequestedModule) {<br>
> - return std::find(RequestingModule->DirectUses.begin(),<br>
> - RequestingModule->DirectUses.end(),<br>
> - RequestedModule) != RequestingModule->DirectUses.end();<br>
> + for (const Module* DirectUse : RequestingModule->DirectUses) {</p>
</div></div><p dir="ltr">This could be written using std::any_of - just a thought, not necessarily better, but might be.</p><div class="HOEnZb"><div class="h5">
<p dir="ltr">> + if (RequestedModule->isSubModuleOf(DirectUse))<br>
> + return true;<br>
> + }<br>
> + return false;<br>
> }<br>
><br>
> static bool violatesPrivateInclude(Module *RequestingModule,<br>
><br>
> Modified: cfe/trunk/test/Modules/Inputs/declare-use/module.map<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/declare-use/module.map?rev=232159&r1=232158&r2=232159&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/declare-use/module.map?rev=232159&r1=232158&r2=232159&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/test/Modules/Inputs/declare-use/module.map (original)<br>
> +++ cfe/trunk/test/Modules/Inputs/declare-use/module.map Fri Mar 13 06:26:16 2015<br>
> @@ -39,6 +39,7 @@ module XG {<br>
> use XE<br>
> use XJ<br>
> use XK<br>
> + use XN<br>
> }<br>
><br>
> module XH {<br>
> @@ -66,5 +67,11 @@ module XM {<br>
> textual header "m2.h"<br>
> }<br>
><br>
> +module XN {<br>
> + module sub {<br>
> + header "sub.h"<br>
> + }<br>
> +}<br>
> +<br>
> module XS {<br>
> }<br>
><br>
> Added: cfe/trunk/test/Modules/Inputs/declare-use/sub.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/declare-use/sub.h?rev=232159&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/declare-use/sub.h?rev=232159&view=auto</a><br>
> ==============================================================================<br>
> --- cfe/trunk/test/Modules/Inputs/declare-use/sub.h (added)<br>
> +++ cfe/trunk/test/Modules/Inputs/declare-use/sub.h Fri Mar 13 06:26:16 2015<br>
> @@ -0,0 +1,4 @@<br>
> +#ifndef SUB_H<br>
> +#define SUB_H<br>
> +const int sub = 42;<br>
> +#endif<br>
><br>
> Modified: cfe/trunk/test/Modules/declare-use1.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/declare-use1.cpp?rev=232159&r1=232158&r2=232159&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/declare-use1.cpp?rev=232159&r1=232158&r2=232159&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/test/Modules/declare-use1.cpp (original)<br>
> +++ cfe/trunk/test/Modules/declare-use1.cpp Fri Mar 13 06:26:16 2015<br>
> @@ -5,4 +5,5 @@<br>
> #include "e.h"<br>
> #include "f.h" // expected-error {{module XG does not depend on a module exporting 'f.h'}}<br>
> #include "i.h"<br>
> -const int g2 = g1 + e + f + aux_i;<br>
> +#include "sub.h"<br>
> +const int g2 = g1 + e + f + aux_i + sub;<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</p>
</div></div></blockquote></div><br></div>