]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/lib/Serialization/Module.cpp
Merge clang trunk r300422 and resolve conflicts.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / lib / Serialization / Module.cpp
1 //===--- Module.cpp - Module description ------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //  This file implements the Module class, which describes a module that has
11 //  been loaded from an AST file.
12 //
13 //===----------------------------------------------------------------------===//
14 #include "clang/Serialization/Module.h"
15 #include "ASTReaderInternals.h"
16 #include "llvm/Support/raw_ostream.h"
17
18 using namespace clang;
19 using namespace serialization;
20 using namespace reader;
21
22 ModuleFile::~ModuleFile() {
23   delete static_cast<ASTIdentifierLookupTable *>(IdentifierLookupTable);
24   delete static_cast<HeaderFileInfoLookupTable *>(HeaderFileInfoTable);
25   delete static_cast<ASTSelectorLookupTable *>(SelectorLookupTable);
26 }
27
28 template<typename Key, typename Offset, unsigned InitialCapacity>
29 static void 
30 dumpLocalRemap(StringRef Name,
31                const ContinuousRangeMap<Key, Offset, InitialCapacity> &Map) {
32   if (Map.begin() == Map.end())
33     return;
34   
35   typedef ContinuousRangeMap<Key, Offset, InitialCapacity> MapType;
36   llvm::errs() << "  " << Name << ":\n";
37   for (typename MapType::const_iterator I = Map.begin(), IEnd = Map.end(); 
38        I != IEnd; ++I) {
39     llvm::errs() << "    " << I->first << " -> " << I->second << "\n";
40   }
41 }
42
43 LLVM_DUMP_METHOD void ModuleFile::dump() {
44   llvm::errs() << "\nModule: " << FileName << "\n";
45   if (!Imports.empty()) {
46     llvm::errs() << "  Imports: ";
47     for (unsigned I = 0, N = Imports.size(); I != N; ++I) {
48       if (I)
49         llvm::errs() << ", ";
50       llvm::errs() << Imports[I]->FileName;
51     }
52     llvm::errs() << "\n";
53   }
54   
55   // Remapping tables.
56   llvm::errs() << "  Base source location offset: " << SLocEntryBaseOffset 
57                << '\n';
58   dumpLocalRemap("Source location offset local -> global map", SLocRemap);
59   
60   llvm::errs() << "  Base identifier ID: " << BaseIdentifierID << '\n'
61                << "  Number of identifiers: " << LocalNumIdentifiers << '\n';
62   dumpLocalRemap("Identifier ID local -> global map", IdentifierRemap);
63
64   llvm::errs() << "  Base macro ID: " << BaseMacroID << '\n'
65                << "  Number of macros: " << LocalNumMacros << '\n';
66   dumpLocalRemap("Macro ID local -> global map", MacroRemap);
67
68   llvm::errs() << "  Base submodule ID: " << BaseSubmoduleID << '\n'
69                << "  Number of submodules: " << LocalNumSubmodules << '\n';
70   dumpLocalRemap("Submodule ID local -> global map", SubmoduleRemap);
71
72   llvm::errs() << "  Base selector ID: " << BaseSelectorID << '\n'
73                << "  Number of selectors: " << LocalNumSelectors << '\n';
74   dumpLocalRemap("Selector ID local -> global map", SelectorRemap);
75   
76   llvm::errs() << "  Base preprocessed entity ID: " << BasePreprocessedEntityID
77                << '\n'  
78                << "  Number of preprocessed entities: " 
79                << NumPreprocessedEntities << '\n';
80   dumpLocalRemap("Preprocessed entity ID local -> global map", 
81                  PreprocessedEntityRemap);
82   
83   llvm::errs() << "  Base type index: " << BaseTypeIndex << '\n'
84                << "  Number of types: " << LocalNumTypes << '\n';
85   dumpLocalRemap("Type index local -> global map", TypeRemap);
86   
87   llvm::errs() << "  Base decl ID: " << BaseDeclID << '\n'
88                << "  Number of decls: " << LocalNumDecls << '\n';
89   dumpLocalRemap("Decl ID local -> global map", DeclRemap);
90 }