clang 20.0.0git
ExternalASTSource.h
Go to the documentation of this file.
1//===- ExternalASTSource.h - Abstract External AST Interface ----*- C++ -*-===//
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 defines the ExternalASTSource interface, which enables
10// construction of AST nodes from some external source.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_AST_EXTERNALASTSOURCE_H
15#define LLVM_CLANG_AST_EXTERNALASTSOURCE_H
16
17#include "clang/AST/CharUnits.h"
18#include "clang/AST/DeclBase.h"
19#include "clang/Basic/LLVM.h"
20#include "llvm/ADT/ArrayRef.h"
21#include "llvm/ADT/DenseMap.h"
22#include "llvm/ADT/IntrusiveRefCntPtr.h"
23#include "llvm/ADT/PointerUnion.h"
24#include "llvm/ADT/STLExtras.h"
25#include "llvm/ADT/SmallVector.h"
26#include "llvm/ADT/iterator.h"
27#include "llvm/Support/PointerLikeTypeTraits.h"
28#include <algorithm>
29#include <cassert>
30#include <cstddef>
31#include <cstdint>
32#include <iterator>
33#include <new>
34#include <optional>
35#include <utility>
36
37namespace clang {
38
39class ASTConsumer;
40class ASTContext;
41class ASTSourceDescriptor;
42class CXXBaseSpecifier;
43class CXXCtorInitializer;
44class CXXRecordDecl;
45class DeclarationName;
46class FieldDecl;
47class IdentifierInfo;
48class NamedDecl;
49class ObjCInterfaceDecl;
50class RecordDecl;
51class Selector;
52class Stmt;
53class TagDecl;
54
55/// Abstract interface for external sources of AST nodes.
56///
57/// External AST sources provide AST nodes constructed from some
58/// external source, such as a precompiled header. External AST
59/// sources can resolve types and declarations from abstract IDs into
60/// actual type and declaration nodes, and read parts of declaration
61/// contexts.
62class ExternalASTSource : public RefCountedBase<ExternalASTSource> {
63 friend class ExternalSemaSource;
64
65 /// Generation number for this external AST source. Must be increased
66 /// whenever we might have added new redeclarations for existing decls.
67 uint32_t CurrentGeneration = 0;
68
69 /// LLVM-style RTTI.
70 static char ID;
71
72public:
73 ExternalASTSource() = default;
75
76 /// RAII class for safely pairing a StartedDeserializing call
77 /// with FinishedDeserializing.
79 ExternalASTSource *Source;
80
81 public:
82 explicit Deserializing(ExternalASTSource *source) : Source(source) {
83 assert(Source);
84 Source->StartedDeserializing();
85 }
86
88 Source->FinishedDeserializing();
89 }
90 };
91
92 /// Get the current generation of this AST source. This number
93 /// is incremented each time the AST source lazily extends an existing
94 /// entity.
95 uint32_t getGeneration() const { return CurrentGeneration; }
96
97 /// Resolve a declaration ID into a declaration, potentially
98 /// building a new declaration.
99 ///
100 /// This method only needs to be implemented if the AST source ever
101 /// passes back decl sets as VisibleDeclaration objects.
102 ///
103 /// The default implementation of this method is a no-op.
104 virtual Decl *GetExternalDecl(GlobalDeclID ID);
105
106 /// Resolve a selector ID into a selector.
107 ///
108 /// This operation only needs to be implemented if the AST source
109 /// returns non-zero for GetNumKnownSelectors().
110 ///
111 /// The default implementation of this method is a no-op.
112 virtual Selector GetExternalSelector(uint32_t ID);
113
114 /// Returns the number of selectors known to the external AST
115 /// source.
116 ///
117 /// The default implementation of this method is a no-op.
118 virtual uint32_t GetNumExternalSelectors();
119
120 /// Resolve the offset of a statement in the decl stream into
121 /// a statement.
122 ///
123 /// This operation is meant to be used via a LazyOffsetPtr. It only
124 /// needs to be implemented if the AST source uses methods like
125 /// FunctionDecl::setLazyBody when building decls.
126 ///
127 /// The default implementation of this method is a no-op.
128 virtual Stmt *GetExternalDeclStmt(uint64_t Offset);
129
130 /// Resolve the offset of a set of C++ constructor initializers in
131 /// the decl stream into an array of initializers.
132 ///
133 /// The default implementation of this method is a no-op.
134 virtual CXXCtorInitializer **GetExternalCXXCtorInitializers(uint64_t Offset);
135
136 /// Resolve the offset of a set of C++ base specifiers in the decl
137 /// stream into an array of specifiers.
138 ///
139 /// The default implementation of this method is a no-op.
140 virtual CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset);
141
142 /// Update an out-of-date identifier.
143 virtual void updateOutOfDateIdentifier(const IdentifierInfo &II) {}
144
145 /// Find all declarations with the given name in the given context,
146 /// and add them to the context by calling SetExternalVisibleDeclsForName
147 /// or SetNoExternalVisibleDeclsForName.
148 /// \return \c true if any declarations might have been found, \c false if
149 /// we definitely have no declarations with tbis name.
150 ///
151 /// The default implementation of this method is a no-op returning \c false.
152 virtual bool
154
155 /// Load all the external specializations for the Decl \param D if \param
156 /// OnlyPartial is false. Otherwise, load all the external **partial**
157 /// specializations for the \param D.
158 ///
159 /// Return true if any new specializations get loaded. Return false otherwise.
160 virtual bool LoadExternalSpecializations(const Decl *D, bool OnlyPartial);
161
162 /// Load all the specializations for the Decl \param D with the same template
163 /// args specified by \param TemplateArgs.
164 ///
165 /// Return true if any new specializations get loaded. Return false otherwise.
166 virtual bool
168 ArrayRef<TemplateArgument> TemplateArgs);
169
170 /// Ensures that the table of all visible declarations inside this
171 /// context is up to date.
172 ///
173 /// The default implementation of this function is a no-op.
174 virtual void completeVisibleDeclsMap(const DeclContext *DC);
175
176 /// Retrieve the module that corresponds to the given module ID.
177 virtual Module *getModule(unsigned ID) { return nullptr; }
178
179 /// Return a descriptor for the corresponding module, if one exists.
180 virtual std::optional<ASTSourceDescriptor> getSourceDescriptor(unsigned ID);
181
183
184 virtual ExtKind hasExternalDefinitions(const Decl *D);
185
186 /// Finds all declarations lexically contained within the given
187 /// DeclContext, after applying an optional filter predicate.
188 ///
189 /// \param IsKindWeWant a predicate function that returns true if the passed
190 /// declaration kind is one we are looking for.
191 ///
192 /// The default implementation of this method is a no-op.
193 virtual void
195 llvm::function_ref<bool(Decl::Kind)> IsKindWeWant,
197
198 /// Finds all declarations lexically contained within the given
199 /// DeclContext.
202 FindExternalLexicalDecls(DC, [](Decl::Kind) { return true; }, Result);
203 }
204
205 /// Get the decls that are contained in a file in the Offset/Length
206 /// range. \p Length can be 0 to indicate a point at \p Offset instead of
207 /// a range.
208 virtual void FindFileRegionDecls(FileID File, unsigned Offset,
209 unsigned Length,
211
212 /// Gives the external AST source an opportunity to complete
213 /// the redeclaration chain for a declaration. Called each time we
214 /// need the most recent declaration of a declaration after the
215 /// generation count is incremented.
216 virtual void CompleteRedeclChain(const Decl *D);
217
218 /// Gives the external AST source an opportunity to complete
219 /// an incomplete type.
220 virtual void CompleteType(TagDecl *Tag);
221
222 /// Gives the external AST source an opportunity to complete an
223 /// incomplete Objective-C class.
224 ///
225 /// This routine will only be invoked if the "externally completed" bit is
226 /// set on the ObjCInterfaceDecl via the function
227 /// \c ObjCInterfaceDecl::setExternallyCompleted().
228 virtual void CompleteType(ObjCInterfaceDecl *Class);
229
230 /// Loads comment ranges.
231 virtual void ReadComments();
232
233 /// Notify ExternalASTSource that we started deserialization of
234 /// a decl or type so until FinishedDeserializing is called there may be
235 /// decls that are initializing. Must be paired with FinishedDeserializing.
236 ///
237 /// The default implementation of this method is a no-op.
238 virtual void StartedDeserializing();
239
240 /// Notify ExternalASTSource that we finished the deserialization of
241 /// a decl or type. Must be paired with StartedDeserializing.
242 ///
243 /// The default implementation of this method is a no-op.
244 virtual void FinishedDeserializing();
245
246 /// Function that will be invoked when we begin parsing a new
247 /// translation unit involving this external AST source.
248 ///
249 /// The default implementation of this method is a no-op.
250 virtual void StartTranslationUnit(ASTConsumer *Consumer);
251
252 /// Print any statistics that have been gathered regarding
253 /// the external AST source.
254 ///
255 /// The default implementation of this method is a no-op.
256 virtual void PrintStats();
257
258 /// Perform layout on the given record.
259 ///
260 /// This routine allows the external AST source to provide an specific
261 /// layout for a record, overriding the layout that would normally be
262 /// constructed. It is intended for clients who receive specific layout
263 /// details rather than source code (such as LLDB). The client is expected
264 /// to fill in the field offsets, base offsets, virtual base offsets, and
265 /// complete object size.
266 ///
267 /// \param Record The record whose layout is being requested.
268 ///
269 /// \param Size The final size of the record, in bits.
270 ///
271 /// \param Alignment The final alignment of the record, in bits.
272 ///
273 /// \param FieldOffsets The offset of each of the fields within the record,
274 /// expressed in bits. All of the fields must be provided with offsets.
275 ///
276 /// \param BaseOffsets The offset of each of the direct, non-virtual base
277 /// classes. If any bases are not given offsets, the bases will be laid
278 /// out according to the ABI.
279 ///
280 /// \param VirtualBaseOffsets The offset of each of the virtual base classes
281 /// (either direct or not). If any bases are not given offsets, the bases will be laid
282 /// out according to the ABI.
283 ///
284 /// \returns true if the record layout was provided, false otherwise.
285 virtual bool layoutRecordType(
286 const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
287 llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets,
288 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets,
289 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &VirtualBaseOffsets);
290
291 //===--------------------------------------------------------------------===//
292 // Queries for performance analysis.
293 //===--------------------------------------------------------------------===//
294
298
301 };
302
303 /// Return the amount of memory used by memory buffers, breaking down
304 /// by heap-backed versus mmap'ed memory.
306 MemoryBufferSizes sizes(0, 0);
308 return sizes;
309 }
310
311 virtual void getMemoryBufferSizes(MemoryBufferSizes &sizes) const;
312
313 /// LLVM-style RTTI.
314 /// \{
315 virtual bool isA(const void *ClassID) const { return ClassID == &ID; }
316 static bool classof(const ExternalASTSource *S) { return S->isA(&ID); }
317 /// \}
318
319protected:
322 DeclarationName Name,
324
327 DeclarationName Name);
328
329 /// Increment the current generation.
331};
332
333/// A lazy pointer to an AST node (of base type T) that resides
334/// within an external AST source.
335///
336/// The AST node is identified within the external AST source by a
337/// 63-bit offset, and can be retrieved via an operation on the
338/// external AST source itself.
339template<typename T, typename OffsT, T* (ExternalASTSource::*Get)(OffsT Offset)>
341 /// Either a pointer to an AST node or the offset within the
342 /// external AST source where the AST node can be found.
343 ///
344 /// If the low bit is clear, a pointer to the AST node. If the low
345 /// bit is set, the upper 63 bits are the offset.
346 static constexpr size_t DataSize = std::max(sizeof(uint64_t), sizeof(T *));
347 alignas(uint64_t) alignas(T *) mutable unsigned char Data[DataSize] = {};
348
349 unsigned char GetLSB() const {
350 return Data[llvm::sys::IsBigEndianHost ? DataSize - 1 : 0];
351 }
352
353 template <typename U> U &As(bool New) const {
354 unsigned char *Obj =
355 Data + (llvm::sys::IsBigEndianHost ? DataSize - sizeof(U) : 0);
356 if (New)
357 return *new (Obj) U;
358 return *std::launder(reinterpret_cast<U *>(Obj));
359 }
360
361 T *&GetPtr() const { return As<T *>(false); }
362 uint64_t &GetU64() const { return As<uint64_t>(false); }
363 void SetPtr(T *Ptr) const { As<T *>(true) = Ptr; }
364 void SetU64(uint64_t U64) const { As<uint64_t>(true) = U64; }
365
366public:
367 LazyOffsetPtr() = default;
368 explicit LazyOffsetPtr(T *Ptr) : Data() { SetPtr(Ptr); }
369
370 explicit LazyOffsetPtr(uint64_t Offset) : Data() {
371 assert((Offset << 1 >> 1) == Offset && "Offsets must require < 63 bits");
372 if (Offset == 0)
373 SetPtr(nullptr);
374 else
375 SetU64((Offset << 1) | 0x01);
376 }
377
379 SetPtr(Ptr);
380 return *this;
381 }
382
383 LazyOffsetPtr &operator=(uint64_t Offset) {
384 assert((Offset << 1 >> 1) == Offset && "Offsets must require < 63 bits");
385 if (Offset == 0)
386 SetPtr(nullptr);
387 else
388 SetU64((Offset << 1) | 0x01);
389
390 return *this;
391 }
392
393 /// Whether this pointer is non-NULL.
394 ///
395 /// This operation does not require the AST node to be deserialized.
396 explicit operator bool() const { return isOffset() || GetPtr() != nullptr; }
397
398 /// Whether this pointer is non-NULL.
399 ///
400 /// This operation does not require the AST node to be deserialized.
401 bool isValid() const { return isOffset() || GetPtr() != nullptr; }
402
403 /// Whether this pointer is currently stored as an offset.
404 bool isOffset() const { return GetLSB() & 0x01; }
405
406 /// Retrieve the pointer to the AST node that this lazy pointer points to.
407 ///
408 /// \param Source the external AST source.
409 ///
410 /// \returns a pointer to the AST node.
411 T *get(ExternalASTSource *Source) const {
412 if (isOffset()) {
413 assert(Source &&
414 "Cannot deserialize a lazy pointer without an AST source");
415 SetPtr((Source->*Get)(OffsT(GetU64() >> 1)));
416 }
417 return GetPtr();
418 }
419
420 /// Retrieve the address of the AST node pointer. Deserializes the pointee if
421 /// necessary.
423 // Ensure the integer is in pointer form.
424 (void)get(Source);
425 return &GetPtr();
426 }
427};
428
429/// A lazy value (of type T) that is within an AST node of type Owner,
430/// where the value might change in later generations of the external AST
431/// source.
432template<typename Owner, typename T, void (ExternalASTSource::*Update)(Owner)>
434 /// A cache of the value of this pointer, in the most recent generation in
435 /// which we queried it.
436 struct LazyData {
438 uint32_t LastGeneration = 0;
440
442 : ExternalSource(Source), LastValue(Value) {}
443 };
444
445 // Our value is represented as simply T if there is no external AST source.
446 using ValueType = llvm::PointerUnion<T, LazyData*>;
448
450
451 // Defined in ASTContext.h
452 static ValueType makeValue(const ASTContext &Ctx, T Value);
453
454public:
455 explicit LazyGenerationalUpdatePtr(const ASTContext &Ctx, T Value = T())
456 : Value(makeValue(Ctx, Value)) {}
457
458 /// Create a pointer that is not potentially updated by later generations of
459 /// the external AST source.
462 : Value(Value) {}
463
464 /// Forcibly set this pointer (which must be lazy) as needing updates.
465 void markIncomplete() { cast<LazyData *>(Value)->LastGeneration = 0; }
466
467 /// Set the value of this pointer, in the current generation.
468 void set(T NewValue) {
469 if (auto *LazyVal = Value.template dyn_cast<LazyData *>()) {
470 LazyVal->LastValue = NewValue;
471 return;
472 }
473 Value = NewValue;
474 }
475
476 /// Set the value of this pointer, for this and all future generations.
477 void setNotUpdated(T NewValue) { Value = NewValue; }
478
479 /// Get the value of this pointer, updating its owner if necessary.
480 T get(Owner O) {
481 if (auto *LazyVal = Value.template dyn_cast<LazyData *>()) {
482 if (LazyVal->LastGeneration != LazyVal->ExternalSource->getGeneration()) {
483 LazyVal->LastGeneration = LazyVal->ExternalSource->getGeneration();
484 (LazyVal->ExternalSource->*Update)(O);
485 }
486 return LazyVal->LastValue;
487 }
488 return cast<T>(Value);
489 }
490
491 /// Get the most recently computed value of this pointer without updating it.
492 T getNotUpdated() const {
493 if (auto *LazyVal = Value.template dyn_cast<LazyData *>())
494 return LazyVal->LastValue;
495 return cast<T>(Value);
496 }
497
498 void *getOpaqueValue() { return Value.getOpaqueValue(); }
500 return LazyGenerationalUpdatePtr(ValueType::getFromOpaqueValue(Ptr));
501 }
502};
503
504} // namespace clang
505
506namespace llvm {
507
508/// Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be
509/// placed into a PointerUnion.
510template<typename Owner, typename T,
511 void (clang::ExternalASTSource::*Update)(Owner)>
515
516 static void *getAsVoidPointer(Ptr P) { return P.getOpaqueValue(); }
517 static Ptr getFromVoidPointer(void *P) { return Ptr::getFromOpaqueValue(P); }
518
519 static constexpr int NumLowBitsAvailable =
521};
522
523} // namespace llvm
524
525namespace clang {
526
527/// Represents a lazily-loaded vector of data.
528///
529/// The lazily-loaded vector of data contains data that is partially loaded
530/// from an external source and partially added by local translation. The
531/// items loaded from the external source are loaded lazily, when needed for
532/// iteration over the complete vector.
533template<typename T, typename Source,
534 void (Source::*Loader)(SmallVectorImpl<T>&),
535 unsigned LoadedStorage = 2, unsigned LocalStorage = 4>
539
540public:
541 /// Iteration over the elements in the vector.
542 ///
543 /// In a complete iteration, the iterator walks the range [-M, N),
544 /// where negative values are used to indicate elements
545 /// loaded from the external source while non-negative values are used to
546 /// indicate elements added via \c push_back().
547 /// However, to provide iteration in source order (for, e.g., chained
548 /// precompiled headers), dereferencing the iterator flips the negative
549 /// values (corresponding to loaded entities), so that position -M
550 /// corresponds to element 0 in the loaded entities vector, position -M+1
551 /// corresponds to element 1 in the loaded entities vector, etc. This
552 /// gives us a reasonably efficient, source-order walk.
553 ///
554 /// We define this as a wrapping iterator around an int. The
555 /// iterator_adaptor_base class forwards the iterator methods to basic integer
556 /// arithmetic.
558 : public llvm::iterator_adaptor_base<
559 iterator, int, std::random_access_iterator_tag, T, int, T *, T &> {
560 friend class LazyVector;
561
562 LazyVector *Self;
563
564 iterator(LazyVector *Self, int Position)
565 : iterator::iterator_adaptor_base(Position), Self(Self) {}
566
567 bool isLoaded() const { return this->I < 0; }
568
569 public:
570 iterator() : iterator(nullptr, 0) {}
571
572 typename iterator::reference operator*() const {
573 if (isLoaded())
574 return Self->Loaded.end()[this->I];
575 return Self->Local.begin()[this->I];
576 }
577 };
578
579 iterator begin(Source *source, bool LocalOnly = false) {
580 if (LocalOnly)
581 return iterator(this, 0);
582
583 if (source)
584 (source->*Loader)(Loaded);
585 return iterator(this, -(int)Loaded.size());
586 }
587
589 return iterator(this, Local.size());
590 }
591
592 void push_back(const T& LocalValue) {
593 Local.push_back(LocalValue);
594 }
595
596 void erase(iterator From, iterator To) {
597 if (From.isLoaded() && To.isLoaded()) {
598 Loaded.erase(&*From, &*To);
599 return;
600 }
601
602 if (From.isLoaded()) {
603 Loaded.erase(&*From, Loaded.end());
604 From = begin(nullptr, true);
605 }
606
607 Local.erase(&*From, &*To);
608 }
609};
610
611/// A lazy pointer to a statement.
614
615/// A lazy pointer to a declaration.
618
619/// A lazy pointer to a set of CXXCtorInitializers.
622 &ExternalASTSource::GetExternalCXXCtorInitializers>;
623
624/// A lazy pointer to a set of CXXBaseSpecifiers.
627 &ExternalASTSource::GetExternalCXXBaseSpecifiers>;
628
629} // namespace clang
630
631#endif // LLVM_CLANG_AST_EXTERNALASTSOURCE_H
#define V(N, I)
Definition: ASTContext.h:3443
StringRef P
static char ID
Definition: Arena.cpp:183
const Decl * D
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
llvm::MachO::Record Record
Definition: MachO.h:31
__device__ int
#define bool
Definition: amdgpuintrin.h:20
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
The results of name lookup within a DeclContext.
Definition: DeclBase.h:1368
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.
RAII class for safely pairing a StartedDeserializing call with FinishedDeserializing.
Deserializing(ExternalASTSource *source)
Abstract interface for external sources of AST nodes.
static bool classof(const ExternalASTSource *S)
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.
static DeclContextLookupResult SetExternalVisibleDeclsForName(const DeclContext *DC, DeclarationName Name, ArrayRef< NamedDecl * > Decls)
Definition: DeclBase.cpp:1609
virtual bool isA(const void *ClassID) const
LLVM-style RTTI.
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.
static DeclContextLookupResult SetNoExternalVisibleDeclsForName(const DeclContext *DC, DeclarationName Name)
Definition: DeclBase.cpp:1594
virtual Module * getModule(unsigned ID)
Retrieve the module that corresponds to the given module ID.
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.
void FindExternalLexicalDecls(const DeclContext *DC, SmallVectorImpl< Decl * > &Result)
Finds all declarations lexically contained within the given DeclContext.
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 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.
uint32_t getGeneration() const
Get the current generation of this AST source.
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 updateOutOfDateIdentifier(const IdentifierInfo &II)
Update an out-of-date identifier.
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 abstract interface that should be implemented by external AST sources that also provide informatio...
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
One of these records is kept for each identifier that is lexed.
Iteration over the elements in the vector.
iterator::reference operator*() const
Represents a lazily-loaded vector of data.
void push_back(const T &LocalValue)
void erase(iterator From, iterator To)
iterator begin(Source *source, bool LocalOnly=false)
Describes a module or submodule.
Definition: Module.h:115
Represents an ObjC class declaration.
Definition: DeclObjC.h:1153
Represents a struct/union/class.
Definition: Decl.h:4148
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:3564
The JSON file list parser is used to communicate input to InstallAPI.
@ Result
The result type of a method or function.
const FunctionProtoType * T
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30
MemoryBufferSizes(size_t malloc_bytes, size_t mmap_bytes)
A cache of the value of this pointer, in the most recent generation in which we queried it.
LazyData(ExternalASTSource *Source, T Value)
A lazy value (of type T) that is within an AST node of type Owner, where the value might change in la...
static ValueType makeValue(const ASTContext &Ctx, T Value)
Create the representation of a LazyGenerationalUpdatePtr.
Definition: ASTContext.h:3692
T getNotUpdated() const
Get the most recently computed value of this pointer without updating it.
void set(T NewValue)
Set the value of this pointer, in the current generation.
LazyGenerationalUpdatePtr(const ASTContext &Ctx, T Value=T())
NotUpdatedTag
Create a pointer that is not potentially updated by later generations of the external AST source.
void setNotUpdated(T NewValue)
Set the value of this pointer, for this and all future generations.
T get(Owner O)
Get the value of this pointer, updating its owner if necessary.
void markIncomplete()
Forcibly set this pointer (which must be lazy) as needing updates.
static LazyGenerationalUpdatePtr getFromOpaqueValue(void *Ptr)
llvm::PointerUnion< T, LazyData * > ValueType
LazyGenerationalUpdatePtr(NotUpdatedTag, T Value=T())
A lazy pointer to an AST node (of base type T) that resides within an external AST source.
bool isValid() const
Whether this pointer is non-NULL.
LazyOffsetPtr(uint64_t Offset)
bool isOffset() const
Whether this pointer is currently stored as an offset.
LazyOffsetPtr & operator=(T *Ptr)
T ** getAddressOfPointer(ExternalASTSource *Source) const
Retrieve the address of the AST node pointer.
void SetU64(uint64_t U64) const
uint64_t & GetU64() const
LazyOffsetPtr & operator=(uint64_t Offset)
T * get(ExternalASTSource *Source) const
Retrieve the pointer to the AST node that this lazy pointer points to.
unsigned char Data[DataSize]
static constexpr size_t DataSize
Either a pointer to an AST node or the offset within the external AST source where the AST node can b...
void SetPtr(T *Ptr) const
unsigned char GetLSB() const
U & As(bool New) const