xref: /minix3/external/bsd/llvm/dist/clang/lib/AST/ExternalASTSource.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc //===- ExternalASTSource.cpp - Abstract External AST Interface --*- C++ -*-===//
2f4a2713aSLionel Sambuc //
3f4a2713aSLionel Sambuc //                     The LLVM Compiler Infrastructure
4f4a2713aSLionel Sambuc //
5f4a2713aSLionel Sambuc // This file is distributed under the University of Illinois Open Source
6f4a2713aSLionel Sambuc // License. See LICENSE.TXT for details.
7f4a2713aSLionel Sambuc //
8f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
9f4a2713aSLionel Sambuc //
10f4a2713aSLionel Sambuc //  This file provides the default implementation of the ExternalASTSource
11f4a2713aSLionel Sambuc //  interface, which enables construction of AST nodes from some external
12f4a2713aSLionel Sambuc //  source.
13f4a2713aSLionel Sambuc //
14f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
15f4a2713aSLionel Sambuc 
16f4a2713aSLionel Sambuc #include "clang/AST/ExternalASTSource.h"
17*0a6a1f1dSLionel Sambuc #include "clang/AST/ASTContext.h"
18f4a2713aSLionel Sambuc #include "clang/AST/DeclarationName.h"
19*0a6a1f1dSLionel Sambuc #include "llvm/Support/ErrorHandling.h"
20f4a2713aSLionel Sambuc 
21f4a2713aSLionel Sambuc using namespace clang;
22f4a2713aSLionel Sambuc 
~ExternalASTSource()23f4a2713aSLionel Sambuc ExternalASTSource::~ExternalASTSource() { }
24f4a2713aSLionel Sambuc 
FindFileRegionDecls(FileID File,unsigned Offset,unsigned Length,SmallVectorImpl<Decl * > & Decls)25*0a6a1f1dSLionel Sambuc void ExternalASTSource::FindFileRegionDecls(FileID File, unsigned Offset,
26*0a6a1f1dSLionel Sambuc                                             unsigned Length,
27*0a6a1f1dSLionel Sambuc                                             SmallVectorImpl<Decl *> &Decls) {}
28*0a6a1f1dSLionel Sambuc 
CompleteRedeclChain(const Decl * D)29*0a6a1f1dSLionel Sambuc void ExternalASTSource::CompleteRedeclChain(const Decl *D) {}
30*0a6a1f1dSLionel Sambuc 
CompleteType(TagDecl * Tag)31*0a6a1f1dSLionel Sambuc void ExternalASTSource::CompleteType(TagDecl *Tag) {}
32*0a6a1f1dSLionel Sambuc 
CompleteType(ObjCInterfaceDecl * Class)33*0a6a1f1dSLionel Sambuc void ExternalASTSource::CompleteType(ObjCInterfaceDecl *Class) {}
34*0a6a1f1dSLionel Sambuc 
ReadComments()35*0a6a1f1dSLionel Sambuc void ExternalASTSource::ReadComments() {}
36*0a6a1f1dSLionel Sambuc 
StartedDeserializing()37*0a6a1f1dSLionel Sambuc void ExternalASTSource::StartedDeserializing() {}
38*0a6a1f1dSLionel Sambuc 
FinishedDeserializing()39*0a6a1f1dSLionel Sambuc void ExternalASTSource::FinishedDeserializing() {}
40*0a6a1f1dSLionel Sambuc 
StartTranslationUnit(ASTConsumer * Consumer)41*0a6a1f1dSLionel Sambuc void ExternalASTSource::StartTranslationUnit(ASTConsumer *Consumer) {}
42*0a6a1f1dSLionel Sambuc 
PrintStats()43f4a2713aSLionel Sambuc void ExternalASTSource::PrintStats() { }
44f4a2713aSLionel Sambuc 
layoutRecordType(const RecordDecl * Record,uint64_t & Size,uint64_t & Alignment,llvm::DenseMap<const FieldDecl *,uint64_t> & FieldOffsets,llvm::DenseMap<const CXXRecordDecl *,CharUnits> & BaseOffsets,llvm::DenseMap<const CXXRecordDecl *,CharUnits> & VirtualBaseOffsets)45*0a6a1f1dSLionel Sambuc bool ExternalASTSource::layoutRecordType(
46*0a6a1f1dSLionel Sambuc     const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
47*0a6a1f1dSLionel Sambuc     llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets,
48*0a6a1f1dSLionel Sambuc     llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets,
49*0a6a1f1dSLionel Sambuc     llvm::DenseMap<const CXXRecordDecl *, CharUnits> &VirtualBaseOffsets) {
50*0a6a1f1dSLionel Sambuc   return false;
51*0a6a1f1dSLionel Sambuc }
52*0a6a1f1dSLionel Sambuc 
GetExternalDecl(uint32_t ID)53f4a2713aSLionel Sambuc Decl *ExternalASTSource::GetExternalDecl(uint32_t ID) {
54*0a6a1f1dSLionel Sambuc   return nullptr;
55f4a2713aSLionel Sambuc }
56f4a2713aSLionel Sambuc 
GetExternalSelector(uint32_t ID)57f4a2713aSLionel Sambuc Selector ExternalASTSource::GetExternalSelector(uint32_t ID) {
58f4a2713aSLionel Sambuc   return Selector();
59f4a2713aSLionel Sambuc }
60f4a2713aSLionel Sambuc 
GetNumExternalSelectors()61f4a2713aSLionel Sambuc uint32_t ExternalASTSource::GetNumExternalSelectors() {
62f4a2713aSLionel Sambuc    return 0;
63f4a2713aSLionel Sambuc }
64f4a2713aSLionel Sambuc 
GetExternalDeclStmt(uint64_t Offset)65f4a2713aSLionel Sambuc Stmt *ExternalASTSource::GetExternalDeclStmt(uint64_t Offset) {
66*0a6a1f1dSLionel Sambuc   return nullptr;
67f4a2713aSLionel Sambuc }
68f4a2713aSLionel Sambuc 
69f4a2713aSLionel Sambuc CXXBaseSpecifier *
GetExternalCXXBaseSpecifiers(uint64_t Offset)70f4a2713aSLionel Sambuc ExternalASTSource::GetExternalCXXBaseSpecifiers(uint64_t Offset) {
71*0a6a1f1dSLionel Sambuc   return nullptr;
72f4a2713aSLionel Sambuc }
73f4a2713aSLionel Sambuc 
74f4a2713aSLionel Sambuc bool
FindExternalVisibleDeclsByName(const DeclContext * DC,DeclarationName Name)75f4a2713aSLionel Sambuc ExternalASTSource::FindExternalVisibleDeclsByName(const DeclContext *DC,
76f4a2713aSLionel Sambuc                                                   DeclarationName Name) {
77f4a2713aSLionel Sambuc   return false;
78f4a2713aSLionel Sambuc }
79f4a2713aSLionel Sambuc 
completeVisibleDeclsMap(const DeclContext * DC)80f4a2713aSLionel Sambuc void ExternalASTSource::completeVisibleDeclsMap(const DeclContext *DC) {
81f4a2713aSLionel Sambuc }
82f4a2713aSLionel Sambuc 
83f4a2713aSLionel Sambuc ExternalLoadResult
FindExternalLexicalDecls(const DeclContext * DC,bool (* isKindWeWant)(Decl::Kind),SmallVectorImpl<Decl * > & Result)84f4a2713aSLionel Sambuc ExternalASTSource::FindExternalLexicalDecls(const DeclContext *DC,
85f4a2713aSLionel Sambuc                                             bool (*isKindWeWant)(Decl::Kind),
86f4a2713aSLionel Sambuc                                          SmallVectorImpl<Decl*> &Result) {
87f4a2713aSLionel Sambuc   return ELR_AlreadyLoaded;
88f4a2713aSLionel Sambuc }
89f4a2713aSLionel Sambuc 
getMemoryBufferSizes(MemoryBufferSizes & sizes) const90f4a2713aSLionel Sambuc void ExternalASTSource::getMemoryBufferSizes(MemoryBufferSizes &sizes) const { }
91*0a6a1f1dSLionel Sambuc 
incrementGeneration(ASTContext & C)92*0a6a1f1dSLionel Sambuc uint32_t ExternalASTSource::incrementGeneration(ASTContext &C) {
93*0a6a1f1dSLionel Sambuc   uint32_t OldGeneration = CurrentGeneration;
94*0a6a1f1dSLionel Sambuc 
95*0a6a1f1dSLionel Sambuc   // Make sure the generation of the topmost external source for the context is
96*0a6a1f1dSLionel Sambuc   // incremented. That might not be us.
97*0a6a1f1dSLionel Sambuc   auto *P = C.getExternalSource();
98*0a6a1f1dSLionel Sambuc   if (P && P != this)
99*0a6a1f1dSLionel Sambuc     CurrentGeneration = P->incrementGeneration(C);
100*0a6a1f1dSLionel Sambuc   else {
101*0a6a1f1dSLionel Sambuc     // FIXME: Only bump the generation counter if the current generation number
102*0a6a1f1dSLionel Sambuc     // has been observed?
103*0a6a1f1dSLionel Sambuc     if (!++CurrentGeneration)
104*0a6a1f1dSLionel Sambuc       llvm::report_fatal_error("generation counter overflowed", false);
105*0a6a1f1dSLionel Sambuc   }
106*0a6a1f1dSLionel Sambuc 
107*0a6a1f1dSLionel Sambuc   return OldGeneration;
108*0a6a1f1dSLionel Sambuc }
109