r289276 - [modules] Add optional out-param to ASTReader::ReadAST for imported submodules.
Graydon Hoare via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 9 13:45:50 PST 2016
Author: graydon
Date: Fri Dec 9 15:45:49 2016
New Revision: 289276
URL: http://llvm.org/viewvc/llvm-project?rev=289276&view=rev
Log:
[modules] Add optional out-param to ASTReader::ReadAST for imported submodules.
Summary:
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.
Reviewers: manmanren, rsmith, doug.gregor
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D27580
Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTReader.cpp
Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=289276&r1=289275&r2=289276&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Fri Dec 9 15:45:49 2016
@@ -821,6 +821,7 @@ private:
// \brief A list of late parsed template function data.
SmallVector<uint64_t, 1> LateParsedTemplates;
+public:
struct ImportedSubmodule {
serialization::SubmoduleID ID;
SourceLocation ImportLoc;
@@ -829,6 +830,7 @@ private:
: 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 @@ public:
/// \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.
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=289276&r1=289275&r2=289276&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Dec 9 15:45:49 2016
@@ -3578,7 +3578,8 @@ static bool SkipCursorToBlock(BitstreamC
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 @@ ASTReader::ASTReadResult ASTReader::Read
}
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.
More information about the cfe-commits
mailing list