1 //===- ExternalASTSource.cpp - Abstract External AST Interface --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file provides the default implementation of the ExternalASTSource
11 // interface, which enables construction of AST nodes from some external
14 //===----------------------------------------------------------------------===//
16 #include "clang/AST/ExternalASTSource.h"
17 #include "clang/AST/ASTContext.h"
18 #include "clang/AST/DeclarationName.h"
19 #include "llvm/Support/ErrorHandling.h"
21 using namespace clang;
23 ExternalASTSource::~ExternalASTSource() { }
25 llvm::Optional<ExternalASTSource::ASTSourceDescriptor>
26 ExternalASTSource::getSourceDescriptor(unsigned ID) {
30 ExternalASTSource::ASTSourceDescriptor
31 ExternalASTSource::getSourceDescriptor(const Module &M) {
32 return ASTSourceDescriptor();
35 void ExternalASTSource::FindFileRegionDecls(FileID File, unsigned Offset,
37 SmallVectorImpl<Decl *> &Decls) {}
39 void ExternalASTSource::CompleteRedeclChain(const Decl *D) {}
41 void ExternalASTSource::CompleteType(TagDecl *Tag) {}
43 void ExternalASTSource::CompleteType(ObjCInterfaceDecl *Class) {}
45 void ExternalASTSource::ReadComments() {}
47 void ExternalASTSource::StartedDeserializing() {}
49 void ExternalASTSource::FinishedDeserializing() {}
51 void ExternalASTSource::StartTranslationUnit(ASTConsumer *Consumer) {}
53 void ExternalASTSource::PrintStats() { }
55 bool ExternalASTSource::layoutRecordType(
56 const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
57 llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets,
58 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets,
59 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &VirtualBaseOffsets) {
63 Decl *ExternalASTSource::GetExternalDecl(uint32_t ID) {
67 Selector ExternalASTSource::GetExternalSelector(uint32_t ID) {
71 uint32_t ExternalASTSource::GetNumExternalSelectors() {
75 Stmt *ExternalASTSource::GetExternalDeclStmt(uint64_t Offset) {
80 ExternalASTSource::GetExternalCXXCtorInitializers(uint64_t Offset) {
85 ExternalASTSource::GetExternalCXXBaseSpecifiers(uint64_t Offset) {
90 ExternalASTSource::FindExternalVisibleDeclsByName(const DeclContext *DC,
91 DeclarationName Name) {
95 void ExternalASTSource::completeVisibleDeclsMap(const DeclContext *DC) {
99 ExternalASTSource::FindExternalLexicalDecls(const DeclContext *DC,
100 bool (*isKindWeWant)(Decl::Kind),
101 SmallVectorImpl<Decl*> &Result) {
102 return ELR_AlreadyLoaded;
105 void ExternalASTSource::getMemoryBufferSizes(MemoryBufferSizes &sizes) const { }
107 uint32_t ExternalASTSource::incrementGeneration(ASTContext &C) {
108 uint32_t OldGeneration = CurrentGeneration;
110 // Make sure the generation of the topmost external source for the context is
111 // incremented. That might not be us.
112 auto *P = C.getExternalSource();
114 CurrentGeneration = P->incrementGeneration(C);
116 // FIXME: Only bump the generation counter if the current generation number
117 // has been observed?
118 if (!++CurrentGeneration)
119 llvm::report_fatal_error("generation counter overflowed", false);
122 return OldGeneration;