r193850 - Simplify computation of visible module set.
Richard Smith
richard-llvm at metafoo.co.uk
Thu Oct 31 19:19:15 PDT 2013
Author: rsmith
Date: Thu Oct 31 21:19:14 2013
New Revision: 193850
URL: http://llvm.org/viewvc/llvm-project?rev=193850&view=rev
Log:
Simplify computation of visible module set.
Modified:
cfe/trunk/include/clang/Basic/Module.h
cfe/trunk/lib/Basic/Module.cpp
Modified: cfe/trunk/include/clang/Basic/Module.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=193850&r1=193849&r2=193850&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Module.h (original)
+++ cfe/trunk/include/clang/Basic/Module.h Thu Oct 31 21:19:14 2013
@@ -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() {
Modified: cfe/trunk/lib/Basic/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Module.cpp?rev=193850&r1=193849&r2=193850&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Module.cpp (original)
+++ cfe/trunk/lib/Basic/Module.cpp Thu Oct 31 21:19:14 2013
@@ -253,22 +253,13 @@ void Module::buildVisibleModulesCache()
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);
}
}
More information about the cfe-commits
mailing list