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::ExtKind 32 ExternalASTSource::hasExternalDefinitions(unsigned ID) { 33 return EK_ReplyHazy; 34 } 35 36 ExternalASTSource::ASTSourceDescriptor::ASTSourceDescriptor(const Module &M) 37 : Signature(M.Signature), ClangModule(&M) { 38 if (M.Directory) 39 Path = M.Directory->getName(); 40 if (auto *File = M.getASTFile()) 41 ASTFile = File->getName(); 42 } 43 44 std::string ExternalASTSource::ASTSourceDescriptor::getModuleName() const { 45 if (ClangModule) 46 return ClangModule->Name; 47 else 48 return PCHModuleName; 49 } 50 51 void ExternalASTSource::FindFileRegionDecls(FileID File, unsigned Offset, 52 unsigned Length, 53 SmallVectorImpl<Decl *> &Decls) {} 54 55 void ExternalASTSource::CompleteRedeclChain(const Decl *D) {} 56 57 void ExternalASTSource::CompleteType(TagDecl *Tag) {} 58 59 void ExternalASTSource::CompleteType(ObjCInterfaceDecl *Class) {} 60 61 void ExternalASTSource::ReadComments() {} 62 63 void ExternalASTSource::StartedDeserializing() {} 64 65 void ExternalASTSource::FinishedDeserializing() {} 66 67 void ExternalASTSource::StartTranslationUnit(ASTConsumer *Consumer) {} 68 69 void ExternalASTSource::PrintStats() { } 70 71 bool ExternalASTSource::layoutRecordType( 72 const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment, 73 llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets, 74 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets, 75 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &VirtualBaseOffsets) { 76 return false; 77 } 78 79 Decl *ExternalASTSource::GetExternalDecl(uint32_t ID) { 80 return nullptr; 81 } 82 83 Selector ExternalASTSource::GetExternalSelector(uint32_t ID) { 84 return Selector(); 85 } 86 87 uint32_t ExternalASTSource::GetNumExternalSelectors() { 88 return 0; 89 } 90 91 Stmt *ExternalASTSource::GetExternalDeclStmt(uint64_t Offset) { 92 return nullptr; 93 } 94 95 CXXCtorInitializer ** 96 ExternalASTSource::GetExternalCXXCtorInitializers(uint64_t Offset) { 97 return nullptr; 98 } 99 100 CXXBaseSpecifier * 101 ExternalASTSource::GetExternalCXXBaseSpecifiers(uint64_t Offset) { 102 return nullptr; 103 } 104 105 bool 106 ExternalASTSource::FindExternalVisibleDeclsByName(const DeclContext *DC, 107 DeclarationName Name) { 108 return false; 109 } 110 111 void ExternalASTSource::completeVisibleDeclsMap(const DeclContext *DC) {} 112 113 void ExternalASTSource::FindExternalLexicalDecls( 114 const DeclContext *DC, llvm::function_ref<bool(Decl::Kind)> IsKindWeWant, 115 SmallVectorImpl<Decl *> &Result) {} 116 117 void ExternalASTSource::getMemoryBufferSizes(MemoryBufferSizes &sizes) const {} 118 119 uint32_t ExternalASTSource::incrementGeneration(ASTContext &C) { 120 uint32_t OldGeneration = CurrentGeneration; 121 122 // Make sure the generation of the topmost external source for the context is 123 // incremented. That might not be us. 124 auto *P = C.getExternalSource(); 125 if (P && P != this) 126 CurrentGeneration = P->incrementGeneration(C); 127 else { 128 // FIXME: Only bump the generation counter if the current generation number 129 // has been observed? 130 if (!++CurrentGeneration) 131 llvm::report_fatal_error("generation counter overflowed", false); 132 } 133 134 return OldGeneration; 135 } 136