graydon created this revision. graydon added reviewers: doug.gregor, manmanren, rsmith. graydon added a subscriber: cfe-commits.
The Swift frontend is acquiring the ability to load non-module PCH files containing bridging definitions from C/ObjC. As part of this work, it needs to know which submodules were imported by a PCH in order to wrap them in local Swift modules. This information is collected by ASTReader::ReadAST in a local vector, but is currently kept private. The change here is just to make the type of the vector elements public, and provide an optional out-parameter to the ReadAST method to provide the vector's contents to a caller after a successful read. https://reviews.llvm.org/D27580 Files: include/clang/Serialization/ASTReader.h lib/Serialization/ASTReader.cpp Index: lib/Serialization/ASTReader.cpp =================================================================== --- lib/Serialization/ASTReader.cpp +++ lib/Serialization/ASTReader.cpp @@ -3578,7 +3578,8 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName, ModuleKind Type, SourceLocation ImportLoc, - unsigned ClientLoadCapabilities) { + unsigned ClientLoadCapabilities, + SmallVectorImpl<ImportedSubmodule> *Imported) { llvm::SaveAndRestore<SourceLocation> SetCurImportLocRAII(CurrentImportLoc, ImportLoc); @@ -3744,6 +3745,10 @@ } UnresolvedModuleRefs.clear(); + if (Imported) + Imported->append(ImportedModules.begin(), + ImportedModules.end()); + // FIXME: How do we load the 'use'd modules? They may not be submodules. // Might be unnecessary as use declarations are only used to build the // module itself. Index: include/clang/Serialization/ASTReader.h =================================================================== --- include/clang/Serialization/ASTReader.h +++ include/clang/Serialization/ASTReader.h @@ -821,14 +821,16 @@ // \brief A list of late parsed template function data. SmallVector<uint64_t, 1> LateParsedTemplates; +public: struct ImportedSubmodule { serialization::SubmoduleID ID; SourceLocation ImportLoc; ImportedSubmodule(serialization::SubmoduleID ID, SourceLocation ImportLoc) : ID(ID), ImportLoc(ImportLoc) {} }; +private: /// \brief A list of modules that were imported by precompiled headers or /// any other non-module AST file. SmallVector<ImportedSubmodule, 2> ImportedModules; @@ -1404,9 +1406,13 @@ /// \param ClientLoadCapabilities The set of client load-failure /// capabilities, represented as a bitset of the enumerators of /// LoadFailureCapabilities. + /// + /// \param Imported optional out-parameter to append the list of modules + /// that were imported by precompiled headers or any other non-module AST file ASTReadResult ReadAST(StringRef FileName, ModuleKind Type, SourceLocation ImportLoc, - unsigned ClientLoadCapabilities); + unsigned ClientLoadCapabilities, + SmallVectorImpl<ImportedSubmodule> *Imported = nullptr); /// \brief Make the entities in the given module and any of its (non-explicit) /// submodules visible to name lookup.
Index: lib/Serialization/ASTReader.cpp =================================================================== --- lib/Serialization/ASTReader.cpp +++ lib/Serialization/ASTReader.cpp @@ -3578,7 +3578,8 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName, ModuleKind Type, SourceLocation ImportLoc, - unsigned ClientLoadCapabilities) { + unsigned ClientLoadCapabilities, + SmallVectorImpl<ImportedSubmodule> *Imported) { llvm::SaveAndRestore<SourceLocation> SetCurImportLocRAII(CurrentImportLoc, ImportLoc); @@ -3744,6 +3745,10 @@ } UnresolvedModuleRefs.clear(); + if (Imported) + Imported->append(ImportedModules.begin(), + ImportedModules.end()); + // FIXME: How do we load the 'use'd modules? They may not be submodules. // Might be unnecessary as use declarations are only used to build the // module itself. Index: include/clang/Serialization/ASTReader.h =================================================================== --- include/clang/Serialization/ASTReader.h +++ include/clang/Serialization/ASTReader.h @@ -821,14 +821,16 @@ // \brief A list of late parsed template function data. SmallVector<uint64_t, 1> LateParsedTemplates; +public: struct ImportedSubmodule { serialization::SubmoduleID ID; SourceLocation ImportLoc; ImportedSubmodule(serialization::SubmoduleID ID, SourceLocation ImportLoc) : ID(ID), ImportLoc(ImportLoc) {} }; +private: /// \brief A list of modules that were imported by precompiled headers or /// any other non-module AST file. SmallVector<ImportedSubmodule, 2> ImportedModules; @@ -1404,9 +1406,13 @@ /// \param ClientLoadCapabilities The set of client load-failure /// capabilities, represented as a bitset of the enumerators of /// LoadFailureCapabilities. + /// + /// \param Imported optional out-parameter to append the list of modules + /// that were imported by precompiled headers or any other non-module AST file ASTReadResult ReadAST(StringRef FileName, ModuleKind Type, SourceLocation ImportLoc, - unsigned ClientLoadCapabilities); + unsigned ClientLoadCapabilities, + SmallVectorImpl<ImportedSubmodule> *Imported = nullptr); /// \brief Make the entities in the given module and any of its (non-explicit) /// submodules visible to name lookup.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits