[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:53 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.
----------------
ldionne wrote:
```suggestion
// The only place where we can do the above while ensuring that all the
// declarations in the header have been seen is in the clang tidy plugin's
// destructor.
//
// It is possible to skip some declarations in the std namespace, these are
// added to decls_ before processing. To differentiate between a skipped
// declaration and a real declaration the skipped declarations are recorded
// in an extra variable.
```
https://github.com/llvm/llvm-project/pull/71438
More information about the libcxx-commits
mailing list