[libcxx-commits] [libcxx] e89bdc6 - [libc++] Fix issue with std::map::find in Objective-C++ with modules

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri May 19 13:56:11 PDT 2023


Author: Louis Dionne
Date: 2023-05-19T13:56:05-07:00
New Revision: e89bdc6bd714268a8598567caad15aeb22f3af84

URL: https://github.com/llvm/llvm-project/commit/e89bdc6bd714268a8598567caad15aeb22f3af84
DIFF: https://github.com/llvm/llvm-project/commit/e89bdc6bd714268a8598567caad15aeb22f3af84.diff

LOG: [libc++] Fix issue with std::map::find in Objective-C++ with modules

This works around an issue with modules where Clang complains that
it doesn't know about `coroutine_handle<>` when trying to write very
basic code using std::map::find.

rdar://106813461

Differential Revision: https://reviews.llvm.org/D150885

Added: 
    libcxx/test/libcxx/containers/associative/map/find.modules.compile.pass.mm

Modified: 
    libcxx/include/module.modulemap.in

Removed: 
    


################################################################################
diff  --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index 2ea1adec2e84d..3db62d35e9fd0 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -847,18 +847,6 @@ module std [system] {
       module condition_variable { private header "__condition_variable/condition_variable.h" }
     }
   }
-  module coroutine {
-    header "coroutine"
-    export compare
-    export *
-
-    module __coroutine {
-      module coroutine_handle           { private header "__coroutine/coroutine_handle.h" }
-      module coroutine_traits           { private header "__coroutine/coroutine_traits.h" }
-      module noop_coroutine_handle      { private header "__coroutine/noop_coroutine_handle.h" }
-      module trivial_awaitables         { private header "__coroutine/trivial_awaitables.h" }
-    }
-  }
   module deque {
     header "deque"
     export initializer_list
@@ -1799,6 +1787,20 @@ module std [system] {
   module __undef_macros      {         header "__undef_macros"      export * }
   module __verbose_abort     {         header "__verbose_abort"     export * }
 
+  // This one needs to appear after __tree to work around issues with modules in Objective-C++ mode.
+  module coroutine {
+    header "coroutine"
+    export compare
+    export *
+
+    module __coroutine {
+      module coroutine_handle           { private header "__coroutine/coroutine_handle.h" }
+      module coroutine_traits           { private header "__coroutine/coroutine_traits.h" }
+      module noop_coroutine_handle      { private header "__coroutine/noop_coroutine_handle.h" }
+      module trivial_awaitables         { private header "__coroutine/trivial_awaitables.h" }
+    }
+  }
+
   module experimental {
     requires cplusplus11
 

diff  --git a/libcxx/test/libcxx/containers/associative/map/find.modules.compile.pass.mm b/libcxx/test/libcxx/containers/associative/map/find.modules.compile.pass.mm
new file mode 100644
index 0000000000000..8b2f0057bcbc1
--- /dev/null
+++ b/libcxx/test/libcxx/containers/associative/map/find.modules.compile.pass.mm
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// Make sure that we don't get a compiler error when trying to use std::map::find
+// from Objective-C++. This happened in Objective-C++ mode with modules enabled (rdar://106813461).
+
+// REQUIRES: objective-c++
+
+#include <map>
+
+void f(std::map<int, int> const& map, int key) {
+    (void)map.find(key);
+}


        


More information about the libcxx-commits mailing list