blob: 8a44c05dbb7d30d4dd72d83796d50efacfcf8aed [file] [log] [blame]
Axel Naumannaa627ba2011-02-28 11:22:50 +00001//===- 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 Smith053f6c62014-05-16 23:01:30 +000017#include "clang/AST/ASTContext.h"
Axel Naumannaa627ba2011-02-28 11:22:50 +000018#include "clang/AST/DeclarationName.h"
Richard Smith053f6c62014-05-16 23:01:30 +000019#include "llvm/Support/ErrorHandling.h"
Axel Naumannaa627ba2011-02-28 11:22:50 +000020
21using namespace clang;
22
23ExternalASTSource::~ExternalASTSource() { }
24
Adrian Prantl15bcf702015-06-30 17:39:43 +000025llvm::Optional<ExternalASTSource::ASTSourceDescriptor>
26ExternalASTSource::getSourceDescriptor(unsigned ID) {
27 return None;
28}
29
30ExternalASTSource::ASTSourceDescriptor
31ExternalASTSource::getSourceDescriptor(const Module &M) {
32 return ASTSourceDescriptor();
33}
34
Rafael Espindolaf5bbe272014-05-21 14:19:22 +000035void ExternalASTSource::FindFileRegionDecls(FileID File, unsigned Offset,
36 unsigned Length,
37 SmallVectorImpl<Decl *> &Decls) {}
38
39void ExternalASTSource::CompleteRedeclChain(const Decl *D) {}
40
41void ExternalASTSource::CompleteType(TagDecl *Tag) {}
42
43void ExternalASTSource::CompleteType(ObjCInterfaceDecl *Class) {}
44
45void ExternalASTSource::ReadComments() {}
46
47void ExternalASTSource::StartedDeserializing() {}
48
49void ExternalASTSource::FinishedDeserializing() {}
50
51void ExternalASTSource::StartTranslationUnit(ASTConsumer *Consumer) {}
52
Axel Naumannaa627ba2011-02-28 11:22:50 +000053void ExternalASTSource::PrintStats() { }
54
Rafael Espindolaf5bbe272014-05-21 14:19:22 +000055bool 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 Naumannaa627ba2011-02-28 11:22:50 +000063Decl *ExternalASTSource::GetExternalDecl(uint32_t ID) {
Craig Topper36250ad2014-05-12 05:36:57 +000064 return nullptr;
Axel Naumannaa627ba2011-02-28 11:22:50 +000065}
66
67Selector ExternalASTSource::GetExternalSelector(uint32_t ID) {
68 return Selector();
69}
70
71uint32_t ExternalASTSource::GetNumExternalSelectors() {
72 return 0;
73}
74
75Stmt *ExternalASTSource::GetExternalDeclStmt(uint64_t Offset) {
Craig Topper36250ad2014-05-12 05:36:57 +000076 return nullptr;
Axel Naumannaa627ba2011-02-28 11:22:50 +000077}
78
Richard Smithc2bb8182015-03-24 06:36:48 +000079CXXCtorInitializer **
80ExternalASTSource::GetExternalCXXCtorInitializers(uint64_t Offset) {
81 return nullptr;
82}
83
Axel Naumannaa627ba2011-02-28 11:22:50 +000084CXXBaseSpecifier *
85ExternalASTSource::GetExternalCXXBaseSpecifiers(uint64_t Offset) {
Craig Topper36250ad2014-05-12 05:36:57 +000086 return nullptr;
Axel Naumannaa627ba2011-02-28 11:22:50 +000087}
88
Richard Smith9ce12e32013-02-07 03:30:24 +000089bool
Axel Naumannaa627ba2011-02-28 11:22:50 +000090ExternalASTSource::FindExternalVisibleDeclsByName(const DeclContext *DC,
91 DeclarationName Name) {
Richard Smith9ce12e32013-02-07 03:30:24 +000092 return false;
Axel Naumannaa627ba2011-02-28 11:22:50 +000093}
94
Richard Smith3cb15722015-08-05 22:41:45 +000095void ExternalASTSource::completeVisibleDeclsMap(const DeclContext *DC) {}
Nick Lewycky2bd0ab22012-04-16 02:51:46 +000096
Richard Smith3cb15722015-08-05 22:41:45 +000097void ExternalASTSource::FindExternalLexicalDecls(
98 const DeclContext *DC, llvm::function_ref<bool(Decl::Kind)> IsKindWeWant,
99 SmallVectorImpl<Decl *> &Result) {}
Axel Naumanned35df12011-05-04 12:59:24 +0000100
Richard Smith3cb15722015-08-05 22:41:45 +0000101void ExternalASTSource::getMemoryBufferSizes(MemoryBufferSizes &sizes) const {}
Richard Smith053f6c62014-05-16 23:01:30 +0000102
103uint32_t ExternalASTSource::incrementGeneration(ASTContext &C) {
104 uint32_t OldGeneration = CurrentGeneration;
105
106 // Make sure the generation of the topmost external source for the context is
107 // incremented. That might not be us.
108 auto *P = C.getExternalSource();
109 if (P && P != this)
110 CurrentGeneration = P->incrementGeneration(C);
111 else {
112 // FIXME: Only bump the generation counter if the current generation number
113 // has been observed?
114 if (!++CurrentGeneration)
115 llvm::report_fatal_error("generation counter overflowed", false);
116 }
117
118 return OldGeneration;
119}