[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
This commit is contained in:
Louis Dionne 2023-05-18 10:26:06 -07:00
parent f60cc01e9e
commit e89bdc6bd7
2 changed files with 32 additions and 12 deletions

View File

@ -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

View File

@ -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);
}