aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Basic/Module.h
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-01-04 23:32:19 +0000
committerDouglas Gregor <dgregor@apple.com>2012-01-04 23:32:19 +0000
commitb7a7819473709c01ea024a2dc15e99d38f0f8760 (patch)
tree5fbbadeec73aba8aed448bfaf2f67401042d1b0d /include/clang/Basic/Module.h
parente5e42ae2694f2c4709dac3d84e3e6e5fac86c244 (diff)
Store the submodules of a module in source order, as they are stored
in the module map. This provides a bit more predictability for the user, as well as eliminating the need to sort the submodules when serializing them. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147564 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/Module.h')
-rw-r--r--include/clang/Basic/Module.h33
1 files changed, 22 insertions, 11 deletions
diff --git a/include/clang/Basic/Module.h b/include/clang/Basic/Module.h
index 4e6bba2ed3..19292950f5 100644
--- a/include/clang/Basic/Module.h
+++ b/include/clang/Basic/Module.h
@@ -22,6 +22,7 @@
#include "llvm/ADT/StringRef.h"
#include <string>
#include <utility>
+#include <vector>
namespace llvm {
class raw_ostream;
@@ -53,9 +54,15 @@ public:
/// \brief The umbrella header or directory.
llvm::PointerUnion<const DirectoryEntry *, const FileEntry *> Umbrella;
+private:
/// \brief The submodules of this module, indexed by name.
- llvm::StringMap<Module *> SubModules;
+ std::vector<Module *> SubModules;
+ /// \brief A mapping from the submodule name to the index into the
+ /// \c SubModules vector at which that submodule resides.
+ llvm::StringMap<unsigned> SubModuleIndex;
+
+public:
/// \brief The headers that are part of this module.
llvm::SmallVector<const FileEntry *, 2> Headers;
@@ -152,16 +159,7 @@ public:
/// \brief Construct a new module or submodule.
Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent,
- bool IsFramework, bool IsExplicit)
- : Name(Name), DefinitionLoc(DefinitionLoc), Parent(Parent),
- Umbrella(), IsAvailable(true), IsFromModuleFile(false),
- IsFramework(IsFramework), IsExplicit(IsExplicit), InferSubmodules(false),
- InferExplicitSubmodules(false), InferExportWildcard(false),
- NameVisibility(Hidden)
- {
- if (Parent && !Parent->isAvailable())
- IsAvailable = false;
- }
+ bool IsFramework, bool IsExplicit);
~Module();
@@ -245,6 +243,19 @@ public:
/// evaluate the availability of this feature.
void addRequirement(StringRef Feature, const LangOptions &LangOpts);
+ /// \brief Find the submodule with the given name.
+ ///
+ /// \returns The submodule if found, or NULL otherwise.
+ Module *findSubmodule(StringRef Name) const;
+
+ typedef std::vector<Module *>::iterator submodule_iterator;
+ typedef std::vector<Module *>::const_iterator submodule_const_iterator;
+
+ submodule_iterator submodule_begin() { return SubModules.begin(); }
+ submodule_const_iterator submodule_begin() const {return SubModules.begin();}
+ submodule_iterator submodule_end() { return SubModules.end(); }
+ submodule_const_iterator submodule_end() const { return SubModules.end(); }
+
/// \brief Print the module map for this module to the given stream.
///
void print(llvm::raw_ostream &OS, unsigned Indent = 0) const;