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
21 using namespace clang;
22
~ExternalASTSource()23 ExternalASTSource::~ExternalASTSource() { }
24
FindFileRegionDecls(FileID File,unsigned Offset,unsigned Length,SmallVectorImpl<Decl * > & Decls)25 void ExternalASTSource::FindFileRegionDecls(FileID File, unsigned Offset,
26 unsigned Length,
27 SmallVectorImpl<Decl *> &Decls) {}
28
CompleteRedeclChain(const Decl * D)29 void ExternalASTSource::CompleteRedeclChain(const Decl *D) {}
30
CompleteType(TagDecl * Tag)31 void ExternalASTSource::CompleteType(TagDecl *Tag) {}
32
CompleteType(ObjCInterfaceDecl * Class)33 void ExternalASTSource::CompleteType(ObjCInterfaceDecl *Class) {}
34
ReadComments()35 void ExternalASTSource::ReadComments() {}
36
StartedDeserializing()37 void ExternalASTSource::StartedDeserializing() {}
38
FinishedDeserializing()39 void ExternalASTSource::FinishedDeserializing() {}
40
StartTranslationUnit(ASTConsumer * Consumer)41 void ExternalASTSource::StartTranslationUnit(ASTConsumer *Consumer) {}
42
PrintStats()43 void ExternalASTSource::PrintStats() { }
44
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 bool ExternalASTSource::layoutRecordType(
46 const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
47 llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets,
48 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets,
49 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &VirtualBaseOffsets) {
50 return false;
51 }
52
GetExternalDecl(uint32_t ID)53 Decl *ExternalASTSource::GetExternalDecl(uint32_t ID) {
54 return nullptr;
55 }
56
GetExternalSelector(uint32_t ID)57 Selector ExternalASTSource::GetExternalSelector(uint32_t ID) {
58 return Selector();
59 }
60
GetNumExternalSelectors()61 uint32_t ExternalASTSource::GetNumExternalSelectors() {
62 return 0;
63 }
64
GetExternalDeclStmt(uint64_t Offset)65 Stmt *ExternalASTSource::GetExternalDeclStmt(uint64_t Offset) {
66 return nullptr;
67 }
68
69 CXXCtorInitializer **
GetExternalCXXCtorInitializers(uint64_t Offset)70 ExternalASTSource::GetExternalCXXCtorInitializers(uint64_t Offset) {
71 return nullptr;
72 }
73
74 CXXBaseSpecifier *
GetExternalCXXBaseSpecifiers(uint64_t Offset)75 ExternalASTSource::GetExternalCXXBaseSpecifiers(uint64_t Offset) {
76 return nullptr;
77 }
78
79 bool
FindExternalVisibleDeclsByName(const DeclContext * DC,DeclarationName Name)80 ExternalASTSource::FindExternalVisibleDeclsByName(const DeclContext *DC,
81 DeclarationName Name) {
82 return false;
83 }
84
completeVisibleDeclsMap(const DeclContext * DC)85 void ExternalASTSource::completeVisibleDeclsMap(const DeclContext *DC) {
86 }
87
88 ExternalLoadResult
FindExternalLexicalDecls(const DeclContext * DC,bool (* isKindWeWant)(Decl::Kind),SmallVectorImpl<Decl * > & Result)89 ExternalASTSource::FindExternalLexicalDecls(const DeclContext *DC,
90 bool (*isKindWeWant)(Decl::Kind),
91 SmallVectorImpl<Decl*> &Result) {
92 return ELR_AlreadyLoaded;
93 }
94
getMemoryBufferSizes(MemoryBufferSizes & sizes) const95 void ExternalASTSource::getMemoryBufferSizes(MemoryBufferSizes &sizes) const { }
96
incrementGeneration(ASTContext & C)97 uint32_t ExternalASTSource::incrementGeneration(ASTContext &C) {
98 uint32_t OldGeneration = CurrentGeneration;
99
100 // Make sure the generation of the topmost external source for the context is
101 // incremented. That might not be us.
102 auto *P = C.getExternalSource();
103 if (P && P != this)
104 CurrentGeneration = P->incrementGeneration(C);
105 else {
106 // FIXME: Only bump the generation counter if the current generation number
107 // has been observed?
108 if (!++CurrentGeneration)
109 llvm::report_fatal_error("generation counter overflowed", false);
110 }
111
112 return OldGeneration;
113 }
114