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