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

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu May 18 10:31:50 PDT 2023


ldionne created this revision.
Herald added a project: All.
ldionne requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150885

Files:
  libcxx/include/module.modulemap.in
  libcxx/test/libcxx/containers/associative/map/find.modules.compile.pass.mm


Index: libcxx/test/libcxx/containers/associative/map/find.modules.compile.pass.mm
===================================================================
--- /dev/null
+++ libcxx/test/libcxx/containers/associative/map/find.modules.compile.pass.mm
@@ -0,0 +1,16 @@
+//===----------------------------------------------------------------------===//
+//
+// 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).
+
+#include <map>
+
+void f(std::map<int, int> const& map, int key) {
+    (void)map.find(key);
+}
Index: libcxx/include/module.modulemap.in
===================================================================
--- libcxx/include/module.modulemap.in
+++ libcxx/include/module.modulemap.in
@@ -847,18 +847,6 @@
       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,19 @@
   module __undef_macros      {         header "__undef_macros"      export * }
   module __verbose_abort     {         header "__verbose_abort"     export * }
 
+  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
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150885.523441.patch
Type: text/x-patch
Size: 2543 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230518/1a2d31b4/attachment.bin>


More information about the libcxx-commits mailing list