r232159 - Make a module "use" also count as use of all its submodules
Daniel Jasper
djasper at google.com
Fri Mar 13 04:26:16 PDT 2015
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) {
+ 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;
More information about the cfe-commits
mailing list