ExternalASTSource.cpp revision 288943
1//===- ExternalASTSource.cpp - Abstract External AST Interface --*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file provides the default implementation of the ExternalASTSource 11// interface, which enables construction of AST nodes from some external 12// source. 13// 14//===----------------------------------------------------------------------===// 15 16#include "clang/AST/ExternalASTSource.h" 17#include "clang/AST/ASTContext.h" 18#include "clang/AST/DeclarationName.h" 19#include "llvm/Support/ErrorHandling.h" 20 21using namespace clang; 22 23ExternalASTSource::~ExternalASTSource() { } 24 25llvm::Optional<ExternalASTSource::ASTSourceDescriptor> 26ExternalASTSource::getSourceDescriptor(unsigned ID) { 27 return None; 28} 29 30ExternalASTSource::ASTSourceDescriptor 31ExternalASTSource::getSourceDescriptor(const Module &M) { 32 return ASTSourceDescriptor(); 33} 34 35void ExternalASTSource::FindFileRegionDecls(FileID File, unsigned Offset, 36 unsigned Length, 37 SmallVectorImpl<Decl *> &Decls) {} 38 39void ExternalASTSource::CompleteRedeclChain(const Decl *D) {} 40 41void ExternalASTSource::CompleteType(TagDecl *Tag) {} 42 43void ExternalASTSource::CompleteType(ObjCInterfaceDecl *Class) {} 44 45void ExternalASTSource::ReadComments() {} 46 47void ExternalASTSource::StartedDeserializing() {} 48 49void ExternalASTSource::FinishedDeserializing() {} 50 51void ExternalASTSource::StartTranslationUnit(ASTConsumer *Consumer) {} 52 53void ExternalASTSource::PrintStats() { } 54 55bool 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) { 60 return false; 61} 62 63Decl *ExternalASTSource::GetExternalDecl(uint32_t ID) { 64 return nullptr; 65} 66 67Selector ExternalASTSource::GetExternalSelector(uint32_t ID) { 68 return Selector(); 69} 70 71uint32_t ExternalASTSource::GetNumExternalSelectors() { 72 return 0; 73} 74 75Stmt *ExternalASTSource::GetExternalDeclStmt(uint64_t Offset) { 76 return nullptr; 77} 78 79CXXCtorInitializer ** 80ExternalASTSource::GetExternalCXXCtorInitializers(uint64_t Offset) { 81 return nullptr; 82} 83 84CXXBaseSpecifier * 85ExternalASTSource::GetExternalCXXBaseSpecifiers(uint64_t Offset) { 86 return nullptr; 87} 88 89bool 90ExternalASTSource::FindExternalVisibleDeclsByName(const DeclContext *DC, 91 DeclarationName Name) { 92 return false; 93} 94 95void ExternalASTSource::completeVisibleDeclsMap(const DeclContext *DC) { 96} 97 98ExternalLoadResult 99ExternalASTSource::FindExternalLexicalDecls(const DeclContext *DC, 100 bool (*isKindWeWant)(Decl::Kind), 101 SmallVectorImpl<Decl*> &Result) { 102 return ELR_AlreadyLoaded; 103} 104 105void ExternalASTSource::getMemoryBufferSizes(MemoryBufferSizes &sizes) const { } 106 107uint32_t ExternalASTSource::incrementGeneration(ASTContext &C) { 108 uint32_t OldGeneration = CurrentGeneration; 109 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(); 113 if (P && P != this) 114 CurrentGeneration = P->incrementGeneration(C); 115 else { 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); 120 } 121 122 return OldGeneration; 123} 124