[cfe-commits] [PATCH] More refactoring module management into its own manager

Douglas Gregor dgregor at apple.com
Mon Jul 25 22:26:49 PDT 2011


On Jul 25, 2011, at 5:23 PM, Jonathan Turner wrote:

> This patch extends the previous patch by starting to incorporate more functionality, like lookup-by-name and exporting lookup tables, into the module manager.  Methods now have documentation.  A few more functions have been switched over to the new iterator style and away from manual/explicit iteration.  

Index: include/clang/Serialization/ASTReader.h
===================================================================
--- include/clang/Serialization/ASTReader.h	(revision 135957)
+++ include/clang/Serialization/ASTReader.h	(working copy)
@@ -393,34 +393,81 @@
   /// \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<Module*, 2> Chain;
+
+  /// \brief All loaded modules, indexed by name.
+  llvm::StringMap<Module*> Modules;
+

Uniquing by file names won't work when we're dealing with symlinks. Why not use the FileManager to find the modules when we load them, then unique based on FileEntry*'s via a DenseMap?

+  /// \brief Creates a new module and adds it to the list of known modules
+  Module &addModule(StringRef FileName, ModuleKind Type) {
+    Module *Prev = !size() ? 0 : &getLastModule();
+    Module *Current = new Module(Type);

Please move the definition out-of-line.

Everything else looks good!

	- Doug



More information about the cfe-commits mailing list