[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
================
@@ -18,15 +18,47 @@ namespace libcpp {
class header_exportable_declarations : public clang::tidy::ClangTidyCheck {
public:
explicit header_exportable_declarations(llvm::StringRef, clang::tidy::ClangTidyContext*);
+ ~header_exportable_declarations();
void registerMatchers(clang::ast_matchers::MatchFinder*) override;
void check(const clang::ast_matchers::MatchFinder::MatchResult&) override;
- enum class FileType { Header, ModulePartition, Module, Unknown };
+ enum class FileType {
+ // std module specific
+ Header,
+ CompatModulePartition,
+ Module,
+ // std.compat module specific
+ CHeader,
+ ModulePartition,
+ CompatModule,
+ // invalid value
+ Unknown
+ };
private:
llvm::StringRef filename_;
FileType file_type_;
llvm::StringRef extra_header_;
std::set<std::string> decls_;
+
+ // The named declarations in .h C headers are "tricky". On POSIX systems
+ // these headers contain POSIX specific functions that do not use a reserved
+ // name. For example, fmemopen is provided by stdio.h.
+ // The way to filter the names that should be provided by the headers is the
+ // following:
+ // - record all named declarations the global namespace
+ // - wait until the header is completely processed
+ // - every named declaration in the global namespace that has a matching
+ // "export" in the std namespace is exported.
+ //
+ // The only possible place where to process after the header is processed is
+ // the class' destructor.
+ //
+ // It is possible to skip some declarations in the std namespace, these are
+ // added to decls_ before processing. To differenciate between a skipped
+ // declaration and a real declaration the skipped declarations are recorded
+ // in an extra variable.
+ std::set<std::string> skip_decls_;
+ std::set<std::string> global_decls_;
----------------
ldionne wrote:
Can we move `global_decls_` above `skip_decls_` so it is just beside `decls_`? This also makes it clearer that this comment doesn't apply to `global_decls_`, which wasn't clear to me initially.
https://github.com/llvm/llvm-project/pull/71438
More information about the libcxx-commits
mailing list