/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Serialization/ModuleFile.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | |
14 | | #include "clang/Serialization/ModuleFile.h" |
15 | | #include "ASTReaderInternals.h" |
16 | | #include "clang/Serialization/ContinuousRangeMap.h" |
17 | | #include "llvm/ADT/StringRef.h" |
18 | | #include "llvm/Support/Compiler.h" |
19 | | #include "llvm/Support/raw_ostream.h" |
20 | | |
21 | | using namespace clang; |
22 | | using namespace serialization; |
23 | | using namespace reader; |
24 | | |
25 | 472k | ModuleFile::~ModuleFile() { |
26 | 472k | delete static_cast<ASTIdentifierLookupTable *>(IdentifierLookupTable); |
27 | 472k | delete static_cast<HeaderFileInfoLookupTable *>(HeaderFileInfoTable); |
28 | 472k | delete static_cast<ASTSelectorLookupTable *>(SelectorLookupTable); |
29 | 472k | } |
30 | | |
31 | | template<typename Key, typename Offset, unsigned InitialCapacity> |
32 | | static void |
33 | | dumpLocalRemap(StringRef Name, |
34 | 32 | const ContinuousRangeMap<Key, Offset, InitialCapacity> &Map) { |
35 | 32 | if (Map.begin() == Map.end()) |
36 | 8 | return; |
37 | | |
38 | 24 | using MapType = ContinuousRangeMap<Key, Offset, InitialCapacity>; |
39 | | |
40 | 24 | llvm::errs() << " " << Name << ":\n"; |
41 | 24 | for (typename MapType::const_iterator I = Map.begin(), IEnd = Map.end(); |
42 | 58 | I != IEnd; ++I34 ) { |
43 | 34 | llvm::errs() << " " << I->first << " -> " << I->second << "\n"; |
44 | 34 | } |
45 | 24 | } |
46 | | |
47 | 4 | LLVM_DUMP_METHOD void ModuleFile::dump() { |
48 | 4 | llvm::errs() << "\nModule: " << FileName << "\n"; |
49 | 4 | if (!Imports.empty()) { |
50 | 1 | llvm::errs() << " Imports: "; |
51 | 2 | for (unsigned I = 0, N = Imports.size(); I != N; ++I1 ) { |
52 | 1 | if (I) |
53 | 0 | llvm::errs() << ", "; |
54 | 1 | llvm::errs() << Imports[I]->FileName; |
55 | 1 | } |
56 | 1 | llvm::errs() << "\n"; |
57 | 1 | } |
58 | | |
59 | | // Remapping tables. |
60 | 4 | llvm::errs() << " Base source location offset: " << SLocEntryBaseOffset |
61 | 4 | << '\n'; |
62 | 4 | dumpLocalRemap("Source location offset local -> global map", SLocRemap); |
63 | | |
64 | 4 | llvm::errs() << " Base identifier ID: " << BaseIdentifierID << '\n' |
65 | 4 | << " Number of identifiers: " << LocalNumIdentifiers << '\n'; |
66 | 4 | dumpLocalRemap("Identifier ID local -> global map", IdentifierRemap); |
67 | | |
68 | 4 | llvm::errs() << " Base macro ID: " << BaseMacroID << '\n' |
69 | 4 | << " Number of macros: " << LocalNumMacros << '\n'; |
70 | 4 | dumpLocalRemap("Macro ID local -> global map", MacroRemap); |
71 | | |
72 | 4 | llvm::errs() << " Base submodule ID: " << BaseSubmoduleID << '\n' |
73 | 4 | << " Number of submodules: " << LocalNumSubmodules << '\n'; |
74 | 4 | dumpLocalRemap("Submodule ID local -> global map", SubmoduleRemap); |
75 | | |
76 | 4 | llvm::errs() << " Base selector ID: " << BaseSelectorID << '\n' |
77 | 4 | << " Number of selectors: " << LocalNumSelectors << '\n'; |
78 | 4 | dumpLocalRemap("Selector ID local -> global map", SelectorRemap); |
79 | | |
80 | 4 | llvm::errs() << " Base preprocessed entity ID: " << BasePreprocessedEntityID |
81 | 4 | << '\n' |
82 | 4 | << " Number of preprocessed entities: " |
83 | 4 | << NumPreprocessedEntities << '\n'; |
84 | 4 | dumpLocalRemap("Preprocessed entity ID local -> global map", |
85 | 4 | PreprocessedEntityRemap); |
86 | | |
87 | 4 | llvm::errs() << " Base type index: " << BaseTypeIndex << '\n' |
88 | 4 | << " Number of types: " << LocalNumTypes << '\n'; |
89 | 4 | dumpLocalRemap("Type index local -> global map", TypeRemap); |
90 | | |
91 | 4 | llvm::errs() << " Base decl ID: " << BaseDeclID << '\n' |
92 | 4 | << " Number of decls: " << LocalNumDecls << '\n'; |
93 | 4 | dumpLocalRemap("Decl ID local -> global map", DeclRemap); |
94 | 4 | } |