clang 22.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 return false;
43}
44
46 unsigned Length,
48
50
52
54
56
58
60
62
64
66 const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
67 llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets,
68 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets,
69 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &VirtualBaseOffsets) {
70 return false;
71}
72
74
76 return Selector();
77}
78
80 return 0;
81}
82
84 return nullptr;
85}
86
89 return nullptr;
90}
91
94 return nullptr;
95}
96
98 const DeclContext *DC, DeclarationName Name,
99 const DeclContext *OriginalDC) {
100 return false;
101}
102
104 return false;
105}
106
109 return false;
110}
111
113
115 const DeclContext *DC, llvm::function_ref<bool(Decl::Kind)> IsKindWeWant,
117
119
121 uint32_t OldGeneration = CurrentGeneration;
122
123 // Make sure the generation of the topmost external source for the context is
124 // incremented. That might not be us.
125 auto *P = C.getExternalSource();
126 if (P && P != this)
127 CurrentGeneration = P->incrementGeneration(C);
128 else {
129 // FIXME: Only bump the generation counter if the current generation number
130 // has been observed?
131 if (!++CurrentGeneration)
132 llvm::reportFatalUsageError("generation counter overflowed");
133 }
134
135 return OldGeneration;
136}
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:2369
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1449
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 bool wasThisDeclarationADefinition(const FunctionDecl *FD)
True if this function declaration was a definition before in its own module.
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 a function declaration or definition.
Definition: Decl.h:1999
Represents an ObjC class declaration.
Definition: DeclObjC.h:1154
Represents a struct/union/class.
Definition: Decl.h:4309
Smart pointer class that efficiently represents Objective-C method names.
Stmt - This represents one statement.
Definition: Stmt.h:85
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3714
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.