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
21#include "clang/Basic/LLVM.h"
23#include "llvm/Support/ErrorHandling.h"
24#include <cstdint>
25#include <optional>
26
27using namespace clang;
28
29char ExternalASTSource::ID;
30
32
33std::optional<ASTSourceDescriptor>
35 return std::nullopt;
36}
37
40 return EK_ReplyHazy;
41}
42
44 unsigned Length,
46
48
50
52
54
56
58
60
62
64 const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
65 llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets,
66 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets,
67 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &VirtualBaseOffsets) {
68 return false;
69}
70
72
74 return Selector();
75}
76
78 return 0;
79}
80
82 return nullptr;
83}
84
87 return nullptr;
88}
89
92 return nullptr;
93}
94
95bool
97 DeclarationName Name) {
98 return false;
99}
100
102
104 const DeclContext *DC, llvm::function_ref<bool(Decl::Kind)> IsKindWeWant,
106
108
110 uint32_t OldGeneration = CurrentGeneration;
111
112 // Make sure the generation of the topmost external source for the context is
113 // incremented. That might not be us.
114 auto *P = C.getExternalSource();
115 if (P && P != this)
116 CurrentGeneration = P->incrementGeneration(C);
117 else {
118 // FIXME: Only bump the generation counter if the current generation number
119 // has been observed?
120 if (!++CurrentGeneration)
121 llvm::report_fatal_error("generation counter overflowed", false);
122 }
123
124 return OldGeneration;
125}
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::FileManager interface and associated types.
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
Defines the SourceManager interface.
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:187
Represents a base class of a C++ class.
Definition: DeclCXX.h:146
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2304
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1436
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 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 bool FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name)
Find all declarations with the given name in the given context, and add them to the context by callin...
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 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:4145
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:3561
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.