diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-11-01 02:19:14 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-11-01 02:19:14 +0000 |
commit | dde17e74fa05c1c749c7ecb8ac88a3e30c953848 (patch) | |
tree | f6174d58a2a6adf015217521a47dfb7dc49552e6 | |
parent | b9657033ccd50504021b63757b92c1e7f4e69993 (diff) | |
download | bcm5719-llvm-dde17e74fa05c1c749c7ecb8ac88a3e30c953848.tar.gz bcm5719-llvm-dde17e74fa05c1c749c7ecb8ac88a3e30c953848.zip |
Simplify computation of visible module set.
llvm-svn: 193850
-rw-r--r-- | clang/include/clang/Basic/Module.h | 6 | ||||
-rw-r--r-- | clang/lib/Basic/Module.cpp | 19 |
2 files changed, 8 insertions, 17 deletions
diff --git a/clang/include/clang/Basic/Module.h b/clang/include/clang/Basic/Module.h index 3d8b75b471f..e8d774e1eb5 100644 --- a/clang/include/clang/Basic/Module.h +++ b/clang/include/clang/Basic/Module.h @@ -403,10 +403,10 @@ public: submodule_iterator submodule_end() { return SubModules.end(); } submodule_const_iterator submodule_end() const { return SubModules.end(); } - /// \brief Returns the exported modules based on the wildcard restrictions. + /// \brief Appends this module's list of exported modules to \p Exported. /// - /// This returns a subset of immediately imported modules (the ones that are - /// exported), not the complete set of exported modules. + /// This provides a subset of immediately imported modules (the ones that are + /// directly exported), not the complete set of exported modules. void getExportedModules(SmallVectorImpl<Module *> &Exported) const; static StringRef getModuleInputBufferName() { diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp index ccf7077d6fb..4818e8d173c 100644 --- a/clang/lib/Basic/Module.cpp +++ b/clang/lib/Basic/Module.cpp @@ -253,22 +253,13 @@ void Module::buildVisibleModulesCache() const { VisibleModulesCache.insert(this); // Every imported module is visible. - // Every module exported by an imported module is visible. - llvm::SmallPtrSet<Module *, 4> Visited; - llvm::SmallVector<Module *, 4> Exports; - SmallVector<Module *, 4> Stack(Imports.begin(), Imports.end()); + SmallVector<Module *, 16> Stack(Imports.begin(), Imports.end()); while (!Stack.empty()) { Module *CurrModule = Stack.pop_back_val(); - VisibleModulesCache.insert(CurrModule); - - CurrModule->getExportedModules(Exports); - for (SmallVectorImpl<Module *>::iterator I = Exports.begin(), - E = Exports.end(); - I != E; ++I) { - Module *Exported = *I; - if (Visited.insert(Exported)) - Stack.push_back(Exported); - } + + // Every module transitively exported by an imported module is visible. + if (VisibleModulesCache.insert(CurrModule).second) + CurrModule->getExportedModules(Stack); } } |