blob: e3de8c5fefa2b5e8885cf6e10c2b7f802f3c8716 [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
Adrian Prantlc6458d62015-09-19 00:10:32 +000031ExternalASTSource::ASTSourceDescriptor::ASTSourceDescriptor(const Module &M)
Adrian Prantl6083b082015-09-24 16:10:00 +000032 : Signature(M.Signature), ClangModule(&M) {
Adrian Prantlc6458d62015-09-19 00:10:32 +000033 if (M.Directory)
34 Path = M.Directory->getName();
35 if (auto *File = M.getASTFile())
36 ASTFile = File->getName();
Adrian Prantl15bcf702015-06-30 17:39:43 +000037}
38
Adrian Prantl835e6632015-09-24 16:10:10 +000039std::string ExternalASTSource::ASTSourceDescriptor::getModuleName() const {
Adrian Prantl6083b082015-09-24 16:10:00 +000040 if (ClangModule)
Adrian Prantl835e6632015-09-24 16:10:10 +000041 return ClangModule->Name;
Adrian Prantl6083b082015-09-24 16:10:00 +000042 else
43 return PCHModuleName;
44}
45
Rafael Espindolaf5bbe272014-05-21 14:19:22 +000046void ExternalASTSource::FindFileRegionDecls(FileID File, unsigned Offset,
47 unsigned Length,
48 SmallVectorImpl<Decl *> &Decls) {}
49
50void ExternalASTSource::CompleteRedeclChain(const Decl *D) {}
51
52void ExternalASTSource::CompleteType(TagDecl *Tag) {}
53
54void ExternalASTSource::CompleteType(ObjCInterfaceDecl *Class) {}
55
56void ExternalASTSource::ReadComments() {}
57
58void ExternalASTSource::StartedDeserializing() {}
59
60void ExternalASTSource::FinishedDeserializing() {}
61
62void ExternalASTSource::StartTranslationUnit(ASTConsumer *Consumer) {}
63
Axel Naumannaa627ba2011-02-28 11:22:50 +000064void ExternalASTSource::PrintStats() { }
65
Rafael Espindolaf5bbe272014-05-21 14:19:22 +000066bool ExternalASTSource::layoutRecordType(
67 const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
68 llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets,
69 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets,
70 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &VirtualBaseOffsets) {
71 return false;
72}
73
Axel Naumannaa627ba2011-02-28 11:22:50 +000074Decl *ExternalASTSource::GetExternalDecl(uint32_t ID) {
Craig Topper36250ad2014-05-12 05:36:57 +000075 return nullptr;
Axel Naumannaa627ba2011-02-28 11:22:50 +000076}
77
78Selector ExternalASTSource::GetExternalSelector(uint32_t ID) {
79 return Selector();
80}
81
82uint32_t ExternalASTSource::GetNumExternalSelectors() {
83 return 0;
84}
85
86Stmt *ExternalASTSource::GetExternalDeclStmt(uint64_t Offset) {
Craig Topper36250ad2014-05-12 05:36:57 +000087 return nullptr;
Axel Naumannaa627ba2011-02-28 11:22:50 +000088}
89
Richard Smithc2bb8182015-03-24 06:36:48 +000090CXXCtorInitializer **
91ExternalASTSource::GetExternalCXXCtorInitializers(uint64_t Offset) {
92 return nullptr;
93}
94
Axel Naumannaa627ba2011-02-28 11:22:50 +000095CXXBaseSpecifier *
96ExternalASTSource::GetExternalCXXBaseSpecifiers(uint64_t Offset) {
Craig Topper36250ad2014-05-12 05:36:57 +000097 return nullptr;
Axel Naumannaa627ba2011-02-28 11:22:50 +000098}
99
Richard Smith9ce12e32013-02-07 03:30:24 +0000100bool
Axel Naumannaa627ba2011-02-28 11:22:50 +0000101ExternalASTSource::FindExternalVisibleDeclsByName(const DeclContext *DC,
102 DeclarationName Name) {
Richard Smith9ce12e32013-02-07 03:30:24 +0000103 return false;
Axel Naumannaa627ba2011-02-28 11:22:50 +0000104}
105
Richard Smith3cb15722015-08-05 22:41:45 +0000106void ExternalASTSource::completeVisibleDeclsMap(const DeclContext *DC) {}
Nick Lewycky2bd0ab22012-04-16 02:51:46 +0000107
Richard Smith3cb15722015-08-05 22:41:45 +0000108void ExternalASTSource::FindExternalLexicalDecls(
109 const DeclContext *DC, llvm::function_ref<bool(Decl::Kind)> IsKindWeWant,
110 SmallVectorImpl<Decl *> &Result) {}
Axel Naumanned35df12011-05-04 12:59:24 +0000111
Richard Smith3cb15722015-08-05 22:41:45 +0000112void ExternalASTSource::getMemoryBufferSizes(MemoryBufferSizes &sizes) const {}
Richard Smith053f6c62014-05-16 23:01:30 +0000113
114uint32_t ExternalASTSource::incrementGeneration(ASTContext &C) {
115 uint32_t OldGeneration = CurrentGeneration;
116
117 // Make sure the generation of the topmost external source for the context is
118 // incremented. That might not be us.
119 auto *P = C.getExternalSource();
120 if (P && P != this)
121 CurrentGeneration = P->incrementGeneration(C);
122 else {
123 // FIXME: Only bump the generation counter if the current generation number
124 // has been observed?
125 if (!++CurrentGeneration)
126 llvm::report_fatal_error("generation counter overflowed", false);
127 }
128
129 return OldGeneration;
130}