[libcxx-commits] [libcxx] [libc++][modules] Adds std.compat module. (PR #71438)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Nov 21 09:57:51 PST 2023
================
@@ -199,50 +223,121 @@ static bool is_viable_declaration(const clang::NamedDecl* decl) {
/// Returns the name is a reserved name.
///
/// Detected reserved names are names starting with __ or _[A-Z].
-/// These names can be in the namespace std or any namespace inside std. For
-/// example std::ranges contains reserved names to implement the Niebloids.
+/// These names can be in the global namespace, std namespace or any namespace
+/// inside std. For example, std::ranges contains reserved names to implement
+/// the Niebloids.
///
-/// This test misses 2 candidates which are not used in libc++
+/// This test misses candidates which are not used in libc++
/// * any identifier with two underscores not at the start
-/// * a name with a leading underscore in the global namespace
-bool is_reserved_name(const std::string& name) {
+bool is_reserved_name(std::string_view name) {
+ if (name.starts_with("_"))
+ return name.size() > 1 && (name[1] == '_' || std::isupper(name[1]));
+
std::size_t pos = name.find("::_");
if (pos == std::string::npos)
return false;
if (pos + 3 > name.size())
return false;
+ // This is a public name declared in cstdlib.
+ if (name == "std::_Exit")
+ return false;
+
return name[pos + 3] == '_' || std::isupper(name[pos + 3]);
}
+/// Some declarations in the global namespace are exported from the std module.
+static bool is_valid_global_name(std::string_view name) {
----------------
ldionne wrote:
```suggestion
static bool is_global_name_exported_by_std_module(std::string_view name) {
```
https://github.com/llvm/llvm-project/pull/71438
More information about the libcxx-commits
mailing list