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 "clang/Basic/Module.h" 20 #include "llvm/Support/ErrorHandling.h" 21 22 using namespace clang; 23 24 ExternalASTSource::~ExternalASTSource() { } 25 26 llvm::Optional<ExternalASTSource::ASTSourceDescriptor> 27 ExternalASTSource::getSourceDescriptor(unsigned ID) { 28 return None; 29 } 30 31 ExternalASTSource::ASTSourceDescriptor::ASTSourceDescriptor(const Module &M) 32 : FullModuleName(M.getFullModuleName()), Signature(M.Signature) { 33 if (M.Directory) 34 Path = M.Directory->getName(); 35 if (auto *File = M.getASTFile()) 36 ASTFile = File->getName(); 37 } 38 39 void ExternalASTSource::FindFileRegionDecls(FileID File, unsigned Offset, 40 unsigned Length, 41 SmallVectorImpl<Decl *> &Decls) {} 42 43 void ExternalASTSource::CompleteRedeclChain(const Decl *D) {} 44 45 void ExternalASTSource::CompleteType(TagDecl *Tag) {} 46 47 void ExternalASTSource::CompleteType(ObjCInterfaceDecl *Class) {} 48 49 void ExternalASTSource::ReadComments() {} 50 51 void ExternalASTSource::StartedDeserializing() {} 52 53 void ExternalASTSource::FinishedDeserializing() {} 54 55 void ExternalASTSource::StartTranslationUnit(ASTConsumer *Consumer) {} 56 57 void ExternalASTSource::PrintStats() { } 58 59 bool ExternalASTSource::layoutRecordType( 60 const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment, 61 llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets, 62 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets, 63 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &VirtualBaseOffsets) { 64 return false; 65 } 66 67 Decl *ExternalASTSource::GetExternalDecl(uint32_t ID) { 68 return nullptr; 69 } 70 71 Selector ExternalASTSource::GetExternalSelector(uint32_t ID) { 72 return Selector(); 73 } 74 75 uint32_t ExternalASTSource::GetNumExternalSelectors() { 76 return 0; 77 } 78 79 Stmt *ExternalASTSource::GetExternalDeclStmt(uint64_t Offset) { 80 return nullptr; 81 } 82 83 CXXCtorInitializer ** 84 ExternalASTSource::GetExternalCXXCtorInitializers(uint64_t Offset) { 85 return nullptr; 86 } 87 88 CXXBaseSpecifier * 89 ExternalASTSource::GetExternalCXXBaseSpecifiers(uint64_t Offset) { 90 return nullptr; 91 } 92 93 bool 94 ExternalASTSource::FindExternalVisibleDeclsByName(const DeclContext *DC, 95 DeclarationName Name) { 96 return false; 97 } 98 99 void ExternalASTSource::completeVisibleDeclsMap(const DeclContext *DC) {} 100 101 void ExternalASTSource::FindExternalLexicalDecls( 102 const DeclContext *DC, llvm::function_ref<bool(Decl::Kind)> IsKindWeWant, 103 SmallVectorImpl<Decl *> &Result) {} 104 105 void ExternalASTSource::getMemoryBufferSizes(MemoryBufferSizes &sizes) const {} 106 107 uint32_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