summaryrefslogtreecommitdiffstats
path: root/include/clang/Serialization
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/Serialization')
-rw-r--r--include/clang/Serialization/ASTBitCodes.h50
-rw-r--r--include/clang/Serialization/ASTDeserializationListener.h13
-rw-r--r--include/clang/Serialization/ASTReader.h339
-rw-r--r--include/clang/Serialization/ASTWriter.h95
-rw-r--r--include/clang/Serialization/ContinuousRangeMap.h4
-rw-r--r--include/clang/Serialization/GlobalModuleIndex.h4
-rw-r--r--include/clang/Serialization/Module.h9
-rw-r--r--include/clang/Serialization/ModuleManager.h62
8 files changed, 289 insertions, 287 deletions
diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h
index 3874f3a..e0f01c8 100644
--- a/include/clang/Serialization/ASTBitCodes.h
+++ b/include/clang/Serialization/ASTBitCodes.h
@@ -149,7 +149,11 @@ namespace clang {
/// \brief An ID number that refers to a set of CXXBaseSpecifiers in an
/// AST file.
typedef uint32_t CXXBaseSpecifiersID;
-
+
+ /// \brief An ID number that refers to a list of CXXCtorInitializers in an
+ /// AST file.
+ typedef uint32_t CXXCtorInitializersID;
+
/// \brief An ID number that refers to an entity in the detailed
/// preprocessing record.
typedef uint32_t PreprocessedEntityID;
@@ -295,6 +299,10 @@ namespace clang {
/// \brief Record code for the module build directory.
MODULE_DIRECTORY = 16,
+
+ /// \brief Record code for the list of other AST files made available by
+ /// this AST file but not actually used by it.
+ KNOWN_MODULE_FILES = 17,
};
/// \brief Record types that occur within the input-files block
@@ -385,9 +393,7 @@ namespace clang {
/// \brief Record code for the array of tentative definitions.
TENTATIVE_DEFINITIONS = 9,
- /// \brief Record code for the array of locally-scoped extern "C"
- /// declarations.
- LOCALLY_SCOPED_EXTERN_C_DECLS = 10,
+ // ID 10 used to be for a list of extern "C" declarations.
/// \brief Record code for the table of offsets into the
/// Objective-C method pool.
@@ -425,8 +431,7 @@ namespace clang {
/// \brief Record code for the array of VTable uses.
VTABLE_USES = 19,
- /// \brief Record code for the array of dynamic classes.
- DYNAMIC_CLASSES = 20,
+ // ID 20 used to be for a list of dynamic classes.
/// \brief Record code for referenced selector pool.
REFERENCED_SELECTOR_POOL = 21,
@@ -516,8 +521,7 @@ namespace clang {
/// imported by the AST file.
IMPORTED_MODULES = 43,
- /// \brief Record code for the set of merged declarations in an AST file.
- MERGED_DECLARATIONS = 44,
+ // ID 40 used to be a table of merged canonical declarations.
/// \brief Record code for the array of redeclaration chains.
///
@@ -539,9 +543,7 @@ namespace clang {
/// macro definition.
MACRO_OFFSET = 47,
- /// \brief Mapping table from the identifier ID to the offset of the
- /// macro directive history for the identifier.
- MACRO_TABLE = 48,
+ // ID 48 used to be a table of macros.
/// \brief Record code for undefined but used functions and variables that
/// need a definition in this TU.
@@ -555,6 +557,13 @@ namespace clang {
/// \brief Record code for potentially unused local typedef names.
UNUSED_LOCAL_TYPEDEF_NAME_CANDIDATES = 52,
+
+ /// \brief Record code for the table of offsets to CXXCtorInitializers
+ /// lists.
+ CXX_CTOR_INITIALIZERS_OFFSETS = 53,
+
+ /// \brief Delete expressions that will be analyzed later.
+ DELETE_EXPRS_TO_ANALYZE = 54
};
/// \brief Record types used within a source manager block.
@@ -594,7 +603,11 @@ namespace clang {
PP_TOKEN = 3,
/// \brief The macro directives history for a particular identifier.
- PP_MACRO_DIRECTIVE_HISTORY = 4
+ PP_MACRO_DIRECTIVE_HISTORY = 4,
+
+ /// \brief A macro directive exported by a module.
+ /// [PP_MODULE_MACRO, SubmoduleID, MacroID, (Overridden SubmoduleID)*]
+ PP_MODULE_MACRO = 5,
};
/// \brief Record types used within a preprocessor detail block.
@@ -927,14 +940,17 @@ namespace clang {
PREDEF_DECL_OBJC_INSTANCETYPE_ID = 8,
/// \brief The internal '__builtin_va_list' typedef.
- PREDEF_DECL_BUILTIN_VA_LIST_ID = 9
+ PREDEF_DECL_BUILTIN_VA_LIST_ID = 9,
+
+ /// \brief The extern "C" context.
+ PREDEF_DECL_EXTERN_C_CONTEXT_ID = 10,
};
/// \brief The number of declaration IDs that are predefined.
///
/// For more information about predefined declarations, see the
/// \c PredefinedDeclIDs type and the PREDEF_DECL_*_ID constants.
- const unsigned int NUM_PREDEF_DECL_IDS = 10;
+ const unsigned int NUM_PREDEF_DECL_IDS = 11;
/// \brief Record codes for each kind of declaration.
///
@@ -1071,6 +1087,8 @@ namespace clang {
DECL_STATIC_ASSERT,
/// \brief A record containing CXXBaseSpecifiers.
DECL_CXX_BASE_SPECIFIERS,
+ /// \brief A record containing CXXCtorInitializers.
+ DECL_CXX_CTOR_INITIALIZERS,
/// \brief A IndirectFieldDecl record.
DECL_INDIRECTFIELD,
/// \brief A NonTypeTemplateParmDecl record that stores an expanded
@@ -1094,13 +1112,13 @@ namespace clang {
///
/// These constants describe the records that describe statements
/// or expressions. These records occur within type and declarations
- /// block, so they begin with record values of 100. Each constant
+ /// block, so they begin with record values of 128. Each constant
/// describes a record for a specific statement or expression class in the
/// AST.
enum StmtCode {
/// \brief A marker record that indicates that we are at the end
/// of an expression.
- STMT_STOP = 100,
+ STMT_STOP = 128,
/// \brief A NULL expression.
STMT_NULL_PTR,
/// \brief A reference to a previously [de]serialized Stmt record.
diff --git a/include/clang/Serialization/ASTDeserializationListener.h b/include/clang/Serialization/ASTDeserializationListener.h
index c24ccdc..4b10c39 100644
--- a/include/clang/Serialization/ASTDeserializationListener.h
+++ b/include/clang/Serialization/ASTDeserializationListener.h
@@ -23,10 +23,10 @@ namespace clang {
class Decl;
class ASTReader;
class QualType;
-class MacroDefinition;
+class MacroDefinitionRecord;
class MacroInfo;
class Module;
-
+
class ASTDeserializationListener {
public:
virtual ~ASTDeserializationListener();
@@ -46,14 +46,13 @@ public:
/// \brief A decl was deserialized from the AST file.
virtual void DeclRead(serialization::DeclID ID, const Decl *D) { }
/// \brief A selector was read from the AST file.
- virtual void SelectorRead(serialization::SelectorID iD, Selector Sel) { }
+ virtual void SelectorRead(serialization::SelectorID iD, Selector Sel) {}
/// \brief A macro definition was read from the AST file.
- virtual void MacroDefinitionRead(serialization::PreprocessedEntityID,
- MacroDefinition *MD) { }
+ virtual void MacroDefinitionRead(serialization::PreprocessedEntityID,
+ MacroDefinitionRecord *MD) {}
/// \brief A module definition was read from the AST file.
- virtual void ModuleRead(serialization::SubmoduleID ID, Module *Mod) { }
+ virtual void ModuleRead(serialization::SubmoduleID ID, Module *Mod) {}
};
-
}
#endif
diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h
index 91ad34b..c7cc1be 100644
--- a/include/clang/Serialization/ASTReader.h
+++ b/include/clang/Serialization/ASTReader.h
@@ -73,6 +73,7 @@ class GlobalModuleIndex;
class GotoStmt;
class MacroDefinition;
class MacroDirective;
+class ModuleMacro;
class NamedDecl;
class OpaqueValueExpr;
class Preprocessor;
@@ -124,8 +125,8 @@ public:
///
/// \returns true to indicate the target options are invalid, or false
/// otherwise.
- virtual bool ReadTargetOptions(const TargetOptions &TargetOpts,
- bool Complain) {
+ virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
+ bool AllowCompatibleDifferences) {
return false;
}
@@ -153,6 +154,7 @@ public:
/// \returns true to indicate the header search options are invalid, or false
/// otherwise.
virtual bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
+ StringRef SpecificModuleCachePath,
bool Complain) {
return false;
}
@@ -222,14 +224,15 @@ public:
void ReadModuleMapFile(StringRef ModuleMapPath) override;
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
bool AllowCompatibleDifferences) override;
- bool ReadTargetOptions(const TargetOptions &TargetOpts,
- bool Complain) override;
+ bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
+ bool AllowCompatibleDifferences) override;
bool ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts,
bool Complain) override;
bool ReadFileSystemOptions(const FileSystemOptions &FSOpts,
bool Complain) override;
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
+ StringRef SpecificModuleCachePath,
bool Complain) override;
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
bool Complain,
@@ -255,12 +258,15 @@ public:
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
bool AllowCompatibleDifferences) override;
- bool ReadTargetOptions(const TargetOptions &TargetOpts,
- bool Complain) override;
+ bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
+ bool AllowCompatibleDifferences) override;
bool ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts,
bool Complain) override;
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain,
std::string &SuggestedPredefines) override;
+ bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
+ StringRef SpecificModuleCachePath,
+ bool Complain) override;
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override;
private:
@@ -435,6 +441,18 @@ private:
llvm::SmallVector<std::pair<serialization::GlobalDeclID, Decl*>, 16>
PendingUpdateRecords;
+ enum class PendingFakeDefinitionKind { NotFake, Fake, FakeLoaded };
+
+ /// \brief The DefinitionData pointers that we faked up for class definitions
+ /// that we needed but hadn't loaded yet.
+ llvm::DenseMap<void *, PendingFakeDefinitionKind> PendingFakeDefinitionData;
+
+ /// \brief Exception specification updates that have been loaded but not yet
+ /// propagated across the relevant redeclaration chain. The map key is the
+ /// canonical declaration (used only for deduplication) and the value is a
+ /// declaration that has an exception specification.
+ llvm::SmallMapVector<Decl *, FunctionDecl *, 4> PendingExceptionSpecUpdates;
+
struct ReplacedDeclInfo {
ModuleFile *Mod;
uint64_t Offset;
@@ -498,6 +516,10 @@ private:
/// \brief Functions or methods that have bodies that will be attached.
PendingBodiesMap PendingBodies;
+ /// \brief Definitions for which we have added merged definitions but not yet
+ /// performed deduplication.
+ llvm::SetVector<NamedDecl*> PendingMergedDefinitionsToDeduplicate;
+
/// \brief Read the records that describe the contents of declcontexts.
bool ReadDeclContextStorage(ModuleFile &M,
llvm::BitstreamCursor &Cursor,
@@ -528,6 +550,14 @@ private:
/// been loaded.
std::vector<MacroInfo *> MacrosLoaded;
+ typedef std::pair<IdentifierInfo *, serialization::SubmoduleID>
+ LoadedMacroInfo;
+
+ /// \brief A set of #undef directives that we have loaded; used to
+ /// deduplicate the same #undef information coming from multiple module
+ /// files.
+ llvm::DenseSet<LoadedMacroInfo> LoadedUndefs;
+
typedef ContinuousRangeMap<serialization::MacroID, ModuleFile *, 4>
GlobalMacroMapType;
@@ -550,54 +580,8 @@ private:
/// global submodule ID to produce a local ID.
GlobalSubmoduleMapType GlobalSubmoduleMap;
- /// \brief Information on a macro definition or undefinition that is visible
- /// at the end of a submodule.
- struct ModuleMacroInfo;
-
- /// \brief An entity that has been hidden.
- class HiddenName {
- public:
- enum NameKind {
- Declaration,
- Macro
- } Kind;
-
- private:
- union {
- Decl *D;
- ModuleMacroInfo *MMI;
- };
-
- IdentifierInfo *Id;
-
- public:
- HiddenName(Decl *D) : Kind(Declaration), D(D), Id() { }
-
- HiddenName(IdentifierInfo *II, ModuleMacroInfo *MMI)
- : Kind(Macro), MMI(MMI), Id(II) { }
-
- NameKind getKind() const { return Kind; }
-
- Decl *getDecl() const {
- assert(getKind() == Declaration && "Hidden name is not a declaration");
- return D;
- }
-
- std::pair<IdentifierInfo *, ModuleMacroInfo *> getMacro() const {
- assert(getKind() == Macro && "Hidden name is not a macro!");
- return std::make_pair(Id, MMI);
- }
- };
-
- typedef llvm::SmallDenseMap<IdentifierInfo*,
- ModuleMacroInfo*> HiddenMacrosMap;
-
/// \brief A set of hidden declarations.
- struct HiddenNames {
- SmallVector<Decl*, 2> HiddenDecls;
- HiddenMacrosMap HiddenMacros;
- };
-
+ typedef SmallVector<Decl*, 2> HiddenNames;
typedef llvm::DenseMap<Module *, HiddenNames> HiddenNamesMapType;
/// \brief A mapping from each of the hidden submodules to the deserialized
@@ -651,30 +635,10 @@ private:
struct PendingMacroInfo {
ModuleFile *M;
+ uint64_t MacroDirectivesOffset;
- struct ModuleMacroDataTy {
- uint32_t MacID;
- serialization::SubmoduleID *Overrides;
- };
- struct PCHMacroDataTy {
- uint64_t MacroDirectivesOffset;
- };
-
- union {
- ModuleMacroDataTy ModuleMacroData;
- PCHMacroDataTy PCHMacroData;
- };
-
- PendingMacroInfo(ModuleFile *M,
- uint32_t MacID,
- serialization::SubmoduleID *Overrides) : M(M) {
- ModuleMacroData.MacID = MacID;
- ModuleMacroData.Overrides = Overrides;
- }
-
- PendingMacroInfo(ModuleFile *M, uint64_t MacroDirectivesOffset) : M(M) {
- PCHMacroData.MacroDirectivesOffset = MacroDirectivesOffset;
- }
+ PendingMacroInfo(ModuleFile *M, uint64_t MacroDirectivesOffset)
+ : M(M), MacroDirectivesOffset(MacroDirectivesOffset) {}
};
typedef llvm::MapVector<IdentifierInfo *, SmallVector<PendingMacroInfo, 2> >
@@ -759,18 +723,6 @@ private:
/// \brief Fields containing data that is used for semantic analysis
//@{
- /// \brief The IDs of all locally scoped extern "C" decls in the chain.
- ///
- /// Sema tracks these to validate that the types are consistent across all
- /// local extern "C" declarations.
- SmallVector<uint64_t, 16> LocallyScopedExternCDecls;
-
- /// \brief The IDs of all dynamic class declarations in the chain.
- ///
- /// Sema tracks these because it checks for the key functions being defined
- /// at the end of the TU, in which case it directs CodeGen to emit the VTable.
- SmallVector<uint64_t, 16> DynamicClasses;
-
/// \brief The IDs of all potentially unused typedef names in the chain.
///
/// Sema tracks these to emit warnings.
@@ -808,6 +760,9 @@ private:
/// SourceLocation of a matching ODR-use.
SmallVector<uint64_t, 8> UndefinedButUsed;
+ /// \brief Delete expressions to analyze at the end of translation unit.
+ SmallVector<uint64_t, 8> DelayedDeleteExprs;
+
// \brief A list of late parsed template function data.
SmallVector<uint64_t, 1> LateParsedTemplates;
@@ -930,9 +885,6 @@ private:
/// passing decls to consumer.
bool PassingDeclsToConsumer;
- /// Number of CXX base specifiers currently loaded
- unsigned NumCXXBaseSpecifiersLoaded;
-
/// \brief The set of identifiers that were read while the AST reader was
/// (recursively) loading declarations.
///
@@ -941,6 +893,11 @@ private:
llvm::MapVector<IdentifierInfo *, SmallVector<uint32_t, 4> >
PendingIdentifierInfos;
+ /// \brief The set of lookup results that we have faked in order to support
+ /// merging of partially deserialized decls but that we have not yet removed.
+ llvm::SmallMapVector<IdentifierInfo *, SmallVector<NamedDecl*, 2>, 16>
+ PendingFakeLookupResults;
+
/// \brief The generation number of each identifier, which keeps track of
/// the last time we loaded information about this identifier.
llvm::DenseMap<IdentifierInfo *, unsigned> IdentifierGeneration;
@@ -960,13 +917,13 @@ private:
/// \brief The list of redeclaration chains that still need to be
/// reconstructed.
///
- /// Each element is the global declaration ID of the first declaration in
- /// the chain. Elements in this vector should be unique; use
+ /// Each element is the canonical declaration of the chain.
+ /// Elements in this vector should be unique; use
/// PendingDeclChainsKnown to ensure uniqueness.
- SmallVector<serialization::DeclID, 16> PendingDeclChains;
+ SmallVector<Decl *, 16> PendingDeclChains;
/// \brief Keeps track of the elements added to PendingDeclChains.
- llvm::SmallSet<serialization::DeclID, 16> PendingDeclChainsKnown;
+ llvm::SmallSet<Decl *, 16> PendingDeclChainsKnown;
/// \brief The list of canonical declarations whose redeclaration chains
/// need to be marked as incomplete once we're done deserializing things.
@@ -1026,26 +983,6 @@ private:
/// that canonical declaration.
MergedDeclsMap MergedDecls;
- typedef llvm::DenseMap<serialization::GlobalDeclID,
- SmallVector<serialization::DeclID, 2> >
- StoredMergedDeclsMap;
-
- /// \brief A mapping from canonical declaration IDs to the set of additional
- /// declaration IDs that have been merged with that canonical declaration.
- ///
- /// This is the deserialized representation of the entries in MergedDecls.
- /// When we query entries in MergedDecls, they will be augmented with entries
- /// from StoredMergedDecls.
- StoredMergedDeclsMap StoredMergedDecls;
-
- /// \brief Combine the stored merged declarations for the given canonical
- /// declaration into the set of merged declarations.
- ///
- /// \returns An iterator into MergedDecls that corresponds to the position of
- /// the given canonical declaration.
- MergedDeclsMap::iterator
- combineStoredMergedDecls(Decl *Canon, serialization::GlobalDeclID CanonID);
-
/// \brief A mapping from DeclContexts to the semantic DeclContext that we
/// are treating as the definition of the entity. This is used, for instance,
/// when merging implicit instantiations of class templates across modules.
@@ -1071,8 +1008,8 @@ private:
ASTReader &Reader;
enum ReadingKind PrevKind;
- ReadingKindTracker(const ReadingKindTracker &) LLVM_DELETED_FUNCTION;
- void operator=(const ReadingKindTracker &) LLVM_DELETED_FUNCTION;
+ ReadingKindTracker(const ReadingKindTracker &) = delete;
+ void operator=(const ReadingKindTracker &) = delete;
public:
ReadingKindTracker(enum ReadingKind newKind, ASTReader &reader)
@@ -1153,7 +1090,8 @@ private:
ASTReaderListener &Listener,
bool AllowCompatibleDifferences);
static bool ParseTargetOptions(const RecordData &Record, bool Complain,
- ASTReaderListener &Listener);
+ ASTReaderListener &Listener,
+ bool AllowCompatibleDifferences);
static bool ParseDiagnosticOptions(const RecordData &Record, bool Complain,
ASTReaderListener &Listener);
static bool ParseFileSystemOptions(const RecordData &Record, bool Complain,
@@ -1180,10 +1118,28 @@ private:
void LoadedDecl(unsigned Index, Decl *D);
Decl *ReadDeclRecord(serialization::DeclID ID);
void markIncompleteDeclChain(Decl *Canon);
+
+ /// \brief Returns the most recent declaration of a declaration (which must be
+ /// of a redeclarable kind) that is either local or has already been loaded
+ /// merged into its redecl chain.
+ Decl *getMostRecentExistingDecl(Decl *D);
+
+ template <typename Fn>
+ void forEachFormerlyCanonicalImportedDecl(const Decl *D, Fn Visit) {
+ D = D->getCanonicalDecl();
+ if (D->isFromASTFile())
+ Visit(D);
+
+ auto It = MergedDecls.find(const_cast<Decl*>(D));
+ if (It != MergedDecls.end())
+ for (auto ID : It->second)
+ Visit(GetExistingDecl(ID));
+ }
+
RecordLocation DeclCursorForID(serialization::DeclID ID,
unsigned &RawLocation);
void loadDeclUpdateRecords(serialization::DeclID ID, Decl *D);
- void loadPendingDeclChain(serialization::GlobalDeclID ID);
+ void loadPendingDeclChain(Decl *D);
void loadObjCCategories(serialization::GlobalDeclID ID, ObjCInterfaceDecl *D,
unsigned PreviousGeneration = 0);
@@ -1212,66 +1168,38 @@ private:
/// \brief Returns (begin, end) pair for the preprocessed entities of a
/// particular module.
- std::pair<PreprocessingRecord::iterator, PreprocessingRecord::iterator>
- getModulePreprocessedEntities(ModuleFile &Mod) const;
-
- class ModuleDeclIterator {
+ llvm::iterator_range<PreprocessingRecord::iterator>
+ getModulePreprocessedEntities(ModuleFile &Mod) const;
+
+ class ModuleDeclIterator
+ : public llvm::iterator_adaptor_base<
+ ModuleDeclIterator, const serialization::LocalDeclID *,
+ std::random_access_iterator_tag, const Decl *, ptrdiff_t,
+ const Decl *, const Decl *> {
ASTReader *Reader;
ModuleFile *Mod;
- const serialization::LocalDeclID *Pos;
public:
- typedef const Decl *value_type;
- typedef value_type& reference;
- typedef value_type* pointer;
-
- ModuleDeclIterator() : Reader(nullptr), Mod(nullptr), Pos(nullptr) { }
+ ModuleDeclIterator()
+ : iterator_adaptor_base(nullptr), Reader(nullptr), Mod(nullptr) {}
ModuleDeclIterator(ASTReader *Reader, ModuleFile *Mod,
const serialization::LocalDeclID *Pos)
- : Reader(Reader), Mod(Mod), Pos(Pos) { }
+ : iterator_adaptor_base(Pos), Reader(Reader), Mod(Mod) {}
value_type operator*() const {
- return Reader->GetDecl(Reader->getGlobalDeclID(*Mod, *Pos));
+ return Reader->GetDecl(Reader->getGlobalDeclID(*Mod, *I));
}
+ value_type operator->() const { return **this; }
- ModuleDeclIterator &operator++() {
- ++Pos;
- return *this;
- }
-
- ModuleDeclIterator operator++(int) {
- ModuleDeclIterator Prev(*this);
- ++Pos;
- return Prev;
- }
-
- ModuleDeclIterator &operator--() {
- --Pos;
- return *this;
- }
-
- ModuleDeclIterator operator--(int) {
- ModuleDeclIterator Prev(*this);
- --Pos;
- return Prev;
- }
-
- friend bool operator==(const ModuleDeclIterator &LHS,
- const ModuleDeclIterator &RHS) {
- assert(LHS.Reader == RHS.Reader && LHS.Mod == RHS.Mod);
- return LHS.Pos == RHS.Pos;
- }
-
- friend bool operator!=(const ModuleDeclIterator &LHS,
- const ModuleDeclIterator &RHS) {
- assert(LHS.Reader == RHS.Reader && LHS.Mod == RHS.Mod);
- return LHS.Pos != RHS.Pos;
+ bool operator==(const ModuleDeclIterator &RHS) const {
+ assert(Reader == RHS.Reader && Mod == RHS.Mod);
+ return I == RHS.I;
}
};
- std::pair<ModuleDeclIterator, ModuleDeclIterator>
- getModuleFileLevelDecls(ModuleFile &Mod);
+ llvm::iterator_range<ModuleDeclIterator>
+ getModuleFileLevelDecls(ModuleFile &Mod);
void PassInterestingDeclsToConsumer();
void PassInterestingDeclToConsumer(Decl *D);
@@ -1297,8 +1225,8 @@ private:
void Error(unsigned DiagID, StringRef Arg1 = StringRef(),
StringRef Arg2 = StringRef());
- ASTReader(const ASTReader &) LLVM_DELETED_FUNCTION;
- void operator=(const ASTReader &) LLVM_DELETED_FUNCTION;
+ ASTReader(const ASTReader &) = delete;
+ void operator=(const ASTReader &) = delete;
public:
/// \brief Load the AST file and validate its contents against the given
/// Preprocessor.
@@ -1337,7 +1265,7 @@ public:
bool ValidateSystemInputs = false,
bool UseGlobalIndex = true);
- ~ASTReader();
+ ~ASTReader() override;
SourceManager &getSourceManager() const { return SourceMgr; }
FileManager &getFileManager() const { return FileMgr; }
@@ -1391,16 +1319,12 @@ public:
/// module. Visibility can only be increased over time.
///
/// \param ImportLoc The location at which the import occurs.
- ///
- /// \param Complain Whether to complain about conflicting module imports.
void makeModuleVisible(Module *Mod,
Module::NameVisibilityKind NameVisibility,
- SourceLocation ImportLoc,
- bool Complain);
+ SourceLocation ImportLoc);
/// \brief Make the names within this set of hidden names visible.
- void makeNamesVisible(const HiddenNames &Names, Module *Owner,
- bool FromFinalization);
+ void makeNamesVisible(const HiddenNames &Names, Module *Owner);
/// \brief Take the AST callbacks listener.
std::unique_ptr<ASTReaderListener> takeListener() {
@@ -1518,7 +1442,8 @@ public:
FileManager &FileMgr,
const LangOptions &LangOpts,
const TargetOptions &TargetOpts,
- const PreprocessorOptions &PPOpts);
+ const PreprocessorOptions &PPOpts,
+ std::string ExistingModuleCachePath);
/// \brief Returns the suggested contents of the predefines buffer,
/// which contains a (typically-empty) subset of the predefines
@@ -1593,11 +1518,6 @@ public:
return Result;
}
- /// \brief Returns the number of C++ base specifiers found in the chain.
- unsigned getTotalNumCXXBaseSpecifiers() const {
- return NumCXXBaseSpecifiersLoaded;
- }
-
/// \brief Reads a TemplateArgumentLocInfo appropriate for the
/// given TemplateArgument kind.
TemplateArgumentLocInfo
@@ -1823,6 +1743,10 @@ public:
void ReadUndefinedButUsed(
llvm::DenseMap<NamedDecl *, SourceLocation> &Undefined) override;
+ void ReadMismatchingDeleteExpressions(llvm::MapVector<
+ FieldDecl *, llvm::SmallVector<std::pair<SourceLocation, bool>, 4>> &
+ Exprs) override;
+
void ReadTentativeDefinitions(
SmallVectorImpl<VarDecl *> &TentativeDefs) override;
@@ -1834,14 +1758,9 @@ public:
void ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl *> &Decls) override;
- void ReadDynamicClasses(SmallVectorImpl<CXXRecordDecl *> &Decls) override;
-
void ReadUnusedLocalTypedefNameCandidates(
llvm::SmallSetVector<const TypedefNameDecl *, 4> &Decls) override;
- void ReadLocallyScopedExternCDecls(
- SmallVectorImpl<NamedDecl *> &Decls) override;
-
void ReadReferencedSelectors(
SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) override;
@@ -1855,8 +1774,8 @@ public:
SourceLocation> > &Pending) override;
void ReadLateParsedTemplates(
- llvm::DenseMap<const FunctionDecl *,
- LateParsedTemplate *> &LPTMap) override;
+ llvm::MapVector<const FunctionDecl *, LateParsedTemplate *> &LPTMap)
+ override;
/// \brief Load a selector from disk, registering its ID if it exists.
void LoadSelector(Selector Sel);
@@ -1891,28 +1810,8 @@ public:
serialization::IdentifierID getGlobalIdentifierID(ModuleFile &M,
unsigned LocalID);
- ModuleMacroInfo *getModuleMacro(const PendingMacroInfo &PMInfo);
-
void resolvePendingMacro(IdentifierInfo *II, const PendingMacroInfo &PMInfo);
- void installPCHMacroDirectives(IdentifierInfo *II,
- ModuleFile &M, uint64_t Offset);
-
- void installImportedMacro(IdentifierInfo *II, ModuleMacroInfo *MMI,
- Module *Owner);
-
- typedef llvm::TinyPtrVector<DefMacroDirective *> AmbiguousMacros;
- llvm::DenseMap<IdentifierInfo*, AmbiguousMacros> AmbiguousMacroDefs;
-
- void
- removeOverriddenMacros(IdentifierInfo *II, SourceLocation Loc,
- AmbiguousMacros &Ambig,
- ArrayRef<serialization::SubmoduleID> Overrides);
-
- AmbiguousMacros *
- removeOverriddenMacros(IdentifierInfo *II, SourceLocation Loc,
- ArrayRef<serialization::SubmoduleID> Overrides);
-
/// \brief Retrieve the macro with the given ID.
MacroInfo *getMacro(serialization::MacroID ID);
@@ -2007,10 +1906,18 @@ public:
const RecordData &Record,unsigned &Idx);
/// \brief Read a CXXCtorInitializer array.
- std::pair<CXXCtorInitializer **, unsigned>
+ CXXCtorInitializer **
ReadCXXCtorInitializers(ModuleFile &F, const RecordData &Record,
unsigned &Idx);
+ /// \brief Read a CXXCtorInitializers ID from the given record and
+ /// return its global bit offset.
+ uint64_t ReadCXXCtorInitializersRef(ModuleFile &M, const RecordData &Record,
+ unsigned &Idx);
+
+ /// \brief Read the contents of a CXXCtorInitializer array.
+ CXXCtorInitializer **GetExternalCXXCtorInitializers(uint64_t Offset) override;
+
/// \brief Read a source location from raw form.
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, unsigned Raw) const {
SourceLocation Loc = SourceLocation::getFromRawEncoding(Raw);
@@ -2087,24 +1994,14 @@ public:
serialization::PreprocessedEntityID
getGlobalPreprocessedEntityID(ModuleFile &M, unsigned LocalID) const;
- /// \brief Add a macro to resolve imported from a module.
- ///
- /// \param II The name of the macro.
- /// \param M The module file.
- /// \param GMacID The global macro ID that is associated with this identifier.
- void addPendingMacroFromModule(IdentifierInfo *II,
- ModuleFile *M,
- serialization::GlobalMacroID GMacID,
- ArrayRef<serialization::SubmoduleID>);
-
- /// \brief Add a macro to deserialize its macro directive history from a PCH.
+ /// \brief Add a macro to deserialize its macro directive history.
///
/// \param II The name of the macro.
/// \param M The module file.
/// \param MacroDirectivesOffset Offset of the serialized macro directive
/// history.
- void addPendingMacroFromPCH(IdentifierInfo *II,
- ModuleFile *M, uint64_t MacroDirectivesOffset);
+ void addPendingMacro(IdentifierInfo *II, ModuleFile *M,
+ uint64_t MacroDirectivesOffset);
/// \brief Read the set of macros defined by this external macro source.
void ReadDefinedMacros() override;
diff --git a/include/clang/Serialization/ASTWriter.h b/include/clang/Serialization/ASTWriter.h
index 9907fae..297ee22 100644
--- a/include/clang/Serialization/ASTWriter.h
+++ b/include/clang/Serialization/ASTWriter.h
@@ -49,7 +49,7 @@ class FPOptions;
class HeaderSearch;
class HeaderSearchOptions;
class IdentifierResolver;
-class MacroDefinition;
+class MacroDefinitionRecord;
class MacroDirective;
class MacroInfo;
class OpaqueValueExpr;
@@ -61,6 +61,7 @@ class PreprocessingRecord;
class Preprocessor;
class Sema;
class SourceManager;
+struct StoredDeclsList;
class SwitchCase;
class TargetInfo;
class Token;
@@ -225,7 +226,7 @@ private:
/// The ID numbers for identifiers are consecutive (in order of
/// discovery), starting at 1. An ID of zero refers to a NULL
/// IdentifierInfo.
- llvm::DenseMap<const IdentifierInfo *, serialization::IdentID> IdentifierIDs;
+ llvm::MapVector<const IdentifierInfo *, serialization::IdentID> IdentifierIDs;
/// \brief The first ID number we can use for our own macros.
serialization::MacroID FirstMacroID;
@@ -275,7 +276,7 @@ private:
serialization::SelectorID NextSelectorID;
/// \brief Map that provides the ID numbers of each Selector.
- llvm::DenseMap<Selector, serialization::SelectorID> SelectorIDs;
+ llvm::MapVector<Selector, serialization::SelectorID> SelectorIDs;
/// \brief Offset of each selector within the method pool/selector
/// table, indexed by the Selector ID (-1).
@@ -283,8 +284,8 @@ private:
/// \brief Mapping from macro definitions (as they occur in the preprocessing
/// record) to the macro IDs.
- llvm::DenseMap<const MacroDefinition *, serialization::PreprocessedEntityID>
- MacroDefinitions;
+ llvm::DenseMap<const MacroDefinitionRecord *,
+ serialization::PreprocessedEntityID> MacroDefinitions;
/// \brief Cache of indices of anonymous declarations within their lexical
/// contexts.
@@ -299,6 +300,7 @@ private:
void *Type;
unsigned Loc;
unsigned Val;
+ Module *Mod;
};
public:
@@ -310,6 +312,8 @@ private:
: Kind(Kind), Loc(Loc.getRawEncoding()) {}
DeclUpdate(unsigned Kind, unsigned Val)
: Kind(Kind), Val(Val) {}
+ DeclUpdate(unsigned Kind, Module *M)
+ : Kind(Kind), Mod(M) {}
unsigned getKind() const { return Kind; }
const Decl *getDecl() const { return Dcl; }
@@ -318,10 +322,11 @@ private:
return SourceLocation::getFromRawEncoding(Loc);
}
unsigned getNumber() const { return Val; }
+ Module *getModule() const { return Mod; }
};
typedef SmallVector<DeclUpdate, 1> UpdateRecord;
- typedef llvm::DenseMap<const Decl *, UpdateRecord> DeclUpdateMap;
+ typedef llvm::MapVector<const Decl *, UpdateRecord> DeclUpdateMap;
/// \brief Mapping from declarations that came from a chained PCH to the
/// record containing modifications to them.
DeclUpdateMap DeclUpdates;
@@ -351,13 +356,13 @@ private:
/// if its primary namespace comes from the chain. If it does, we add the
/// primary to this set, so that we can write out lexical content updates for
/// it.
- llvm::SmallPtrSet<const DeclContext *, 16> UpdatedDeclContexts;
+ llvm::SmallSetVector<const DeclContext *, 16> UpdatedDeclContexts;
/// \brief Keeps track of visible decls that were added in DeclContexts
/// coming from another AST file.
SmallVector<const Decl *, 16> UpdatingVisibleDecls;
- typedef llvm::SmallPtrSet<const Decl *, 16> DeclsToRewriteTy;
+ typedef llvm::SmallSetVector<const Decl *, 16> DeclsToRewriteTy;
/// \brief Decls that will be replaced in the current dependent AST file.
DeclsToRewriteTy DeclsToRewrite;
@@ -386,8 +391,7 @@ private:
/// \brief The set of declarations that may have redeclaration chains that
/// need to be serialized.
- llvm::SetVector<Decl *, SmallVector<Decl *, 4>,
- llvm::SmallPtrSet<Decl *, 4> > Redeclarations;
+ llvm::SmallSetVector<Decl *, 4> Redeclarations;
/// \brief Statements that we've encountered while serializing a
/// declaration or type.
@@ -415,7 +419,7 @@ private:
unsigned NumVisibleDeclContexts;
/// \brief The offset of each CXXBaseSpecifier set within the AST.
- SmallVector<uint32_t, 4> CXXBaseSpecifiersOffsets;
+ SmallVector<uint32_t, 16> CXXBaseSpecifiersOffsets;
/// \brief The first ID number we can use for our own base specifiers.
serialization::CXXBaseSpecifiersID FirstCXXBaseSpecifiersID;
@@ -443,6 +447,33 @@ private:
/// in the order they should be written.
SmallVector<QueuedCXXBaseSpecifiers, 2> CXXBaseSpecifiersToWrite;
+ /// \brief The offset of each CXXCtorInitializer list within the AST.
+ SmallVector<uint32_t, 16> CXXCtorInitializersOffsets;
+
+ /// \brief The first ID number we can use for our own ctor initializers.
+ serialization::CXXCtorInitializersID FirstCXXCtorInitializersID;
+
+ /// \brief The ctor initializers ID that will be assigned to the next new
+ /// list of C++ ctor initializers.
+ serialization::CXXCtorInitializersID NextCXXCtorInitializersID;
+
+ /// \brief A set of C++ ctor initializers that is queued to be written
+ /// into the AST file.
+ struct QueuedCXXCtorInitializers {
+ QueuedCXXCtorInitializers() : ID() {}
+
+ QueuedCXXCtorInitializers(serialization::CXXCtorInitializersID ID,
+ ArrayRef<CXXCtorInitializer*> Inits)
+ : ID(ID), Inits(Inits) {}
+
+ serialization::CXXCtorInitializersID ID;
+ ArrayRef<CXXCtorInitializer*> Inits;
+ };
+
+ /// \brief Queue of C++ ctor initializers to be written to the AST file,
+ /// in the order they should be written.
+ SmallVector<QueuedCXXCtorInitializers, 2> CXXCtorInitializersToWrite;
+
/// \brief A mapping from each known submodule to its ID number, which will
/// be a positive integer.
llvm::DenseMap<Module *, unsigned> SubmoduleIDs;
@@ -471,12 +502,16 @@ private:
void WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag,
bool isModule);
void WriteCXXBaseSpecifiersOffsets();
+ void WriteCXXCtorInitializersOffsets();
unsigned TypeExtQualAbbrev;
unsigned TypeFunctionProtoAbbrev;
void WriteTypeAbbrevs();
void WriteType(QualType T);
+ bool isLookupResultExternal(StoredDeclsList &Result, DeclContext *DC);
+ bool isLookupResultEntirelyExternal(StoredDeclsList &Result, DeclContext *DC);
+
uint32_t GenerateNameLookupTable(const DeclContext *DC,
llvm::SmallVectorImpl<char> &LookupTable);
uint64_t WriteDeclContextLexicalBlock(ASTContext &Context, DeclContext *DC);
@@ -496,7 +531,6 @@ private:
void WriteOpenCLExtensions(Sema &SemaRef);
void WriteObjCCategories();
void WriteRedeclarations();
- void WriteMergedDecls();
void WriteLateParsedTemplates(Sema &SemaRef);
void WriteOptimizePragmaOptions(Sema &SemaRef);
@@ -529,7 +563,9 @@ public:
/// \brief Create a new precompiled header writer that outputs to
/// the given bitstream.
ASTWriter(llvm::BitstreamWriter &Stream);
- ~ASTWriter();
+ ~ASTWriter() override;
+
+ const LangOptions &getLangOpts() const;
/// \brief Write a precompiled header for the given semantic analysis.
///
@@ -602,12 +638,6 @@ public:
/// \brief Determine the type ID of an already-emitted type.
serialization::TypeID getTypeID(QualType T) const;
- /// \brief Force a type to be emitted and get its index.
- serialization::TypeIdx GetOrCreateTypeIdx( QualType T);
-
- /// \brief Determine the type index of an already-emitted type.
- serialization::TypeIdx getTypeIdx(QualType T) const;
-
/// \brief Emits a reference to a declarator info.
void AddTypeSourceInfo(TypeSourceInfo *TInfo, RecordDataImpl &Record);
@@ -677,6 +707,11 @@ public:
void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base,
RecordDataImpl &Record);
+ /// \brief Emit the ID for a CXXCtorInitializer array and register the array
+ /// for later serialization.
+ void AddCXXCtorInitializersRef(ArrayRef<CXXCtorInitializer *> Inits,
+ RecordDataImpl &Record);
+
/// \brief Emit a CXXCtorInitializer array.
void AddCXXCtorInitializers(
const CXXCtorInitializer * const *CtorInitializers,
@@ -702,9 +737,6 @@ public:
/// \brief Add a version tuple to the given record
void AddVersionTuple(const VersionTuple &Version, RecordDataImpl &Record);
- /// \brief Mark a declaration context as needing an update.
- void AddUpdatedDeclContext(const DeclContext *DC);
-
void RewriteDecl(const Decl *D) {
DeclsToRewrite.insert(D);
}
@@ -749,6 +781,18 @@ public:
/// via \c AddCXXBaseSpecifiersRef().
void FlushCXXBaseSpecifiers();
+ /// \brief Flush all of the C++ constructor initializer lists that have been
+ /// added via \c AddCXXCtorInitializersRef().
+ void FlushCXXCtorInitializers();
+
+ /// \brief Flush all pending records that are tacked onto the end of
+ /// decl and decl update records.
+ void FlushPendingAfterDecl() {
+ FlushStmts();
+ FlushCXXBaseSpecifiers();
+ FlushCXXCtorInitializers();
+ }
+
/// \brief Record an ID for the given switch-case statement.
unsigned RecordSwitchCaseID(SwitchCase *S);
@@ -787,7 +831,7 @@ public:
void TypeRead(serialization::TypeIdx Idx, QualType T) override;
void SelectorRead(serialization::SelectorID ID, Selector Sel) override;
void MacroDefinitionRead(serialization::PreprocessedEntityID ID,
- MacroDefinition *MD) override;
+ MacroDefinitionRecord *MD) override;
void ModuleRead(serialization::SubmoduleID ID, Module *Mod) override;
// ASTMutationListener implementation.
@@ -802,6 +846,8 @@ public:
const FunctionDecl *D) override;
void ResolvedExceptionSpec(const FunctionDecl *FD) override;
void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType) override;
+ void ResolvedOperatorDelete(const CXXDestructorDecl *DD,
+ const FunctionDecl *Delete) override;
void CompletedImplicitDefinition(const FunctionDecl *D) override;
void StaticDataMemberInstantiated(const VarDecl *D) override;
void FunctionDefinitionInstantiated(const FunctionDecl *D) override;
@@ -812,6 +858,7 @@ public:
const ObjCCategoryDecl *ClassExt) override;
void DeclarationMarkedUsed(const Decl *D) override;
void DeclarationMarkedOpenMPThreadPrivate(const Decl *D) override;
+ void RedefinedHiddenDefinition(const NamedDecl *D, Module *M) override;
};
/// \brief AST and semantic-analysis consumer that generates a
@@ -838,7 +885,7 @@ public:
clang::Module *Module,
StringRef isysroot, raw_ostream *Out,
bool AllowASTWithErrors = false);
- ~PCHGenerator();
+ ~PCHGenerator() override;
void InitializeSema(Sema &S) override { SemaPtr = &S; }
void HandleTranslationUnit(ASTContext &Ctx) override;
ASTMutationListener *GetASTMutationListener() override;
diff --git a/include/clang/Serialization/ContinuousRangeMap.h b/include/clang/Serialization/ContinuousRangeMap.h
index 5f8ae1f..244b01b 100644
--- a/include/clang/Serialization/ContinuousRangeMap.h
+++ b/include/clang/Serialization/ContinuousRangeMap.h
@@ -109,8 +109,8 @@ public:
class Builder {
ContinuousRangeMap &Self;
- Builder(const Builder&) LLVM_DELETED_FUNCTION;
- Builder &operator=(const Builder&) LLVM_DELETED_FUNCTION;
+ Builder(const Builder&) = delete;
+ Builder &operator=(const Builder&) = delete;
public:
explicit Builder(ContinuousRangeMap &Self) : Self(Self) { }
diff --git a/include/clang/Serialization/GlobalModuleIndex.h b/include/clang/Serialization/GlobalModuleIndex.h
index d8a57be..640c7bb 100644
--- a/include/clang/Serialization/GlobalModuleIndex.h
+++ b/include/clang/Serialization/GlobalModuleIndex.h
@@ -118,8 +118,8 @@ class GlobalModuleIndex {
explicit GlobalModuleIndex(std::unique_ptr<llvm::MemoryBuffer> Buffer,
llvm::BitstreamCursor Cursor);
- GlobalModuleIndex(const GlobalModuleIndex &) LLVM_DELETED_FUNCTION;
- GlobalModuleIndex &operator=(const GlobalModuleIndex &) LLVM_DELETED_FUNCTION;
+ GlobalModuleIndex(const GlobalModuleIndex &) = delete;
+ GlobalModuleIndex &operator=(const GlobalModuleIndex &) = delete;
public:
~GlobalModuleIndex();
diff --git a/include/clang/Serialization/Module.h b/include/clang/Serialization/Module.h
index 426cec5..5571d91 100644
--- a/include/clang/Serialization/Module.h
+++ b/include/clang/Serialization/Module.h
@@ -206,7 +206,7 @@ public:
llvm::BitstreamCursor InputFilesCursor;
/// \brief Offsets for all of the input file entries in the AST file.
- const uint32_t *InputFileOffsets;
+ const uint64_t *InputFileOffsets;
/// \brief The input files that have been loaded from this AST file.
std::vector<InputFile> InputFilesLoaded;
@@ -404,6 +404,13 @@ public:
/// indexed by the C++ base specifier set ID (-1).
const uint32_t *CXXBaseSpecifiersOffsets;
+ /// \brief The number of C++ ctor initializer lists in this AST file.
+ unsigned LocalNumCXXCtorInitializers;
+
+ /// \brief Offset of each C++ ctor initializer list within the bitstream,
+ /// indexed by the C++ ctor initializer list ID minus 1.
+ const uint32_t *CXXCtorInitializersOffsets;
+
typedef llvm::DenseMap<const DeclContext *, DeclContextInfo>
DeclContextInfosMap;
diff --git a/include/clang/Serialization/ModuleManager.h b/include/clang/Serialization/ModuleManager.h
index 3d10fad..3de86fe 100644
--- a/include/clang/Serialization/ModuleManager.h
+++ b/include/clang/Serialization/ModuleManager.h
@@ -32,10 +32,20 @@ class ModuleManager {
/// \brief The chain of AST files. The first entry is the one named by the
/// user, the last one is the one that doesn't depend on anything further.
SmallVector<ModuleFile *, 2> Chain;
+
+ // \brief The roots of the dependency DAG of AST files. This is used
+ // to implement short-circuiting logic when running DFS over the dependencies.
+ SmallVector<ModuleFile *, 2> Roots;
/// \brief All loaded modules, indexed by name.
llvm::DenseMap<const FileEntry *, ModuleFile *> Modules;
-
+
+ typedef llvm::SetVector<const FileEntry *> AdditionalKnownModuleFileSet;
+
+ /// \brief Additional module files that are known but not loaded. Tracked
+ /// here so that we can re-export them if necessary.
+ AdditionalKnownModuleFileSet AdditionalKnownModuleFiles;
+
/// \brief FileManager that handles translating between filenames and
/// FileEntry *.
FileManager &FileMgr;
@@ -159,6 +169,8 @@ public:
OutOfDate
};
+ typedef ASTFileSignature(*ASTFileSignatureReader)(llvm::BitstreamReader &);
+
/// \brief Attempts to create a new module and add it to the list of known
/// modules.
///
@@ -198,8 +210,7 @@ public:
ModuleFile *ImportedBy, unsigned Generation,
off_t ExpectedSize, time_t ExpectedModTime,
ASTFileSignature ExpectedSignature,
- std::function<ASTFileSignature(llvm::BitstreamReader &)>
- ReadSignature,
+ ASTFileSignatureReader ReadSignature,
ModuleFile *&Module,
std::string &ErrorStr);
@@ -219,6 +230,19 @@ public:
/// has been "accepted", and will not (can not) be unloaded.
void moduleFileAccepted(ModuleFile *MF);
+ /// \brief Notification from the frontend that the given module file is
+ /// part of this compilation (even if not imported) and, if this compilation
+ /// is exported, should be made available to importers of it.
+ bool addKnownModuleFile(StringRef FileName);
+
+ /// \brief Get a list of additional module files that are not currently
+ /// loaded but are considered to be part of the current compilation.
+ llvm::iterator_range<AdditionalKnownModuleFileSet::const_iterator>
+ getAdditionalKnownModuleFiles() {
+ return llvm::make_range(AdditionalKnownModuleFiles.begin(),
+ AdditionalKnownModuleFiles.end());
+ }
+
/// \brief Visit each of the modules.
///
/// This routine visits each of the modules, starting with the
@@ -244,25 +268,35 @@ public:
/// manager that is *not* in this set can be skipped.
void visit(bool (*Visitor)(ModuleFile &M, void *UserData), void *UserData,
llvm::SmallPtrSetImpl<ModuleFile *> *ModuleFilesHit = nullptr);
-
+
+ /// \brief Control DFS behavior during preorder visitation.
+ enum DFSPreorderControl {
+ Continue, /// Continue visiting all nodes.
+ Abort, /// Stop the visitation immediately.
+ SkipImports, /// Do not visit imports of the current node.
+ };
+
/// \brief Visit each of the modules with a depth-first traversal.
///
/// This routine visits each of the modules known to the module
/// manager using a depth-first search, starting with the first
- /// loaded module. The traversal invokes the callback both before
- /// traversing the children (preorder traversal) and after
- /// traversing the children (postorder traversal).
+ /// loaded module. The traversal invokes one callback before
+ /// traversing the imports (preorder traversal) and one after
+ /// traversing the imports (postorder traversal).
///
- /// \param Visitor A visitor function that will be invoked with each
- /// module and given a \c Preorder flag that indicates whether we're
- /// visiting the module before or after visiting its children. The
- /// visitor may return true at any time to abort the depth-first
- /// visitation.
+ /// \param PreorderVisitor A visitor function that will be invoked with each
+ /// module before visiting its imports. The visitor can control how to
+ /// continue the visitation through its return value.
+ ///
+ /// \param PostorderVisitor A visitor function taht will be invoked with each
+ /// module after visiting its imports. The visitor may return true at any time
+ /// to abort the depth-first visitation.
///
/// \param UserData User data ssociated with the visitor object,
/// which will be passed along to the user.
- void visitDepthFirst(bool (*Visitor)(ModuleFile &M, bool Preorder,
- void *UserData),
+ void visitDepthFirst(DFSPreorderControl (*PreorderVisitor)(ModuleFile &M,
+ void *UserData),
+ bool (*PostorderVisitor)(ModuleFile &M, void *UserData),
void *UserData);
/// \brief Attempt to resolve the given module file name to a file entry.
OpenPOWER on IntegriCloud