clang 19.0.0git
ModuleFile.cpp
Go to the documentation of this file.
1//===- ModuleFile.cpp - Module description --------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the ModuleFile class, which describes a module that
10// has been loaded from an AST file.
11//
12//===----------------------------------------------------------------------===//
13
15#include "ASTReaderInternals.h"
17#include "llvm/ADT/StringRef.h"
18#include "llvm/Support/Compiler.h"
19#include "llvm/Support/raw_ostream.h"
20
21using namespace clang;
22using namespace serialization;
23using namespace reader;
24
28 delete static_cast<ASTSelectorLookupTable *>(SelectorLookupTable);
29}
30
31template<typename Key, typename Offset, unsigned InitialCapacity>
32static void
33dumpLocalRemap(StringRef Name,
35 if (Map.begin() == Map.end())
36 return;
37
39
40 llvm::errs() << " " << Name << ":\n";
41 for (typename MapType::const_iterator I = Map.begin(), IEnd = Map.end();
42 I != IEnd; ++I) {
43 llvm::errs() << " " << I->first << " -> " << I->second << "\n";
44 }
45}
46
47LLVM_DUMP_METHOD void ModuleFile::dump() {
48 llvm::errs() << "\nModule: " << FileName << "\n";
49 if (!Imports.empty()) {
50 llvm::errs() << " Imports: ";
51 for (unsigned I = 0, N = Imports.size(); I != N; ++I) {
52 if (I)
53 llvm::errs() << ", ";
54 llvm::errs() << Imports[I]->FileName;
55 }
56 llvm::errs() << "\n";
57 }
58
59 // Remapping tables.
60 llvm::errs() << " Base source location offset: " << SLocEntryBaseOffset
61 << '\n';
62
63 llvm::errs() << " Base identifier ID: " << BaseIdentifierID << '\n'
64 << " Number of identifiers: " << LocalNumIdentifiers << '\n';
65 dumpLocalRemap("Identifier ID local -> global map", IdentifierRemap);
66
67 llvm::errs() << " Base macro ID: " << BaseMacroID << '\n'
68 << " Number of macros: " << LocalNumMacros << '\n';
69 dumpLocalRemap("Macro ID local -> global map", MacroRemap);
70
71 llvm::errs() << " Base submodule ID: " << BaseSubmoduleID << '\n'
72 << " Number of submodules: " << LocalNumSubmodules << '\n';
73 dumpLocalRemap("Submodule ID local -> global map", SubmoduleRemap);
74
75 llvm::errs() << " Base selector ID: " << BaseSelectorID << '\n'
76 << " Number of selectors: " << LocalNumSelectors << '\n';
77 dumpLocalRemap("Selector ID local -> global map", SelectorRemap);
78
79 llvm::errs() << " Base preprocessed entity ID: " << BasePreprocessedEntityID
80 << '\n'
81 << " Number of preprocessed entities: "
82 << NumPreprocessedEntities << '\n';
83 dumpLocalRemap("Preprocessed entity ID local -> global map",
85
86 llvm::errs() << " Base type index: " << BaseTypeIndex << '\n'
87 << " Number of types: " << LocalNumTypes << '\n';
88 dumpLocalRemap("Type index local -> global map", TypeRemap);
89
90 llvm::errs() << " Base decl index: " << BaseDeclIndex << '\n'
91 << " Number of decls: " << LocalNumDecls << '\n';
92}
static void dumpLocalRemap(StringRef Name, const ContinuousRangeMap< Key, Offset, InitialCapacity > &Map)
Definition: ModuleFile.cpp:33
A map from continuous integer ranges to some value, with a very specialized interface.
void * IdentifierLookupTable
A pointer to an on-disk hash table of opaque type IdentifierHashTable.
Definition: ModuleFile.h:324
void * SelectorLookupTable
A pointer to an on-disk hash table of opaque type ASTSelectorLookupTable.
Definition: ModuleFile.h:438
ContinuousRangeMap< uint32_t, int, 2 > PreprocessedEntityRemap
Remapping table for preprocessed entity IDs in this module.
Definition: ModuleFile.h:373
serialization::IdentifierID BaseIdentifierID
Base identifier ID for identifiers local to this module.
Definition: ModuleFile.h:311
serialization::PreprocessedEntityID BasePreprocessedEntityID
Base preprocessed entity ID for preprocessed entities local to this module.
Definition: ModuleFile.h:370
serialization::TypeID BaseTypeIndex
Base type ID for types local to this module as represented in the global type ID space.
Definition: ModuleFile.h:486
unsigned LocalNumIdentifiers
The number of identifiers in this AST file.
Definition: ModuleFile.h:301
serialization::SelectorID BaseSelectorID
Base selector ID for selectors local to this module.
Definition: ModuleFile.h:423
ContinuousRangeMap< uint32_t, int, 2 > TypeRemap
Remapping table for type IDs in this module.
Definition: ModuleFile.h:489
ContinuousRangeMap< uint32_t, int, 2 > IdentifierRemap
Remapping table for identifier IDs in this module.
Definition: ModuleFile.h:314
unsigned LocalNumSubmodules
The number of submodules in this module.
Definition: ModuleFile.h:403
unsigned BaseDeclIndex
Base declaration index in ASTReader for declarations local to this module.
Definition: ModuleFile.h:458
void * HeaderFileInfoTable
The on-disk hash table that contains information about each of the header files.
Definition: ModuleFile.h:398
serialization::SubmoduleID BaseSubmoduleID
Base submodule ID for submodules local to this module.
Definition: ModuleFile.h:406
unsigned LocalNumTypes
The number of types in this AST file.
Definition: ModuleFile.h:478
std::string FileName
The file name of the module file.
Definition: ModuleFile.h:139
llvm::SetVector< ModuleFile * > Imports
List of modules which this module directly imported.
Definition: ModuleFile.h:500
SourceLocation::UIntTy SLocEntryBaseOffset
The base offset in the source manager's view of this module.
Definition: ModuleFile.h:288
unsigned LocalNumMacros
The number of macros in this AST file.
Definition: ModuleFile.h:337
void dump()
Dump debugging output for this module.
Definition: ModuleFile.cpp:47
unsigned LocalNumDecls
The number of declarations in this AST file.
Definition: ModuleFile.h:451
ContinuousRangeMap< uint32_t, int, 2 > SelectorRemap
Remapping table for selector IDs in this module.
Definition: ModuleFile.h:426
ContinuousRangeMap< uint32_t, int, 2 > MacroRemap
Remapping table for macro IDs in this module.
Definition: ModuleFile.h:354
ContinuousRangeMap< uint32_t, int, 2 > SubmoduleRemap
Remapping table for submodule IDs in this module.
Definition: ModuleFile.h:409
unsigned LocalNumSelectors
The number of selectors new to this file.
Definition: ModuleFile.h:416
serialization::MacroID BaseMacroID
Base macro ID for macros local to this module.
Definition: ModuleFile.h:351
llvm::OnDiskChainedHashTable< HeaderFileInfoTrait > HeaderFileInfoLookupTable
The on-disk hash table used for known header files.
llvm::OnDiskIterableChainedHashTable< ASTIdentifierLookupTrait > ASTIdentifierLookupTable
The on-disk hash table used to contain information about all of the identifiers in the program.
llvm::OnDiskChainedHashTable< ASTSelectorLookupTrait > ASTSelectorLookupTable
The on-disk hash table used for the global method pool.
The JSON file list parser is used to communicate input to InstallAPI.