[llvm-branch-commits] [libcxx] [libc++][modules] Fixes clang-tidy exports. (PR #76288)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sat Dec 23 06:32:18 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Mark de Wever (mordante)
<details>
<summary>Changes</summary>
As suggested in #<!-- -->71438 we should use
export import std;
in the std.compat module.
Using this exports some named declarations from functions and records, adding them to the global namespace. Clang correctly, does not export these it's and issue in the declaration filtering. Declarations in function or record context are not considered a global named declaration.
---
Full diff: https://github.com/llvm/llvm-project/pull/76288.diff
1 Files Affected:
- (modified) libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp (+5-1)
``````````diff
diff --git a/libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp b/libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp
index 35f020da45c435..15d2e6839ad5e3 100644
--- a/libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp
+++ b/libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp
@@ -252,9 +252,13 @@ static bool is_global_name_exported_by_std_module(std::string_view name) {
static bool is_valid_declaration_context(
const clang::NamedDecl& decl, std::string_view name, header_exportable_declarations::FileType file_type) {
- if (decl.getDeclContext()->isNamespace())
+ const clang::DeclContext& context = *decl.getDeclContext();
+ if (context.isNamespace())
return true;
+ if (context.isFunctionOrMethod() || context.isRecord())
+ return false;
+
if (is_global_name_exported_by_std_module(name))
return true;
``````````
</details>
https://github.com/llvm/llvm-project/pull/76288
More information about the llvm-branch-commits
mailing list