blob: 5a44d26fe399841e9f506ba3b77c0e099a976a95 [file] [log] [blame]
Douglas Gregord44252e2011-08-25 20:47:51 +00001//===--- 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"
Douglas Gregord44252e2011-08-25 20:47:51 +000015#include "ASTReaderInternals.h"
Chandler Carruth3a022472012-12-04 09:13:33 +000016#include "llvm/Support/raw_ostream.h"
Douglas Gregord44252e2011-08-25 20:47:51 +000017
18using namespace clang;
19using namespace serialization;
20using namespace reader;
21
Douglas Gregorde3ef502011-11-30 23:21:26 +000022ModuleFile::~ModuleFile() {
Douglas Gregord44252e2011-08-25 20:47:51 +000023 delete static_cast<ASTIdentifierLookupTable *>(IdentifierLookupTable);
24 delete static_cast<HeaderFileInfoLookupTable *>(HeaderFileInfoTable);
25 delete static_cast<ASTSelectorLookupTable *>(SelectorLookupTable);
26}
27
28template<typename Key, typename Offset, unsigned InitialCapacity>
29static void
30dumpLocalRemap(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
Yaron Kerencdae9412016-01-29 19:38:18 +000043LLVM_DUMP_METHOD void ModuleFile::dump() {
Douglas Gregord44252e2011-08-25 20:47:51 +000044 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);
Douglas Gregor253eefe2011-12-01 00:59:36 +000063
Douglas Gregorcb28f9d2012-10-09 23:05:51 +000064 llvm::errs() << " Base macro ID: " << BaseMacroID << '\n'
65 << " Number of macros: " << LocalNumMacros << '\n';
66 dumpLocalRemap("Macro ID local -> global map", MacroRemap);
67
Douglas Gregor253eefe2011-12-01 00:59:36 +000068 llvm::errs() << " Base submodule ID: " << BaseSubmoduleID << '\n'
69 << " Number of submodules: " << LocalNumSubmodules << '\n';
70 dumpLocalRemap("Submodule ID local -> global map", SubmoduleRemap);
71
Douglas Gregord44252e2011-08-25 20:47:51 +000072 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: "
Argyrios Kyrtzidis03c40c52011-09-15 18:02:56 +000079 << NumPreprocessedEntities << '\n';
Douglas Gregord44252e2011-08-25 20:47:51 +000080 dumpLocalRemap("Preprocessed entity ID local -> global map",
81 PreprocessedEntityRemap);
82
Douglas Gregord44252e2011-08-25 20:47:51 +000083 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}