Path: blob/main/contrib/llvm-project/clang/lib/Serialization/ModuleFile.cpp
35232 views
//===- ModuleFile.cpp - Module description --------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file implements the ModuleFile class, which describes a module that9// has been loaded from an AST file.10//11//===----------------------------------------------------------------------===//1213#include "clang/Serialization/ModuleFile.h"14#include "ASTReaderInternals.h"15#include "clang/Serialization/ContinuousRangeMap.h"16#include "llvm/ADT/StringRef.h"17#include "llvm/Support/Compiler.h"18#include "llvm/Support/raw_ostream.h"1920using namespace clang;21using namespace serialization;22using namespace reader;2324ModuleFile::~ModuleFile() {25delete static_cast<ASTIdentifierLookupTable *>(IdentifierLookupTable);26delete static_cast<HeaderFileInfoLookupTable *>(HeaderFileInfoTable);27delete static_cast<ASTSelectorLookupTable *>(SelectorLookupTable);28}2930template<typename Key, typename Offset, unsigned InitialCapacity>31static void32dumpLocalRemap(StringRef Name,33const ContinuousRangeMap<Key, Offset, InitialCapacity> &Map) {34if (Map.begin() == Map.end())35return;3637using MapType = ContinuousRangeMap<Key, Offset, InitialCapacity>;3839llvm::errs() << " " << Name << ":\n";40for (typename MapType::const_iterator I = Map.begin(), IEnd = Map.end();41I != IEnd; ++I) {42llvm::errs() << " " << I->first << " -> " << I->second << "\n";43}44}4546LLVM_DUMP_METHOD void ModuleFile::dump() {47llvm::errs() << "\nModule: " << FileName << "\n";48if (!Imports.empty()) {49llvm::errs() << " Imports: ";50for (unsigned I = 0, N = Imports.size(); I != N; ++I) {51if (I)52llvm::errs() << ", ";53llvm::errs() << Imports[I]->FileName;54}55llvm::errs() << "\n";56}5758// Remapping tables.59llvm::errs() << " Base source location offset: " << SLocEntryBaseOffset60<< '\n';6162llvm::errs() << " Base identifier ID: " << BaseIdentifierID << '\n'63<< " Number of identifiers: " << LocalNumIdentifiers << '\n';6465llvm::errs() << " Base macro ID: " << BaseMacroID << '\n'66<< " Number of macros: " << LocalNumMacros << '\n';67dumpLocalRemap("Macro ID local -> global map", MacroRemap);6869llvm::errs() << " Base submodule ID: " << BaseSubmoduleID << '\n'70<< " Number of submodules: " << LocalNumSubmodules << '\n';71dumpLocalRemap("Submodule ID local -> global map", SubmoduleRemap);7273llvm::errs() << " Base selector ID: " << BaseSelectorID << '\n'74<< " Number of selectors: " << LocalNumSelectors << '\n';75dumpLocalRemap("Selector ID local -> global map", SelectorRemap);7677llvm::errs() << " Base preprocessed entity ID: " << BasePreprocessedEntityID78<< '\n'79<< " Number of preprocessed entities: "80<< NumPreprocessedEntities << '\n';81dumpLocalRemap("Preprocessed entity ID local -> global map",82PreprocessedEntityRemap);8384llvm::errs() << " Base type index: " << BaseTypeIndex << '\n'85<< " Number of types: " << LocalNumTypes << '\n';8687llvm::errs() << " Base decl index: " << BaseDeclIndex << '\n'88<< " Number of decls: " << LocalNumDecls << '\n';89}909192