r302491 - [Modules] Allow umbrella frameworks to define private submodules for subframeworks

Bruno Cardoso Lopes via cfe-commits cfe-commits at lists.llvm.org
Mon May 8 17:41:38 PDT 2017


Author: bruno
Date: Mon May  8 19:41:38 2017
New Revision: 302491

URL: http://llvm.org/viewvc/llvm-project?rev=302491&view=rev
Log:
[Modules] Allow umbrella frameworks to define private submodules for subframeworks

In r298391 we fixed the umbrella framework model to work when submodules
named "Private" are used. This complements the work by allowing the
umbrella framework model to work in general.

rdar://problem/31790067

Added:
    cfe/trunk/test/Modules/Inputs/MainA.framework/
    cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/
    cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/
    cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/
    cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/B.h
    cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/Sub.h
    cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/
    cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/BPriv.h
    cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/SubPriv.h
    cfe/trunk/test/Modules/Inputs/MainA.framework/Headers/
    cfe/trunk/test/Modules/Inputs/MainA.framework/Headers/A.h
    cfe/trunk/test/Modules/Inputs/MainA.framework/Headers/Main.h
    cfe/trunk/test/Modules/Inputs/MainA.framework/Modules/
    cfe/trunk/test/Modules/Inputs/MainA.framework/Modules/module.modulemap
    cfe/trunk/test/Modules/Inputs/MainA.framework/Modules/module.private.modulemap
    cfe/trunk/test/Modules/Inputs/MainA.framework/PrivateHeaders/
    cfe/trunk/test/Modules/Inputs/MainA.framework/PrivateHeaders/APriv.h
    cfe/trunk/test/Modules/Inputs/MainA.framework/PrivateHeaders/MainPriv.h
Modified:
    cfe/trunk/lib/Lex/ModuleMap.cpp
    cfe/trunk/test/Modules/find-privateheaders.m

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=302491&r1=302490&r2=302491&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Mon May  8 19:41:38 2017
@@ -1913,8 +1913,10 @@ void ModuleMapParser::parseHeaderDecl(MM
         // 'framework module FrameworkName.Private', since a 'Private.Framework'
         // does not usually exist. However, since both are currently widely used
         // for private modules, make sure we find the right path in both cases.
-        RelativePathName.resize(ActiveModule->IsFramework ? 0
-                                                          : RelativePathLength);
+        if (ActiveModule->IsFramework && ActiveModule->Name == "Private")
+          RelativePathName.clear();
+        else
+          RelativePathName.resize(RelativePathLength);
         FullPathName.resize(FullPathLength);
         llvm::sys::path::append(RelativePathName, "PrivateHeaders",
                                 Header.FileName);

Added: cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/B.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/B.h?rev=302491&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/B.h (added)
+++ cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/B.h Mon May  8 19:41:38 2017
@@ -0,0 +1 @@
+// B.h

Added: cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/Sub.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/Sub.h?rev=302491&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/Sub.h (added)
+++ cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/Sub.h Mon May  8 19:41:38 2017
@@ -0,0 +1,2 @@
+// Sub.h
+#import "B.h"

Added: cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/BPriv.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/BPriv.h?rev=302491&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/BPriv.h (added)
+++ cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/BPriv.h Mon May  8 19:41:38 2017
@@ -0,0 +1 @@
+// BPriv.h

Added: cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/SubPriv.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/SubPriv.h?rev=302491&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/SubPriv.h (added)
+++ cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/SubPriv.h Mon May  8 19:41:38 2017
@@ -0,0 +1 @@
+#import "BPriv.h"

Added: cfe/trunk/test/Modules/Inputs/MainA.framework/Headers/A.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/MainA.framework/Headers/A.h?rev=302491&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/MainA.framework/Headers/A.h (added)
+++ cfe/trunk/test/Modules/Inputs/MainA.framework/Headers/A.h Mon May  8 19:41:38 2017
@@ -0,0 +1 @@
+// A.h

Added: cfe/trunk/test/Modules/Inputs/MainA.framework/Headers/Main.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/MainA.framework/Headers/Main.h?rev=302491&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/MainA.framework/Headers/Main.h (added)
+++ cfe/trunk/test/Modules/Inputs/MainA.framework/Headers/Main.h Mon May  8 19:41:38 2017
@@ -0,0 +1,2 @@
+// Main.h
+#import "A.h"

Added: cfe/trunk/test/Modules/Inputs/MainA.framework/Modules/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/MainA.framework/Modules/module.modulemap?rev=302491&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/MainA.framework/Modules/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/MainA.framework/Modules/module.modulemap Mon May  8 19:41:38 2017
@@ -0,0 +1,12 @@
+framework module MainA {
+  umbrella header "Main.h"
+
+  module * { export * }
+  export *
+
+  framework module Sub {
+    umbrella header "Sub.h"
+    module * { export * }
+    export *
+  }
+}

Added: cfe/trunk/test/Modules/Inputs/MainA.framework/Modules/module.private.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/MainA.framework/Modules/module.private.modulemap?rev=302491&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/MainA.framework/Modules/module.private.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/MainA.framework/Modules/module.private.modulemap Mon May  8 19:41:38 2017
@@ -0,0 +1,12 @@
+framework module MainA_Private {
+  umbrella header "MainPriv.h"
+
+  module * { export * }
+  export *
+
+  explicit framework module Sub {
+    umbrella header "SubPriv.h"
+    module * { export * }
+    export *
+  }
+}

Added: cfe/trunk/test/Modules/Inputs/MainA.framework/PrivateHeaders/APriv.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/MainA.framework/PrivateHeaders/APriv.h?rev=302491&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/MainA.framework/PrivateHeaders/APriv.h (added)
+++ cfe/trunk/test/Modules/Inputs/MainA.framework/PrivateHeaders/APriv.h Mon May  8 19:41:38 2017
@@ -0,0 +1 @@
+// APriv.h

Added: cfe/trunk/test/Modules/Inputs/MainA.framework/PrivateHeaders/MainPriv.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/MainA.framework/PrivateHeaders/MainPriv.h?rev=302491&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/MainA.framework/PrivateHeaders/MainPriv.h (added)
+++ cfe/trunk/test/Modules/Inputs/MainA.framework/PrivateHeaders/MainPriv.h Mon May  8 19:41:38 2017
@@ -0,0 +1 @@
+#import "APriv.h"

Modified: cfe/trunk/test/Modules/find-privateheaders.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/find-privateheaders.m?rev=302491&r1=302490&r2=302491&view=diff
==============================================================================
--- cfe/trunk/test/Modules/find-privateheaders.m (original)
+++ cfe/trunk/test/Modules/find-privateheaders.m Mon May  8 19:41:38 2017
@@ -1,2 +1,13 @@
-// RUN: %clang_cc1 -fmodules -fsyntax-only -F%S/Inputs %s
+// RUN: rm -rf %t.cache
+// RUN: %clang_cc1 -fmodules -fsyntax-only -F%S/Inputs -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%t.cache -Wno-private-module -DBUILD_PUBLIC -verify %s
+// RUN: rm -rf %t.cache
+// RUN: %clang_cc1 -fmodules -fsyntax-only -F%S/Inputs -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%t.cache -Wno-private-module -verify %s
+//expected-no-diagnostics
+
+#ifdef BUILD_PUBLIC
 #import "Main/Main.h"
+#else
+#import "MainA/MainPriv.h"
+#endif




More information about the cfe-commits mailing list