brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.2 KiB · 7f631ea Raw
88 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8//9//  This file implements the ModuleFile class, which describes a module that10//  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 21using namespace clang;22using namespace serialization;23using namespace reader;24 25ModuleFile::~ModuleFile() {26  delete static_cast<ASTIdentifierLookupTable *>(IdentifierLookupTable);27  delete static_cast<HeaderFileInfoLookupTable *>(HeaderFileInfoTable);28  delete static_cast<ASTSelectorLookupTable *>(SelectorLookupTable);29}30 31template<typename Key, typename Offset, unsigned InitialCapacity>32static void33dumpLocalRemap(StringRef Name,34               const ContinuousRangeMap<Key, Offset, InitialCapacity> &Map) {35  if (Map.begin() == Map.end())36    return;37 38  using MapType = ContinuousRangeMap<Key, Offset, InitialCapacity>;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: " << SLocEntryBaseOffset61               << '\n';62 63  llvm::errs() << "  Base identifier ID: " << BaseIdentifierID << '\n'64               << "  Number of identifiers: " << LocalNumIdentifiers << '\n';65 66  llvm::errs() << "  Base macro ID: " << BaseMacroID << '\n'67               << "  Number of macros: " << LocalNumMacros << '\n';68 69  llvm::errs() << "  Base submodule ID: " << BaseSubmoduleID << '\n'70               << "  Number of submodules: " << LocalNumSubmodules << '\n';71  dumpLocalRemap("Submodule ID local -> global map", SubmoduleRemap);72 73  llvm::errs() << "  Base selector ID: " << BaseSelectorID << '\n'74               << "  Number of selectors: " << LocalNumSelectors << '\n';75  dumpLocalRemap("Selector ID local -> global map", SelectorRemap);76 77  llvm::errs() << "  Base preprocessed entity ID: " << BasePreprocessedEntityID78               << '\n'79               << "  Number of preprocessed entities: "80               << NumPreprocessedEntities << '\n';81 82  llvm::errs() << "  Base type index: " << BaseTypeIndex << '\n'83               << "  Number of types: " << LocalNumTypes << '\n';84 85  llvm::errs() << "  Base decl index: " << BaseDeclIndex << '\n'86               << "  Number of decls: " << LocalNumDecls << '\n';87}88