blob: 182d38242f596dace3ebe3c7591f4076985d1d46 [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"
Adrian Prantlc6458d62015-09-19 00:10:32 +000019#include "clang/Basic/Module.h"
Richard Smith053f6c62014-05-16 23:01:30 +000020#include "llvm/Support/ErrorHandling.h"
Axel Naumannaa627ba2011-02-28 11:22:50 +000021
22using namespace clang;
23
Angel Garcia Gomez637d1e62015-10-20 13:23:58 +000024ExternalASTSource::~ExternalASTSource() { }
Axel Naumannaa627ba2011-02-28 11:22:50 +000025
Adrian Prantl15bcf702015-06-30 17:39:43 +000026llvm::Optional<ExternalASTSource::ASTSourceDescriptor>
27ExternalASTSource::getSourceDescriptor(unsigned ID) {
28 return None;
29}
30
David Blaikie9ffe5a32017-01-30 05:00:26 +000031ExternalASTSource::ExtKind
David Blaikie1ac9c982017-04-11 21:13:37 +000032ExternalASTSource::hasExternalDefinitions(const Decl *D) {
David Blaikie9ffe5a32017-01-30 05:00:26 +000033 return EK_ReplyHazy;
34}
35
Adrian Prantlc6458d62015-09-19 00:10:32 +000036ExternalASTSource::ASTSourceDescriptor::ASTSourceDescriptor(const Module &M)
Adrian Prantl6083b082015-09-24 16:10:00 +000037 : Signature(M.Signature), ClangModule(&M) {
Adrian Prantlc6458d62015-09-19 00:10:32 +000038 if (M.Directory)
39 Path = M.Directory->getName();
40 if (auto *File = M.getASTFile())
41 ASTFile = File->getName();
Adrian Prantl15bcf702015-06-30 17:39:43 +000042}
43
Adrian Prantl835e6632015-09-24 16:10:10 +000044std::string ExternalASTSource::ASTSourceDescriptor::getModuleName() const {
Adrian Prantl6083b082015-09-24 16:10:00 +000045 if (ClangModule)
Adrian Prantl835e6632015-09-24 16:10:10 +000046 return ClangModule->Name;
Adrian Prantl6083b082015-09-24 16:10:00 +000047 else
48 return PCHModuleName;
49}
50
Rafael Espindolaf5bbe272014-05-21 14:19:22 +000051void ExternalASTSource::FindFileRegionDecls(FileID File, unsigned Offset,
52 unsigned Length,
53 SmallVectorImpl<Decl *> &Decls) {}
54
55void ExternalASTSource::CompleteRedeclChain(const Decl *D) {}
56
57void ExternalASTSource::CompleteType(TagDecl *Tag) {}
58
59void ExternalASTSource::CompleteType(ObjCInterfaceDecl *Class) {}
60
61void ExternalASTSource::ReadComments() {}
62
63void ExternalASTSource::StartedDeserializing() {}
64
65void ExternalASTSource::FinishedDeserializing() {}
66
67void ExternalASTSource::StartTranslationUnit(ASTConsumer *Consumer) {}
68
Axel Naumannaa627ba2011-02-28 11:22:50 +000069void ExternalASTSource::PrintStats() { }
70
Rafael Espindolaf5bbe272014-05-21 14:19:22 +000071bool 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
Axel Naumannaa627ba2011-02-28 11:22:50 +000079Decl *ExternalASTSource::GetExternalDecl(uint32_t ID) {
Craig Topper36250ad2014-05-12 05:36:57 +000080 return nullptr;
Axel Naumannaa627ba2011-02-28 11:22:50 +000081}
82
83Selector ExternalASTSource::GetExternalSelector(uint32_t ID) {
84 return Selector();
85}
86
87uint32_t ExternalASTSource::GetNumExternalSelectors() {
88 return 0;
89}
90
91Stmt *ExternalASTSource::GetExternalDeclStmt(uint64_t Offset) {
Craig Topper36250ad2014-05-12 05:36:57 +000092 return nullptr;
Axel Naumannaa627ba2011-02-28 11:22:50 +000093}
94
Richard Smithc2bb8182015-03-24 06:36:48 +000095CXXCtorInitializer **
96ExternalASTSource::GetExternalCXXCtorInitializers(uint64_t Offset) {
97 return nullptr;
98}
99
Axel Naumannaa627ba2011-02-28 11:22:50 +0000100CXXBaseSpecifier *
101ExternalASTSource::GetExternalCXXBaseSpecifiers(uint64_t Offset) {
Craig Topper36250ad2014-05-12 05:36:57 +0000102 return nullptr;
Axel Naumannaa627ba2011-02-28 11:22:50 +0000103}
104
Richard Smith9ce12e32013-02-07 03:30:24 +0000105bool
Axel Naumannaa627ba2011-02-28 11:22:50 +0000106ExternalASTSource::FindExternalVisibleDeclsByName(const DeclContext *DC,
107 DeclarationName Name) {
Richard Smith9ce12e32013-02-07 03:30:24 +0000108 return false;
Axel Naumannaa627ba2011-02-28 11:22:50 +0000109}
110
Richard Smith3cb15722015-08-05 22:41:45 +0000111void ExternalASTSource::completeVisibleDeclsMap(const DeclContext *DC) {}
Nick Lewycky2bd0ab22012-04-16 02:51:46 +0000112
Richard Smith3cb15722015-08-05 22:41:45 +0000113void ExternalASTSource::FindExternalLexicalDecls(
114 const DeclContext *DC, llvm::function_ref<bool(Decl::Kind)> IsKindWeWant,
115 SmallVectorImpl<Decl *> &Result) {}
Axel Naumanned35df12011-05-04 12:59:24 +0000116
Richard Smith3cb15722015-08-05 22:41:45 +0000117void ExternalASTSource::getMemoryBufferSizes(MemoryBufferSizes &sizes) const {}
Richard Smith053f6c62014-05-16 23:01:30 +0000118
119uint32_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}