aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/ModuleMap.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-11-29 18:17:59 +0000
committerDouglas Gregor <dgregor@apple.com>2011-11-29 18:17:59 +0000
commit804c3bfee22076f232dddf4839439119cfdee2b6 (patch)
treee3063fa5a6b97cc4f570cbf3e4bf8123b54b21fd /lib/Lex/ModuleMap.cpp
parent7a71524d9b51b01e124719f8e538f2bb85eae07e (diff)
Expose the printing of module maps as part of the ModuleMap::Module
interface. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145411 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/ModuleMap.cpp')
-rw-r--r--lib/Lex/ModuleMap.cpp70
1 files changed, 36 insertions, 34 deletions
diff --git a/lib/Lex/ModuleMap.cpp b/lib/Lex/ModuleMap.cpp
index b8068cc05d..a25c93bfca 100644
--- a/lib/Lex/ModuleMap.cpp
+++ b/lib/Lex/ModuleMap.cpp
@@ -68,6 +68,41 @@ StringRef ModuleMap::Module::getTopLevelModuleName() const {
return Top->Name;
}
+static void indent(llvm::raw_ostream &OS, unsigned Spaces) {
+ OS << std::string(' ', Spaces);
+}
+
+void ModuleMap::Module::print(llvm::raw_ostream &OS, unsigned Indent) const {
+ indent(OS, Indent);
+ if (IsFramework)
+ OS << "framework ";
+ if (IsExplicit)
+ OS << "explicit ";
+ OS << Name << " {\n";
+
+ if (UmbrellaHeader) {
+ indent(OS, Indent + 2);
+ OS << "umbrella \"" << UmbrellaHeader->getName() << "\"\n";
+ }
+
+ for (unsigned I = 0, N = Headers.size(); I != N; ++I) {
+ indent(OS, Indent + 2);
+ OS << "header \"" << Headers[I]->getName() << "\"\n";
+ }
+
+ for (llvm::StringMap<Module *>::const_iterator MI = SubModules.begin(),
+ MIEnd = SubModules.end();
+ MI != MIEnd; ++MI)
+ MI->getValue()->print(OS, Indent + 2);
+
+ indent(OS, Indent);
+ OS << "}\n";
+}
+
+void ModuleMap::Module::dump() const {
+ print(llvm::errs());
+}
+
//----------------------------------------------------------------------------//
// Module map
//----------------------------------------------------------------------------//
@@ -171,45 +206,12 @@ ModuleMap::inferFrameworkModule(StringRef ModuleName,
return Result;
}
-static void indent(llvm::raw_ostream &OS, unsigned Spaces) {
- OS << std::string(' ', Spaces);
-}
-
-static void dumpModule(llvm::raw_ostream &OS, ModuleMap::Module *M,
- unsigned Indent) {
- indent(OS, Indent);
- if (M->IsFramework)
- OS << "framework ";
- if (M->IsExplicit)
- OS << "explicit ";
- OS << M->Name << " {\n";
-
- if (M->UmbrellaHeader) {
- indent(OS, Indent + 2);
- OS << "umbrella \"" << M->UmbrellaHeader->getName() << "\"\n";
- }
-
- for (unsigned I = 0, N = M->Headers.size(); I != N; ++I) {
- indent(OS, Indent + 2);
- OS << "header \"" << M->Headers[I]->getName() << "\"\n";
- }
-
- for (llvm::StringMap<ModuleMap::Module *>::iterator
- MI = M->SubModules.begin(),
- MIEnd = M->SubModules.end();
- MI != MIEnd; ++MI)
- dumpModule(llvm::errs(), MI->getValue(), Indent + 2);
-
- indent(OS, Indent);
- OS << "}\n";
-}
-
void ModuleMap::dump() {
llvm::errs() << "Modules:";
for (llvm::StringMap<Module *>::iterator M = Modules.begin(),
MEnd = Modules.end();
M != MEnd; ++M)
- dumpModule(llvm::errs(), M->getValue(), 2);
+ M->getValue()->print(llvm::errs(), 2);
llvm::errs() << "Headers:";
for (llvm::DenseMap<const FileEntry *, Module *>::iterator