blob: 198ba9d4fbdba3f0ded9f0c611204a6a46132d30 [file] [log] [blame]
Eugene Zelenko0d00c892017-11-08 00:39:18 +00001//===- ExternalASTSource.cpp - Abstract External AST Interface ------------===//
Axel Naumannaa627ba2011-02-28 11:22:50 +00002//
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"
Eugene Zelenko0d00c892017-11-08 00:39:18 +000019#include "clang/Basic/IdentifierTable.h"
20#include "clang/Basic/LLVM.h"
Adrian Prantlc6458d62015-09-19 00:10:32 +000021#include "clang/Basic/Module.h"
Eugene Zelenko0d00c892017-11-08 00:39:18 +000022#include "llvm/ADT/None.h"
Richard Smith053f6c62014-05-16 23:01:30 +000023#include "llvm/Support/ErrorHandling.h"
Eugene Zelenko0d00c892017-11-08 00:39:18 +000024#include <cstdint>
Axel Naumannaa627ba2011-02-28 11:22:50 +000025
26using namespace clang;
27
Eugene Zelenko0d00c892017-11-08 00:39:18 +000028ExternalASTSource::~ExternalASTSource() = default;
Axel Naumannaa627ba2011-02-28 11:22:50 +000029
Adrian Prantl15bcf702015-06-30 17:39:43 +000030llvm::Optional<ExternalASTSource::ASTSourceDescriptor>
31ExternalASTSource::getSourceDescriptor(unsigned ID) {
32 return None;
33}
34
David Blaikie9ffe5a32017-01-30 05:00:26 +000035ExternalASTSource::ExtKind
David Blaikie1ac9c982017-04-11 21:13:37 +000036ExternalASTSource::hasExternalDefinitions(const Decl *D) {
David Blaikie9ffe5a32017-01-30 05:00:26 +000037 return EK_ReplyHazy;
38}
39
Adrian Prantlc6458d62015-09-19 00:10:32 +000040ExternalASTSource::ASTSourceDescriptor::ASTSourceDescriptor(const Module &M)
Adrian Prantl6083b082015-09-24 16:10:00 +000041 : Signature(M.Signature), ClangModule(&M) {
Adrian Prantlc6458d62015-09-19 00:10:32 +000042 if (M.Directory)
43 Path = M.Directory->getName();
44 if (auto *File = M.getASTFile())
45 ASTFile = File->getName();
Adrian Prantl15bcf702015-06-30 17:39:43 +000046}
47
Adrian Prantl835e6632015-09-24 16:10:10 +000048std::string ExternalASTSource::ASTSourceDescriptor::getModuleName() const {
Adrian Prantl6083b082015-09-24 16:10:00 +000049 if (ClangModule)
Adrian Prantl835e6632015-09-24 16:10:10 +000050 return ClangModule->Name;
Adrian Prantl6083b082015-09-24 16:10:00 +000051 else
52 return PCHModuleName;
53}
54
Rafael Espindolaf5bbe272014-05-21 14:19:22 +000055void ExternalASTSource::FindFileRegionDecls(FileID File, unsigned Offset,
56 unsigned Length,
57 SmallVectorImpl<Decl *> &Decls) {}
58
59void ExternalASTSource::CompleteRedeclChain(const Decl *D) {}
60
61void ExternalASTSource::CompleteType(TagDecl *Tag) {}
62
63void ExternalASTSource::CompleteType(ObjCInterfaceDecl *Class) {}
64
65void ExternalASTSource::ReadComments() {}
66
67void ExternalASTSource::StartedDeserializing() {}
68
69void ExternalASTSource::FinishedDeserializing() {}
70
71void ExternalASTSource::StartTranslationUnit(ASTConsumer *Consumer) {}
72
Eugene Zelenko0d00c892017-11-08 00:39:18 +000073void ExternalASTSource::PrintStats() {}
Axel Naumannaa627ba2011-02-28 11:22:50 +000074
Rafael Espindolaf5bbe272014-05-21 14:19:22 +000075bool ExternalASTSource::layoutRecordType(
76 const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
77 llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets,
78 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets,
79 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &VirtualBaseOffsets) {
80 return false;
81}
82
Axel Naumannaa627ba2011-02-28 11:22:50 +000083Decl *ExternalASTSource::GetExternalDecl(uint32_t ID) {
Craig Topper36250ad2014-05-12 05:36:57 +000084 return nullptr;
Axel Naumannaa627ba2011-02-28 11:22:50 +000085}
86
87Selector ExternalASTSource::GetExternalSelector(uint32_t ID) {
88 return Selector();
89}
90
91uint32_t ExternalASTSource::GetNumExternalSelectors() {
92 return 0;
93}
94
95Stmt *ExternalASTSource::GetExternalDeclStmt(uint64_t Offset) {
Craig Topper36250ad2014-05-12 05:36:57 +000096 return nullptr;
Axel Naumannaa627ba2011-02-28 11:22:50 +000097}
98
Richard Smithc2bb8182015-03-24 06:36:48 +000099CXXCtorInitializer **
100ExternalASTSource::GetExternalCXXCtorInitializers(uint64_t Offset) {
101 return nullptr;
102}
103
Axel Naumannaa627ba2011-02-28 11:22:50 +0000104CXXBaseSpecifier *
105ExternalASTSource::GetExternalCXXBaseSpecifiers(uint64_t Offset) {
Craig Topper36250ad2014-05-12 05:36:57 +0000106 return nullptr;
Axel Naumannaa627ba2011-02-28 11:22:50 +0000107}
108
Richard Smith9ce12e32013-02-07 03:30:24 +0000109bool
Axel Naumannaa627ba2011-02-28 11:22:50 +0000110ExternalASTSource::FindExternalVisibleDeclsByName(const DeclContext *DC,
111 DeclarationName Name) {
Richard Smith9ce12e32013-02-07 03:30:24 +0000112 return false;
Axel Naumannaa627ba2011-02-28 11:22:50 +0000113}
114
Richard Smith3cb15722015-08-05 22:41:45 +0000115void ExternalASTSource::completeVisibleDeclsMap(const DeclContext *DC) {}
Nick Lewycky2bd0ab22012-04-16 02:51:46 +0000116
Richard Smith3cb15722015-08-05 22:41:45 +0000117void ExternalASTSource::FindExternalLexicalDecls(
118 const DeclContext *DC, llvm::function_ref<bool(Decl::Kind)> IsKindWeWant,
119 SmallVectorImpl<Decl *> &Result) {}
Axel Naumanned35df12011-05-04 12:59:24 +0000120
Richard Smith3cb15722015-08-05 22:41:45 +0000121void ExternalASTSource::getMemoryBufferSizes(MemoryBufferSizes &sizes) const {}
Richard Smith053f6c62014-05-16 23:01:30 +0000122
123uint32_t ExternalASTSource::incrementGeneration(ASTContext &C) {
124 uint32_t OldGeneration = CurrentGeneration;
125
126 // Make sure the generation of the topmost external source for the context is
127 // incremented. That might not be us.
128 auto *P = C.getExternalSource();
129 if (P && P != this)
130 CurrentGeneration = P->incrementGeneration(C);
131 else {
132 // FIXME: Only bump the generation counter if the current generation number
133 // has been observed?
134 if (!++CurrentGeneration)
135 llvm::report_fatal_error("generation counter overflowed", false);
136 }
137
138 return OldGeneration;
139}