clang 20.0.0git
ExternalASTSource.cpp
Go to the documentation of this file.
1//===- ExternalASTSource.cpp - Abstract External AST Interface ------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file provides the default implementation of the ExternalASTSource
10// interface, which enables construction of AST nodes from some external
11// source.
12//
13//===----------------------------------------------------------------------===//
14
20#include "clang/Basic/LLVM.h"
21#include "llvm/Support/ErrorHandling.h"
22#include <cstdint>
23#include <optional>
24
25using namespace clang;
26
27char ExternalASTSource::ID;
28
30
31std::optional<ASTSourceDescriptor>
33 return std::nullopt;
34}
35
38 return EK_ReplyHazy;
39}
40
42 unsigned Length,
44
46
48
50
52
54
56
58
60
62 const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
63 llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets,
64 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets,
65 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &VirtualBaseOffsets) {
66 return false;
67}
68
70
72 return Selector();
73}
74
76 return 0;
77}
78
80 return nullptr;
81}
82
85 return nullptr;
86}
87
90 return nullptr;
91}
92
94 const DeclContext *DC, DeclarationName Name,
95 const DeclContext *OriginalDC) {
96 return false;
97}
98
100 return false;
101}
102
105 return false;
106}
107
109
111 const DeclContext *DC, llvm::function_ref<bool(Decl::Kind)> IsKindWeWant,
113
115
117 uint32_t OldGeneration = CurrentGeneration;
118
119 // Make sure the generation of the topmost external source for the context is
120 // incremented. That might not be us.
121 auto *P = C.getExternalSource();
122 if (P && P != this)
123 CurrentGeneration = P->incrementGeneration(C);
124 else {
125 // FIXME: Only bump the generation counter if the current generation number
126 // has been observed?
127 if (!++CurrentGeneration)
128 llvm::report_fatal_error("generation counter overflowed", false);
129 }
130
131 return OldGeneration;
132}
Defines the clang::ASTContext interface.
StringRef P
Defines the clang::ASTSourceDescriptor class, which abstracts clang modules and precompiled header fi...
const Decl * D
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
llvm::MachO::Record Record
Definition: MachO.h:31
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs.
Definition: ASTConsumer.h:34
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:188
Represents a base class of a C++ class.
Definition: DeclCXX.h:146
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2318
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1435
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
Kind
Lists the kind of concrete classes of Decl.
Definition: DeclBase.h:89
The name of a declaration.
virtual ExtKind hasExternalDefinitions(const Decl *D)
virtual void StartTranslationUnit(ASTConsumer *Consumer)
Function that will be invoked when we begin parsing a new translation unit involving this external AS...
virtual std::optional< ASTSourceDescriptor > getSourceDescriptor(unsigned ID)
Return a descriptor for the corresponding module, if one exists.
MemoryBufferSizes getMemoryBufferSizes() const
Return the amount of memory used by memory buffers, breaking down by heap-backed versus mmap'ed memor...
uint32_t incrementGeneration(ASTContext &C)
Increment the current generation.
virtual CXXCtorInitializer ** GetExternalCXXCtorInitializers(uint64_t Offset)
Resolve the offset of a set of C++ constructor initializers in the decl stream into an array of initi...
virtual void FinishedDeserializing()
Notify ExternalASTSource that we finished the deserialization of a decl or type.
virtual Selector GetExternalSelector(uint32_t ID)
Resolve a selector ID into a selector.
virtual uint32_t GetNumExternalSelectors()
Returns the number of selectors known to the external AST source.
virtual void ReadComments()
Loads comment ranges.
virtual void CompleteRedeclChain(const Decl *D)
Gives the external AST source an opportunity to complete the redeclaration chain for a declaration.
virtual void FindFileRegionDecls(FileID File, unsigned Offset, unsigned Length, SmallVectorImpl< Decl * > &Decls)
Get the decls that are contained in a file in the Offset/Length range.
virtual bool LoadExternalSpecializations(const Decl *D, bool OnlyPartial)
Load all the external specializations for the Decl.
virtual Decl * GetExternalDecl(GlobalDeclID ID)
Resolve a declaration ID into a declaration, potentially building a new declaration.
virtual void PrintStats()
Print any statistics that have been gathered regarding the external AST source.
virtual Stmt * GetExternalDeclStmt(uint64_t Offset)
Resolve the offset of a statement in the decl stream into a statement.
virtual void StartedDeserializing()
Notify ExternalASTSource that we started deserialization of a decl or type so until FinishedDeseriali...
virtual CXXBaseSpecifier * GetExternalCXXBaseSpecifiers(uint64_t Offset)
Resolve the offset of a set of C++ base specifiers in the decl stream into an array of specifiers.
virtual bool layoutRecordType(const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment, llvm::DenseMap< const FieldDecl *, uint64_t > &FieldOffsets, llvm::DenseMap< const CXXRecordDecl *, CharUnits > &BaseOffsets, llvm::DenseMap< const CXXRecordDecl *, CharUnits > &VirtualBaseOffsets)
Perform layout on the given record.
virtual bool FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name, const DeclContext *OriginalDC)
Find all declarations with the given name in the given context, and add them to the context by callin...
virtual void CompleteType(TagDecl *Tag)
Gives the external AST source an opportunity to complete an incomplete type.
virtual void completeVisibleDeclsMap(const DeclContext *DC)
Ensures that the table of all visible declarations inside this context is up to date.
virtual void FindExternalLexicalDecls(const DeclContext *DC, llvm::function_ref< bool(Decl::Kind)> IsKindWeWant, SmallVectorImpl< Decl * > &Result)
Finds all declarations lexically contained within the given DeclContext, after applying an optional f...
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Represents an ObjC class declaration.
Definition: DeclObjC.h:1153
Represents a struct/union/class.
Definition: Decl.h:4162
Smart pointer class that efficiently represents Objective-C method names.
Stmt - This represents one statement.
Definition: Stmt.h:84
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3578
The JSON file list parser is used to communicate input to InstallAPI.
@ Result
The result type of a method or function.
@ Class
The "class" keyword introduces the elaborated-type-specifier.