diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2015-05-27 18:47:56 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2015-05-27 18:47:56 +0000 | 
| commit | 5e20cdd81c44a443562a09007668ffdf76c455af (patch) | |
| tree | dbbd4047878da71c1a706e26ce05b4e7791b14cc /include/clang/Serialization/ModuleManager.h | |
| parent | d5f23b0b7528b5c3caed1ba14f897cc4aaa9e3c3 (diff) | |
Notes
Diffstat (limited to 'include/clang/Serialization/ModuleManager.h')
| -rw-r--r-- | include/clang/Serialization/ModuleManager.h | 62 | 
1 files changed, 48 insertions, 14 deletions
| diff --git a/include/clang/Serialization/ModuleManager.h b/include/clang/Serialization/ModuleManager.h index 3d10fad0a1b6..3de86feb66b9 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. | 
