Path: blob/main/contrib/llvm-project/clang/lib/AST/ExternalASTSource.cpp
35259 views
//===- ExternalASTSource.cpp - Abstract External AST Interface ------------===//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 provides the default implementation of the ExternalASTSource9// interface, which enables construction of AST nodes from some external10// source.11//12//===----------------------------------------------------------------------===//1314#include "clang/AST/ExternalASTSource.h"15#include "clang/AST/ASTContext.h"16#include "clang/AST/DeclarationName.h"17#include "clang/Basic/ASTSourceDescriptor.h"18#include "clang/Basic/FileManager.h"19#include "clang/Basic/IdentifierTable.h"20#include "clang/Basic/LLVM.h"21#include "clang/Basic/SourceManager.h"22#include "llvm/Support/ErrorHandling.h"23#include <cstdint>24#include <optional>2526using namespace clang;2728char ExternalASTSource::ID;2930ExternalASTSource::~ExternalASTSource() = default;3132std::optional<ASTSourceDescriptor>33ExternalASTSource::getSourceDescriptor(unsigned ID) {34return std::nullopt;35}3637ExternalASTSource::ExtKind38ExternalASTSource::hasExternalDefinitions(const Decl *D) {39return EK_ReplyHazy;40}4142void ExternalASTSource::FindFileRegionDecls(FileID File, unsigned Offset,43unsigned Length,44SmallVectorImpl<Decl *> &Decls) {}4546void ExternalASTSource::CompleteRedeclChain(const Decl *D) {}4748void ExternalASTSource::CompleteType(TagDecl *Tag) {}4950void ExternalASTSource::CompleteType(ObjCInterfaceDecl *Class) {}5152void ExternalASTSource::ReadComments() {}5354void ExternalASTSource::StartedDeserializing() {}5556void ExternalASTSource::FinishedDeserializing() {}5758void ExternalASTSource::StartTranslationUnit(ASTConsumer *Consumer) {}5960void ExternalASTSource::PrintStats() {}6162bool ExternalASTSource::layoutRecordType(63const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,64llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets,65llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets,66llvm::DenseMap<const CXXRecordDecl *, CharUnits> &VirtualBaseOffsets) {67return false;68}6970Decl *ExternalASTSource::GetExternalDecl(GlobalDeclID ID) { return nullptr; }7172Selector ExternalASTSource::GetExternalSelector(uint32_t ID) {73return Selector();74}7576uint32_t ExternalASTSource::GetNumExternalSelectors() {77return 0;78}7980Stmt *ExternalASTSource::GetExternalDeclStmt(uint64_t Offset) {81return nullptr;82}8384CXXCtorInitializer **85ExternalASTSource::GetExternalCXXCtorInitializers(uint64_t Offset) {86return nullptr;87}8889CXXBaseSpecifier *90ExternalASTSource::GetExternalCXXBaseSpecifiers(uint64_t Offset) {91return nullptr;92}9394bool95ExternalASTSource::FindExternalVisibleDeclsByName(const DeclContext *DC,96DeclarationName Name) {97return false;98}99100void ExternalASTSource::completeVisibleDeclsMap(const DeclContext *DC) {}101102void ExternalASTSource::FindExternalLexicalDecls(103const DeclContext *DC, llvm::function_ref<bool(Decl::Kind)> IsKindWeWant,104SmallVectorImpl<Decl *> &Result) {}105106void ExternalASTSource::getMemoryBufferSizes(MemoryBufferSizes &sizes) const {}107108uint32_t ExternalASTSource::incrementGeneration(ASTContext &C) {109uint32_t OldGeneration = CurrentGeneration;110111// Make sure the generation of the topmost external source for the context is112// incremented. That might not be us.113auto *P = C.getExternalSource();114if (P && P != this)115CurrentGeneration = P->incrementGeneration(C);116else {117// FIXME: Only bump the generation counter if the current generation number118// has been observed?119if (!++CurrentGeneration)120llvm::report_fatal_error("generation counter overflowed", false);121}122123return OldGeneration;124}125126127