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