Skip to content

Commit dd147d3

Browse files
committed
[libc++][modules] Fixes clang-tidy exports.
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.
1 parent 10dcb94 commit dd147d3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,13 @@ static bool is_global_name_exported_by_std_module(std::string_view name) {
252252

253253
static bool is_valid_declaration_context(
254254
const clang::NamedDecl& decl, std::string_view name, header_exportable_declarations::FileType file_type) {
255-
if (decl.getDeclContext()->isNamespace())
255+
const clang::DeclContext& context = *decl.getDeclContext();
256+
if (context.isNamespace())
256257
return true;
257258

259+
if (context.isFunctionOrMethod() || context.isRecord())
260+
return false;
261+
258262
if (is_global_name_exported_by_std_module(name))
259263
return true;
260264

0 commit comments

Comments
 (0)