Axel Naumann | aa627ba | 2011-02-28 11:22:50 +0000 | [diff] [blame] | 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" |
Richard Smith | 053f6c6 | 2014-05-16 23:01:30 +0000 | [diff] [blame] | 17 | #include "clang/AST/ASTContext.h" |
Axel Naumann | aa627ba | 2011-02-28 11:22:50 +0000 | [diff] [blame] | 18 | #include "clang/AST/DeclarationName.h" |
Richard Smith | 053f6c6 | 2014-05-16 23:01:30 +0000 | [diff] [blame] | 19 | #include "llvm/Support/ErrorHandling.h" |
Axel Naumann | aa627ba | 2011-02-28 11:22:50 +0000 | [diff] [blame] | 20 | |
| 21 | using namespace clang; |
| 22 | |
| 23 | ExternalASTSource::~ExternalASTSource() { } |
| 24 | |
Adrian Prantl | 15bcf70 | 2015-06-30 17:39:43 +0000 | [diff] [blame^] | 25 | llvm::Optional<ExternalASTSource::ASTSourceDescriptor> |
| 26 | ExternalASTSource::getSourceDescriptor(unsigned ID) { |
| 27 | return None; |
| 28 | } |
| 29 | |
| 30 | ExternalASTSource::ASTSourceDescriptor |
| 31 | ExternalASTSource::getSourceDescriptor(const Module &M) { |
| 32 | return ASTSourceDescriptor(); |
| 33 | } |
| 34 | |
Rafael Espindola | f5bbe27 | 2014-05-21 14:19:22 +0000 | [diff] [blame] | 35 | void ExternalASTSource::FindFileRegionDecls(FileID File, unsigned Offset, |
| 36 | unsigned Length, |
| 37 | SmallVectorImpl<Decl *> &Decls) {} |
| 38 | |
| 39 | void ExternalASTSource::CompleteRedeclChain(const Decl *D) {} |
| 40 | |
| 41 | void ExternalASTSource::CompleteType(TagDecl *Tag) {} |
| 42 | |
| 43 | void ExternalASTSource::CompleteType(ObjCInterfaceDecl *Class) {} |
| 44 | |
| 45 | void ExternalASTSource::ReadComments() {} |
| 46 | |
| 47 | void ExternalASTSource::StartedDeserializing() {} |
| 48 | |
| 49 | void ExternalASTSource::FinishedDeserializing() {} |
| 50 | |
| 51 | void ExternalASTSource::StartTranslationUnit(ASTConsumer *Consumer) {} |
| 52 | |
Axel Naumann | aa627ba | 2011-02-28 11:22:50 +0000 | [diff] [blame] | 53 | void ExternalASTSource::PrintStats() { } |
| 54 | |
Rafael Espindola | f5bbe27 | 2014-05-21 14:19:22 +0000 | [diff] [blame] | 55 | bool 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 | |
Axel Naumann | aa627ba | 2011-02-28 11:22:50 +0000 | [diff] [blame] | 63 | Decl *ExternalASTSource::GetExternalDecl(uint32_t ID) { |
Craig Topper | 36250ad | 2014-05-12 05:36:57 +0000 | [diff] [blame] | 64 | return nullptr; |
Axel Naumann | aa627ba | 2011-02-28 11:22:50 +0000 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | Selector ExternalASTSource::GetExternalSelector(uint32_t ID) { |
| 68 | return Selector(); |
| 69 | } |
| 70 | |
| 71 | uint32_t ExternalASTSource::GetNumExternalSelectors() { |
| 72 | return 0; |
| 73 | } |
| 74 | |
| 75 | Stmt *ExternalASTSource::GetExternalDeclStmt(uint64_t Offset) { |
Craig Topper | 36250ad | 2014-05-12 05:36:57 +0000 | [diff] [blame] | 76 | return nullptr; |
Axel Naumann | aa627ba | 2011-02-28 11:22:50 +0000 | [diff] [blame] | 77 | } |
| 78 | |
Richard Smith | c2bb818 | 2015-03-24 06:36:48 +0000 | [diff] [blame] | 79 | CXXCtorInitializer ** |
| 80 | ExternalASTSource::GetExternalCXXCtorInitializers(uint64_t Offset) { |
| 81 | return nullptr; |
| 82 | } |
| 83 | |
Axel Naumann | aa627ba | 2011-02-28 11:22:50 +0000 | [diff] [blame] | 84 | CXXBaseSpecifier * |
| 85 | ExternalASTSource::GetExternalCXXBaseSpecifiers(uint64_t Offset) { |
Craig Topper | 36250ad | 2014-05-12 05:36:57 +0000 | [diff] [blame] | 86 | return nullptr; |
Axel Naumann | aa627ba | 2011-02-28 11:22:50 +0000 | [diff] [blame] | 87 | } |
| 88 | |
Richard Smith | 9ce12e3 | 2013-02-07 03:30:24 +0000 | [diff] [blame] | 89 | bool |
Axel Naumann | aa627ba | 2011-02-28 11:22:50 +0000 | [diff] [blame] | 90 | ExternalASTSource::FindExternalVisibleDeclsByName(const DeclContext *DC, |
| 91 | DeclarationName Name) { |
Richard Smith | 9ce12e3 | 2013-02-07 03:30:24 +0000 | [diff] [blame] | 92 | return false; |
Axel Naumann | aa627ba | 2011-02-28 11:22:50 +0000 | [diff] [blame] | 93 | } |
| 94 | |
Nick Lewycky | 2bd0ab2 | 2012-04-16 02:51:46 +0000 | [diff] [blame] | 95 | void ExternalASTSource::completeVisibleDeclsMap(const DeclContext *DC) { |
| 96 | } |
| 97 | |
| 98 | ExternalLoadResult |
Axel Naumann | aa627ba | 2011-02-28 11:22:50 +0000 | [diff] [blame] | 99 | ExternalASTSource::FindExternalLexicalDecls(const DeclContext *DC, |
| 100 | bool (*isKindWeWant)(Decl::Kind), |
Chris Lattner | 0e62c1c | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 101 | SmallVectorImpl<Decl*> &Result) { |
Douglas Gregor | 3d0adb3 | 2011-07-15 21:46:17 +0000 | [diff] [blame] | 102 | return ELR_AlreadyLoaded; |
Axel Naumann | aa627ba | 2011-02-28 11:22:50 +0000 | [diff] [blame] | 103 | } |
Axel Naumann | ed35df1 | 2011-05-04 12:59:24 +0000 | [diff] [blame] | 104 | |
| 105 | void ExternalASTSource::getMemoryBufferSizes(MemoryBufferSizes &sizes) const { } |
Richard Smith | 053f6c6 | 2014-05-16 23:01:30 +0000 | [diff] [blame] | 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 | } |