blob: 88941075dd0640687c2736de91de24c138e36279 [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
Rafael Espindolaf5bbe272014-05-21 14:19:22 +000025void ExternalASTSource::FindFileRegionDecls(FileID File, unsigned Offset,
26 unsigned Length,
27 SmallVectorImpl<Decl *> &Decls) {}
28
29void ExternalASTSource::CompleteRedeclChain(const Decl *D) {}
30
31void ExternalASTSource::CompleteType(TagDecl *Tag) {}
32
33void ExternalASTSource::CompleteType(ObjCInterfaceDecl *Class) {}
34
35void ExternalASTSource::ReadComments() {}
36
37void ExternalASTSource::StartedDeserializing() {}
38
39void ExternalASTSource::FinishedDeserializing() {}
40
41void ExternalASTSource::StartTranslationUnit(ASTConsumer *Consumer) {}
42
Axel Naumannaa627ba2011-02-28 11:22:50 +000043void ExternalASTSource::PrintStats() { }
44
Rafael Espindolaf5bbe272014-05-21 14:19:22 +000045bool ExternalASTSource::layoutRecordType(
46 const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
47 llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets,
48 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets,
49 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &VirtualBaseOffsets) {
50 return false;
51}
52
Axel Naumannaa627ba2011-02-28 11:22:50 +000053Decl *ExternalASTSource::GetExternalDecl(uint32_t ID) {
Craig Topper36250ad2014-05-12 05:36:57 +000054 return nullptr;
Axel Naumannaa627ba2011-02-28 11:22:50 +000055}
56
57Selector ExternalASTSource::GetExternalSelector(uint32_t ID) {
58 return Selector();
59}
60
61uint32_t ExternalASTSource::GetNumExternalSelectors() {
62 return 0;
63}
64
65Stmt *ExternalASTSource::GetExternalDeclStmt(uint64_t Offset) {
Craig Topper36250ad2014-05-12 05:36:57 +000066 return nullptr;
Axel Naumannaa627ba2011-02-28 11:22:50 +000067}
68
69CXXBaseSpecifier *
70ExternalASTSource::GetExternalCXXBaseSpecifiers(uint64_t Offset) {
Craig Topper36250ad2014-05-12 05:36:57 +000071 return nullptr;
Axel Naumannaa627ba2011-02-28 11:22:50 +000072}
73
Richard Smith9ce12e32013-02-07 03:30:24 +000074bool
Axel Naumannaa627ba2011-02-28 11:22:50 +000075ExternalASTSource::FindExternalVisibleDeclsByName(const DeclContext *DC,
76 DeclarationName Name) {
Richard Smith9ce12e32013-02-07 03:30:24 +000077 return false;
Axel Naumannaa627ba2011-02-28 11:22:50 +000078}
79
Nick Lewycky2bd0ab22012-04-16 02:51:46 +000080void ExternalASTSource::completeVisibleDeclsMap(const DeclContext *DC) {
81}
82
83ExternalLoadResult
Axel Naumannaa627ba2011-02-28 11:22:50 +000084ExternalASTSource::FindExternalLexicalDecls(const DeclContext *DC,
85 bool (*isKindWeWant)(Decl::Kind),
Chris Lattner0e62c1c2011-07-23 10:55:15 +000086 SmallVectorImpl<Decl*> &Result) {
Douglas Gregor3d0adb32011-07-15 21:46:17 +000087 return ELR_AlreadyLoaded;
Axel Naumannaa627ba2011-02-28 11:22:50 +000088}
Axel Naumanned35df12011-05-04 12:59:24 +000089
90void ExternalASTSource::getMemoryBufferSizes(MemoryBufferSizes &sizes) const { }
Richard Smith053f6c62014-05-16 23:01:30 +000091
92uint32_t ExternalASTSource::incrementGeneration(ASTContext &C) {
93 uint32_t OldGeneration = CurrentGeneration;
94
95 // Make sure the generation of the topmost external source for the context is
96 // incremented. That might not be us.
97 auto *P = C.getExternalSource();
98 if (P && P != this)
99 CurrentGeneration = P->incrementGeneration(C);
100 else {
101 // FIXME: Only bump the generation counter if the current generation number
102 // has been observed?
103 if (!++CurrentGeneration)
104 llvm::report_fatal_error("generation counter overflowed", false);
105 }
106
107 return OldGeneration;
108}