Index: cfe/trunk/include/clang/Serialization/ASTReader.h =================================================================== --- cfe/trunk/include/clang/Serialization/ASTReader.h +++ cfe/trunk/include/clang/Serialization/ASTReader.h @@ -821,6 +821,7 @@ // \brief A list of late parsed template function data. SmallVector LateParsedTemplates; +public: struct ImportedSubmodule { serialization::SubmoduleID ID; SourceLocation ImportLoc; @@ -829,6 +830,7 @@ : ID(ID), ImportLoc(ImportLoc) {} }; +private: /// \brief A list of modules that were imported by precompiled headers or /// any other non-module AST file. SmallVector 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 *Imported = nullptr); /// \brief Make the entities in the given module and any of its (non-explicit) /// submodules visible to name lookup. Index: cfe/trunk/lib/Serialization/ASTReader.cpp =================================================================== --- cfe/trunk/lib/Serialization/ASTReader.cpp +++ cfe/trunk/lib/Serialization/ASTReader.cpp @@ -3578,7 +3578,8 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName, ModuleKind Type, SourceLocation ImportLoc, - unsigned ClientLoadCapabilities) { + unsigned ClientLoadCapabilities, + SmallVectorImpl *Imported) { llvm::SaveAndRestore 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.