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