clang  3.8.0
ASTContext.h
Go to the documentation of this file.
1 //===--- ASTContext.h - Context to hold long-lived AST nodes ----*- 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 /// \file
11 /// \brief Defines the clang::ASTContext interface.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_AST_ASTCONTEXT_H
16 #define LLVM_CLANG_AST_ASTCONTEXT_H
17 
21 #include "clang/AST/Decl.h"
26 #include "clang/AST/TemplateName.h"
27 #include "clang/AST/Type.h"
31 #include "clang/Basic/Module.h"
36 #include "llvm/ADT/DenseMap.h"
37 #include "llvm/ADT/FoldingSet.h"
38 #include "llvm/ADT/IntrusiveRefCntPtr.h"
39 #include "llvm/ADT/SmallPtrSet.h"
40 #include "llvm/ADT/TinyPtrVector.h"
41 #include "llvm/Support/Allocator.h"
42 #include <memory>
43 #include <vector>
44 
45 namespace llvm {
46  struct fltSemantics;
47 }
48 
49 namespace clang {
50  class FileManager;
51  class AtomicExpr;
52  class ASTRecordLayout;
53  class BlockExpr;
54  class CharUnits;
55  class DiagnosticsEngine;
56  class Expr;
57  class ASTMutationListener;
58  class IdentifierTable;
59  class MaterializeTemporaryExpr;
60  class SelectorTable;
61  class TargetInfo;
62  class CXXABI;
63  class MangleNumberingContext;
64  // Decls
65  class MangleContext;
66  class ObjCIvarDecl;
67  class ObjCPropertyDecl;
68  class UnresolvedSetIterator;
69  class UsingDecl;
70  class UsingShadowDecl;
71  class VTableContextBase;
72 
73  namespace Builtin { class Context; }
74  enum BuiltinTemplateKind : int;
75 
76  namespace comments {
77  class FullComment;
78  }
79 
80  struct TypeInfo {
81  uint64_t Width;
82  unsigned Align;
83  bool AlignIsRequired : 1;
85  TypeInfo(uint64_t Width, unsigned Align, bool AlignIsRequired)
86  : Width(Width), Align(Align), AlignIsRequired(AlignIsRequired) {}
87  };
88 
89 /// \brief Holds long-lived AST nodes (such as types and decls) that can be
90 /// referred to throughout the semantic analysis of a file.
91 class ASTContext : public RefCountedBase<ASTContext> {
92  ASTContext &this_() { return *this; }
93 
94  mutable SmallVector<Type *, 0> Types;
95  mutable llvm::FoldingSet<ExtQuals> ExtQualNodes;
96  mutable llvm::FoldingSet<ComplexType> ComplexTypes;
97  mutable llvm::FoldingSet<PointerType> PointerTypes;
98  mutable llvm::FoldingSet<AdjustedType> AdjustedTypes;
99  mutable llvm::FoldingSet<BlockPointerType> BlockPointerTypes;
100  mutable llvm::FoldingSet<LValueReferenceType> LValueReferenceTypes;
101  mutable llvm::FoldingSet<RValueReferenceType> RValueReferenceTypes;
102  mutable llvm::FoldingSet<MemberPointerType> MemberPointerTypes;
103  mutable llvm::FoldingSet<ConstantArrayType> ConstantArrayTypes;
104  mutable llvm::FoldingSet<IncompleteArrayType> IncompleteArrayTypes;
105  mutable std::vector<VariableArrayType*> VariableArrayTypes;
106  mutable llvm::FoldingSet<DependentSizedArrayType> DependentSizedArrayTypes;
107  mutable llvm::FoldingSet<DependentSizedExtVectorType>
108  DependentSizedExtVectorTypes;
109  mutable llvm::FoldingSet<VectorType> VectorTypes;
110  mutable llvm::FoldingSet<FunctionNoProtoType> FunctionNoProtoTypes;
111  mutable llvm::ContextualFoldingSet<FunctionProtoType, ASTContext&>
112  FunctionProtoTypes;
113  mutable llvm::FoldingSet<DependentTypeOfExprType> DependentTypeOfExprTypes;
114  mutable llvm::FoldingSet<DependentDecltypeType> DependentDecltypeTypes;
115  mutable llvm::FoldingSet<TemplateTypeParmType> TemplateTypeParmTypes;
116  mutable llvm::FoldingSet<SubstTemplateTypeParmType>
117  SubstTemplateTypeParmTypes;
118  mutable llvm::FoldingSet<SubstTemplateTypeParmPackType>
119  SubstTemplateTypeParmPackTypes;
120  mutable llvm::ContextualFoldingSet<TemplateSpecializationType, ASTContext&>
121  TemplateSpecializationTypes;
122  mutable llvm::FoldingSet<ParenType> ParenTypes;
123  mutable llvm::FoldingSet<ElaboratedType> ElaboratedTypes;
124  mutable llvm::FoldingSet<DependentNameType> DependentNameTypes;
125  mutable llvm::ContextualFoldingSet<DependentTemplateSpecializationType,
126  ASTContext&>
127  DependentTemplateSpecializationTypes;
128  llvm::FoldingSet<PackExpansionType> PackExpansionTypes;
129  mutable llvm::FoldingSet<ObjCObjectTypeImpl> ObjCObjectTypes;
130  mutable llvm::FoldingSet<ObjCObjectPointerType> ObjCObjectPointerTypes;
131  mutable llvm::FoldingSet<AutoType> AutoTypes;
132  mutable llvm::FoldingSet<AtomicType> AtomicTypes;
133  llvm::FoldingSet<AttributedType> AttributedTypes;
134  mutable llvm::FoldingSet<PipeType> PipeTypes;
135 
136  mutable llvm::FoldingSet<QualifiedTemplateName> QualifiedTemplateNames;
137  mutable llvm::FoldingSet<DependentTemplateName> DependentTemplateNames;
138  mutable llvm::FoldingSet<SubstTemplateTemplateParmStorage>
139  SubstTemplateTemplateParms;
140  mutable llvm::ContextualFoldingSet<SubstTemplateTemplateParmPackStorage,
141  ASTContext&>
142  SubstTemplateTemplateParmPacks;
143 
144  /// \brief The set of nested name specifiers.
145  ///
146  /// This set is managed by the NestedNameSpecifier class.
147  mutable llvm::FoldingSet<NestedNameSpecifier> NestedNameSpecifiers;
148  mutable NestedNameSpecifier *GlobalNestedNameSpecifier;
149  friend class NestedNameSpecifier;
150 
151  /// \brief A cache mapping from RecordDecls to ASTRecordLayouts.
152  ///
153  /// This is lazily created. This is intentionally not serialized.
154  mutable llvm::DenseMap<const RecordDecl*, const ASTRecordLayout*>
155  ASTRecordLayouts;
156  mutable llvm::DenseMap<const ObjCContainerDecl*, const ASTRecordLayout*>
157  ObjCLayouts;
158 
159  /// \brief A cache from types to size and alignment information.
160  typedef llvm::DenseMap<const Type *, struct TypeInfo> TypeInfoMap;
161  mutable TypeInfoMap MemoizedTypeInfo;
162 
163  /// \brief A cache mapping from CXXRecordDecls to key functions.
164  llvm::DenseMap<const CXXRecordDecl*, LazyDeclPtr> KeyFunctions;
165 
166  /// \brief Mapping from ObjCContainers to their ObjCImplementations.
167  llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*> ObjCImpls;
168 
169  /// \brief Mapping from ObjCMethod to its duplicate declaration in the same
170  /// interface.
171  llvm::DenseMap<const ObjCMethodDecl*,const ObjCMethodDecl*> ObjCMethodRedecls;
172 
173  /// \brief Mapping from __block VarDecls to their copy initialization expr.
174  llvm::DenseMap<const VarDecl*, Expr*> BlockVarCopyInits;
175 
176  /// \brief Mapping from class scope functions specialization to their
177  /// template patterns.
178  llvm::DenseMap<const FunctionDecl*, FunctionDecl*>
179  ClassScopeSpecializationPattern;
180 
181  /// \brief Mapping from materialized temporaries with static storage duration
182  /// that appear in constant initializers to their evaluated values. These are
183  /// allocated in a std::map because their address must be stable.
184  llvm::DenseMap<const MaterializeTemporaryExpr *, APValue *>
185  MaterializedTemporaryValues;
186 
187  /// \brief Representation of a "canonical" template template parameter that
188  /// is used in canonical template names.
189  class CanonicalTemplateTemplateParm : public llvm::FoldingSetNode {
191 
192  public:
193  CanonicalTemplateTemplateParm(TemplateTemplateParmDecl *Parm)
194  : Parm(Parm) { }
195 
196  TemplateTemplateParmDecl *getParam() const { return Parm; }
197 
198  void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, Parm); }
199 
200  static void Profile(llvm::FoldingSetNodeID &ID,
201  TemplateTemplateParmDecl *Parm);
202  };
203  mutable llvm::FoldingSet<CanonicalTemplateTemplateParm>
204  CanonTemplateTemplateParms;
205 
206  TemplateTemplateParmDecl *
207  getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const;
208 
209  /// \brief The typedef for the __int128_t type.
210  mutable TypedefDecl *Int128Decl;
211 
212  /// \brief The typedef for the __uint128_t type.
213  mutable TypedefDecl *UInt128Decl;
214 
215  /// \brief The typedef for the __float128 stub type.
216  mutable TypeDecl *Float128StubDecl;
217 
218  /// \brief The typedef for the target specific predefined
219  /// __builtin_va_list type.
220  mutable TypedefDecl *BuiltinVaListDecl;
221 
222  /// The typedef for the predefined \c __builtin_ms_va_list type.
223  mutable TypedefDecl *BuiltinMSVaListDecl;
224 
225  /// \brief The typedef for the predefined \c id type.
226  mutable TypedefDecl *ObjCIdDecl;
227 
228  /// \brief The typedef for the predefined \c SEL type.
229  mutable TypedefDecl *ObjCSelDecl;
230 
231  /// \brief The typedef for the predefined \c Class type.
232  mutable TypedefDecl *ObjCClassDecl;
233 
234  /// \brief The typedef for the predefined \c Protocol class in Objective-C.
235  mutable ObjCInterfaceDecl *ObjCProtocolClassDecl;
236 
237  /// \brief The typedef for the predefined 'BOOL' type.
238  mutable TypedefDecl *BOOLDecl;
239 
240  // Typedefs which may be provided defining the structure of Objective-C
241  // pseudo-builtins
242  QualType ObjCIdRedefinitionType;
243  QualType ObjCClassRedefinitionType;
244  QualType ObjCSelRedefinitionType;
245 
246  /// The identifier 'NSObject'.
247  IdentifierInfo *NSObjectName = nullptr;
248 
249  /// The identifier 'NSCopying'.
250  IdentifierInfo *NSCopyingName = nullptr;
251 
252  /// The identifier '__make_integer_seq'.
253  mutable IdentifierInfo *MakeIntegerSeqName = nullptr;
254 
255  QualType ObjCConstantStringType;
256  mutable RecordDecl *CFConstantStringTypeDecl;
257 
258  mutable QualType ObjCSuperType;
259 
260  QualType ObjCNSStringType;
261 
262  /// \brief The typedef declaration for the Objective-C "instancetype" type.
263  TypedefDecl *ObjCInstanceTypeDecl;
264 
265  /// \brief The type for the C FILE type.
266  TypeDecl *FILEDecl;
267 
268  /// \brief The type for the C jmp_buf type.
269  TypeDecl *jmp_bufDecl;
270 
271  /// \brief The type for the C sigjmp_buf type.
272  TypeDecl *sigjmp_bufDecl;
273 
274  /// \brief The type for the C ucontext_t type.
275  TypeDecl *ucontext_tDecl;
276 
277  /// \brief Type for the Block descriptor for Blocks CodeGen.
278  ///
279  /// Since this is only used for generation of debug info, it is not
280  /// serialized.
281  mutable RecordDecl *BlockDescriptorType;
282 
283  /// \brief Type for the Block descriptor for Blocks CodeGen.
284  ///
285  /// Since this is only used for generation of debug info, it is not
286  /// serialized.
287  mutable RecordDecl *BlockDescriptorExtendedType;
288 
289  /// \brief Declaration for the CUDA cudaConfigureCall function.
290  FunctionDecl *cudaConfigureCallDecl;
291 
292  /// \brief Keeps track of all declaration attributes.
293  ///
294  /// Since so few decls have attrs, we keep them in a hash map instead of
295  /// wasting space in the Decl class.
296  llvm::DenseMap<const Decl*, AttrVec*> DeclAttrs;
297 
298  /// \brief A mapping from non-redeclarable declarations in modules that were
299  /// merged with other declarations to the canonical declaration that they were
300  /// merged into.
301  llvm::DenseMap<Decl*, Decl*> MergedDecls;
302 
303  /// \brief A mapping from a defining declaration to a list of modules (other
304  /// than the owning module of the declaration) that contain merged
305  /// definitions of that entity.
306  llvm::DenseMap<NamedDecl*, llvm::TinyPtrVector<Module*>> MergedDefModules;
307 
308 public:
309  /// \brief A type synonym for the TemplateOrInstantiation mapping.
310  typedef llvm::PointerUnion<VarTemplateDecl *, MemberSpecializationInfo *>
312 
313 private:
314 
315  /// \brief A mapping to contain the template or declaration that
316  /// a variable declaration describes or was instantiated from,
317  /// respectively.
318  ///
319  /// For non-templates, this value will be NULL. For variable
320  /// declarations that describe a variable template, this will be a
321  /// pointer to a VarTemplateDecl. For static data members
322  /// of class template specializations, this will be the
323  /// MemberSpecializationInfo referring to the member variable that was
324  /// instantiated or specialized. Thus, the mapping will keep track of
325  /// the static data member templates from which static data members of
326  /// class template specializations were instantiated.
327  ///
328  /// Given the following example:
329  ///
330  /// \code
331  /// template<typename T>
332  /// struct X {
333  /// static T value;
334  /// };
335  ///
336  /// template<typename T>
337  /// T X<T>::value = T(17);
338  ///
339  /// int *x = &X<int>::value;
340  /// \endcode
341  ///
342  /// This mapping will contain an entry that maps from the VarDecl for
343  /// X<int>::value to the corresponding VarDecl for X<T>::value (within the
344  /// class template X) and will be marked TSK_ImplicitInstantiation.
345  llvm::DenseMap<const VarDecl *, TemplateOrSpecializationInfo>
346  TemplateOrInstantiation;
347 
348  /// \brief Keeps track of the declaration from which a UsingDecl was
349  /// created during instantiation.
350  ///
351  /// The source declaration is always a UsingDecl, an UnresolvedUsingValueDecl,
352  /// or an UnresolvedUsingTypenameDecl.
353  ///
354  /// For example:
355  /// \code
356  /// template<typename T>
357  /// struct A {
358  /// void f();
359  /// };
360  ///
361  /// template<typename T>
362  /// struct B : A<T> {
363  /// using A<T>::f;
364  /// };
365  ///
366  /// template struct B<int>;
367  /// \endcode
368  ///
369  /// This mapping will contain an entry that maps from the UsingDecl in
370  /// B<int> to the UnresolvedUsingDecl in B<T>.
371  llvm::DenseMap<UsingDecl *, NamedDecl *> InstantiatedFromUsingDecl;
372 
373  llvm::DenseMap<UsingShadowDecl*, UsingShadowDecl*>
374  InstantiatedFromUsingShadowDecl;
375 
376  llvm::DenseMap<FieldDecl *, FieldDecl *> InstantiatedFromUnnamedFieldDecl;
377 
378  /// \brief Mapping that stores the methods overridden by a given C++
379  /// member function.
380  ///
381  /// Since most C++ member functions aren't virtual and therefore
382  /// don't override anything, we store the overridden functions in
383  /// this map on the side rather than within the CXXMethodDecl structure.
384  typedef llvm::TinyPtrVector<const CXXMethodDecl*> CXXMethodVector;
385  llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector> OverriddenMethods;
386 
387  /// \brief Mapping from each declaration context to its corresponding
388  /// mangling numbering context (used for constructs like lambdas which
389  /// need to be consistently numbered for the mangler).
390  llvm::DenseMap<const DeclContext *, MangleNumberingContext *>
391  MangleNumberingContexts;
392 
393  /// \brief Side-table of mangling numbers for declarations which rarely
394  /// need them (like static local vars).
395  llvm::DenseMap<const NamedDecl *, unsigned> MangleNumbers;
396  llvm::DenseMap<const VarDecl *, unsigned> StaticLocalNumbers;
397 
398  /// \brief Mapping that stores parameterIndex values for ParmVarDecls when
399  /// that value exceeds the bitfield size of ParmVarDeclBits.ParameterIndex.
400  typedef llvm::DenseMap<const VarDecl *, unsigned> ParameterIndexTable;
401  ParameterIndexTable ParamIndices;
402 
403  ImportDecl *FirstLocalImport;
404  ImportDecl *LastLocalImport;
405 
406  TranslationUnitDecl *TUDecl;
407  mutable ExternCContextDecl *ExternCContext;
408  mutable BuiltinTemplateDecl *MakeIntegerSeqDecl;
409 
410  /// \brief The associated SourceManager object.a
411  SourceManager &SourceMgr;
412 
413  /// \brief The language options used to create the AST associated with
414  /// this ASTContext object.
415  LangOptions &LangOpts;
416 
417  /// \brief Blacklist object that is used by sanitizers to decide which
418  /// entities should not be instrumented.
419  std::unique_ptr<SanitizerBlacklist> SanitizerBL;
420 
421  /// \brief The allocator used to create AST objects.
422  ///
423  /// AST objects are never destructed; rather, all memory associated with the
424  /// AST objects will be released when the ASTContext itself is destroyed.
425  mutable llvm::BumpPtrAllocator BumpAlloc;
426 
427  /// \brief Allocator for partial diagnostics.
429 
430  /// \brief The current C++ ABI.
431  std::unique_ptr<CXXABI> ABI;
432  CXXABI *createCXXABI(const TargetInfo &T);
433 
434  /// \brief The logical -> physical address space map.
435  const LangAS::Map *AddrSpaceMap;
436 
437  /// \brief Address space map mangling must be used with language specific
438  /// address spaces (e.g. OpenCL/CUDA)
439  bool AddrSpaceMapMangling;
440 
441  friend class ASTDeclReader;
442  friend class ASTReader;
443  friend class ASTWriter;
444  friend class CXXRecordDecl;
445 
446  const TargetInfo *Target;
447  const TargetInfo *AuxTarget;
449 
450 public:
457 
458  /// \brief Contains parents of a node.
460 
461  /// \brief Maps from a node to its parents. This is used for nodes that have
462  /// pointer identity only, which are more common and we can save space by
463  /// only storing a unique pointer to them.
464  typedef llvm::DenseMap<const void *,
465  llvm::PointerUnion4<const Decl *, const Stmt *,
468 
469  /// Parent map for nodes without pointer identity. We store a full
470  /// DynTypedNode for all keys.
471  typedef llvm::DenseMap<
473  llvm::PointerUnion4<const Decl *, const Stmt *,
476 
477  /// Container for either a single DynTypedNode or for an ArrayRef to
478  /// DynTypedNode. For use with ParentMap.
481  llvm::AlignedCharArrayUnion<ast_type_traits::DynTypedNode,
482  ArrayRef<DynTypedNode>> Storage;
483  bool IsSingleNode;
484 
485  public:
486  DynTypedNodeList(const DynTypedNode &N) : IsSingleNode(true) {
487  new (Storage.buffer) DynTypedNode(N);
488  }
490  new (Storage.buffer) ArrayRef<DynTypedNode>(A);
491  }
492 
494  if (!IsSingleNode)
495  return reinterpret_cast<const ArrayRef<DynTypedNode> *>(Storage.buffer)
496  ->begin();
497  return reinterpret_cast<const DynTypedNode *>(Storage.buffer);
498  }
499 
501  if (!IsSingleNode)
502  return reinterpret_cast<const ArrayRef<DynTypedNode> *>(Storage.buffer)
503  ->end();
504  return reinterpret_cast<const DynTypedNode *>(Storage.buffer) + 1;
505  }
506 
507  size_t size() const { return end() - begin(); }
508  bool empty() const { return begin() == end(); }
509  const DynTypedNode &operator[](size_t N) const {
510  assert(N < size() && "Out of bounds!");
511  return *(begin() + N);
512  }
513  };
514 
515  /// \brief Returns the parents of the given node.
516  ///
517  /// Note that this will lazily compute the parents of all nodes
518  /// and store them for later retrieval. Thus, the first call is O(n)
519  /// in the number of AST nodes.
520  ///
521  /// Caveats and FIXMEs:
522  /// Calculating the parent map over all AST nodes will need to load the
523  /// full AST. This can be undesirable in the case where the full AST is
524  /// expensive to create (for example, when using precompiled header
525  /// preambles). Thus, there are good opportunities for optimization here.
526  /// One idea is to walk the given node downwards, looking for references
527  /// to declaration contexts - once a declaration context is found, compute
528  /// the parent map for the declaration context; if that can satisfy the
529  /// request, loading the whole AST can be avoided. Note that this is made
530  /// more complex by statements in templates having multiple parents - those
531  /// problems can be solved by building closure over the templated parts of
532  /// the AST, which also avoids touching large parts of the AST.
533  /// Additionally, we will want to add an interface to already give a hint
534  /// where to search for the parents, for example when looking at a statement
535  /// inside a certain function.
536  ///
537  /// 'NodeT' can be one of Decl, Stmt, Type, TypeLoc,
538  /// NestedNameSpecifier or NestedNameSpecifierLoc.
539  template <typename NodeT> DynTypedNodeList getParents(const NodeT &Node) {
541  }
542 
543  DynTypedNodeList getParents(const ast_type_traits::DynTypedNode &Node);
544 
546  return PrintingPolicy;
547  }
548 
550  PrintingPolicy = Policy;
551  }
552 
553  SourceManager& getSourceManager() { return SourceMgr; }
554  const SourceManager& getSourceManager() const { return SourceMgr; }
555 
556  llvm::BumpPtrAllocator &getAllocator() const {
557  return BumpAlloc;
558  }
559 
560  void *Allocate(size_t Size, unsigned Align = 8) const {
561  return BumpAlloc.Allocate(Size, Align);
562  }
563  template <typename T> T *Allocate(size_t Num = 1) const {
564  return static_cast<T *>(Allocate(Num * sizeof(T), llvm::alignOf<T>()));
565  }
566  void Deallocate(void *Ptr) const { }
567 
568  /// Return the total amount of physical memory allocated for representing
569  /// AST nodes and type information.
570  size_t getASTAllocatedMemory() const {
571  return BumpAlloc.getTotalMemory();
572  }
573  /// Return the total memory used for various side tables.
574  size_t getSideTableAllocatedMemory() const;
575 
577  return DiagAllocator;
578  }
579 
580  const TargetInfo &getTargetInfo() const { return *Target; }
581  const TargetInfo *getAuxTargetInfo() const { return AuxTarget; }
582 
583  /// getIntTypeForBitwidth -
584  /// sets integer QualTy according to specified details:
585  /// bitwidth, signed/unsigned.
586  /// Returns empty type if there is no appropriate target types.
587  QualType getIntTypeForBitwidth(unsigned DestWidth,
588  unsigned Signed) const;
589  /// getRealTypeForBitwidth -
590  /// sets floating point QualTy according to specified bitwidth.
591  /// Returns empty type if there is no appropriate target types.
592  QualType getRealTypeForBitwidth(unsigned DestWidth) const;
593 
594  bool AtomicUsesUnsupportedLibcall(const AtomicExpr *E) const;
595 
596  const LangOptions& getLangOpts() const { return LangOpts; }
597 
599  return *SanitizerBL;
600  }
601 
603 
605  return FullSourceLoc(Loc,SourceMgr);
606  }
607 
608  /// \brief All comments in this translation unit.
610 
611  /// \brief True if comments are already loaded from ExternalASTSource.
612  mutable bool CommentsLoaded;
613 
615  public:
616  enum Kind {
617  /// We searched for a comment attached to the particular declaration, but
618  /// didn't find any.
619  ///
620  /// getRaw() == 0.
622 
623  /// We have found a comment attached to this particular declaration.
624  ///
625  /// getRaw() != 0.
627 
628  /// This declaration does not have an attached comment, and we have
629  /// searched the redeclaration chain.
630  ///
631  /// If getRaw() == 0, the whole redeclaration chain does not have any
632  /// comments.
633  ///
634  /// If getRaw() != 0, it is a comment propagated from other
635  /// redeclaration.
637  };
638 
639  Kind getKind() const LLVM_READONLY {
640  return Data.getInt();
641  }
642 
643  void setKind(Kind K) {
644  Data.setInt(K);
645  }
646 
647  const RawComment *getRaw() const LLVM_READONLY {
648  return Data.getPointer();
649  }
650 
651  void setRaw(const RawComment *RC) {
652  Data.setPointer(RC);
653  }
654 
655  const Decl *getOriginalDecl() const LLVM_READONLY {
656  return OriginalDecl;
657  }
658 
659  void setOriginalDecl(const Decl *Orig) {
660  OriginalDecl = Orig;
661  }
662 
663  private:
664  llvm::PointerIntPair<const RawComment *, 2, Kind> Data;
665  const Decl *OriginalDecl;
666  };
667 
668  /// \brief Mapping from declarations to comments attached to any
669  /// redeclaration.
670  ///
671  /// Raw comments are owned by Comments list. This mapping is populated
672  /// lazily.
673  mutable llvm::DenseMap<const Decl *, RawCommentAndCacheFlags> RedeclComments;
674 
675  /// \brief Mapping from declarations to parsed comments attached to any
676  /// redeclaration.
677  mutable llvm::DenseMap<const Decl *, comments::FullComment *> ParsedComments;
678 
679  /// \brief Return the documentation comment attached to a given declaration,
680  /// without looking into cache.
682 
683 public:
685  return Comments;
686  }
687 
688  void addComment(const RawComment &RC) {
689  assert(LangOpts.RetainCommentsFromSystemHeaders ||
690  !SourceMgr.isInSystemHeader(RC.getSourceRange().getBegin()));
691  Comments.addComment(RC, BumpAlloc);
692  }
693 
694  /// \brief Return the documentation comment attached to a given declaration.
695  /// Returns NULL if no comment is attached.
696  ///
697  /// \param OriginalDecl if not NULL, is set to declaration AST node that had
698  /// the comment, if the comment we found comes from a redeclaration.
699  const RawComment *
701  const Decl **OriginalDecl = nullptr) const;
702 
703  /// Return parsed documentation comment attached to a given declaration.
704  /// Returns NULL if no comment is attached.
705  ///
706  /// \param PP the Preprocessor used with this TU. Could be NULL if
707  /// preprocessor is not available.
709  const Preprocessor *PP) const;
710 
711  /// Return parsed documentation comment attached to a given declaration.
712  /// Returns NULL if no comment is attached. Does not look at any
713  /// redeclarations of the declaration.
715 
717  const Decl *D) const;
718 
719 private:
720  mutable comments::CommandTraits CommentCommandTraits;
721 
722  /// \brief Iterator that visits import declarations.
723  class import_iterator {
724  ImportDecl *Import;
725 
726  public:
727  typedef ImportDecl *value_type;
728  typedef ImportDecl *reference;
729  typedef ImportDecl *pointer;
730  typedef int difference_type;
731  typedef std::forward_iterator_tag iterator_category;
732 
733  import_iterator() : Import() {}
734  explicit import_iterator(ImportDecl *Import) : Import(Import) {}
735 
736  reference operator*() const { return Import; }
737  pointer operator->() const { return Import; }
738 
739  import_iterator &operator++() {
740  Import = ASTContext::getNextLocalImport(Import);
741  return *this;
742  }
743 
744  import_iterator operator++(int) {
745  import_iterator Other(*this);
746  ++(*this);
747  return Other;
748  }
749 
750  friend bool operator==(import_iterator X, import_iterator Y) {
751  return X.Import == Y.Import;
752  }
753 
754  friend bool operator!=(import_iterator X, import_iterator Y) {
755  return X.Import != Y.Import;
756  }
757  };
758 
759 public:
761  return CommentCommandTraits;
762  }
763 
764  /// \brief Retrieve the attributes for the given declaration.
765  AttrVec& getDeclAttrs(const Decl *D);
766 
767  /// \brief Erase the attributes corresponding to the given declaration.
768  void eraseDeclAttrs(const Decl *D);
769 
770  /// \brief If this variable is an instantiated static data member of a
771  /// class template specialization, returns the templated static data member
772  /// from which it was instantiated.
773  // FIXME: Remove ?
775  const VarDecl *Var);
776 
779 
781 
783  FunctionDecl *Pattern);
784 
785  /// \brief Note that the static data member \p Inst is an instantiation of
786  /// the static data member template \p Tmpl of a class template.
789  SourceLocation PointOfInstantiation = SourceLocation());
790 
793 
794  /// \brief If the given using decl \p Inst is an instantiation of a
795  /// (possibly unresolved) using decl from a template instantiation,
796  /// return it.
798 
799  /// \brief Remember that the using decl \p Inst is an instantiation
800  /// of the using decl \p Pattern of a class template.
801  void setInstantiatedFromUsingDecl(UsingDecl *Inst, NamedDecl *Pattern);
802 
804  UsingShadowDecl *Pattern);
806 
808 
810 
811  // Access to the set of methods overridden by the given C++ method.
812  typedef CXXMethodVector::const_iterator overridden_cxx_method_iterator;
814  overridden_methods_begin(const CXXMethodDecl *Method) const;
815 
817  overridden_methods_end(const CXXMethodDecl *Method) const;
818 
819  unsigned overridden_methods_size(const CXXMethodDecl *Method) const;
820 
821  /// \brief Note that the given C++ \p Method overrides the given \p
822  /// Overridden method.
823  void addOverriddenMethod(const CXXMethodDecl *Method,
824  const CXXMethodDecl *Overridden);
825 
826  /// \brief Return C++ or ObjC overridden methods for the given \p Method.
827  ///
828  /// An ObjC method is considered to override any method in the class's
829  /// base classes, its protocols, or its categories' protocols, that has
830  /// the same selector and is of the same kind (class or instance).
831  /// A method in an implementation is not considered as overriding the same
832  /// method in the interface or its categories.
834  const NamedDecl *Method,
835  SmallVectorImpl<const NamedDecl *> &Overridden) const;
836 
837  /// \brief Notify the AST context that a new import declaration has been
838  /// parsed or implicitly created within this translation unit.
839  void addedLocalImportDecl(ImportDecl *Import);
840 
842  return Import->NextLocalImport;
843  }
844 
845  typedef llvm::iterator_range<import_iterator> import_range;
847  return import_range(import_iterator(FirstLocalImport), import_iterator());
848  }
849 
851  Decl *Result = MergedDecls.lookup(D);
852  return Result ? Result : D;
853  }
854  void setPrimaryMergedDecl(Decl *D, Decl *Primary) {
855  MergedDecls[D] = Primary;
856  }
857 
858  /// \brief Note that the definition \p ND has been merged into module \p M,
859  /// and should be visible whenever \p M is visible.
861  bool NotifyListeners = true);
862  /// \brief Clean up the merged definition list. Call this if you might have
863  /// added duplicates into the list.
865 
866  /// \brief Get the additional modules in which the definition \p Def has
867  /// been merged.
869  auto MergedIt = MergedDefModules.find(Def);
870  if (MergedIt == MergedDefModules.end())
871  return None;
872  return MergedIt->second;
873  }
874 
875  TranslationUnitDecl *getTranslationUnitDecl() const { return TUDecl; }
876 
879 
880  // Builtin Types.
884  CanQualType WCharTy; // [C++ 3.9.1p5].
885  CanQualType WideCharTy; // Same as WCharTy in C++, integer type in C99.
886  CanQualType WIntTy; // [C99 7.24.1], integer type unchanged by default promotions.
887  CanQualType Char16Ty; // [C++0x 3.9.1p5], integer type in C99.
888  CanQualType Char32Ty; // [C++0x 3.9.1p5], integer type in C99.
893  CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
909 
910  // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand.
911  mutable QualType AutoDeductTy; // Deduction against 'auto'.
912  mutable QualType AutoRRefDeductTy; // Deduction against 'auto &&'.
913 
914  // Decl used to help define __builtin_va_list for some targets.
915  // The decl is built when constructing 'BuiltinVaListDecl'.
916  mutable Decl *VaListTagDecl;
917 
919  SelectorTable &sels, Builtin::Context &builtins);
920 
921  ~ASTContext();
922 
923  /// \brief Attach an external AST source to the AST context.
924  ///
925  /// The external AST source provides the ability to load parts of
926  /// the abstract syntax tree as needed from some external storage,
927  /// e.g., a precompiled header.
929 
930  /// \brief Retrieve a pointer to the external AST source associated
931  /// with this AST context, if any.
933  return ExternalSource.get();
934  }
935 
936  /// \brief Attach an AST mutation listener to the AST context.
937  ///
938  /// The AST mutation listener provides the ability to track modifications to
939  /// the abstract syntax tree entities committed after they were initially
940  /// created.
942  this->Listener = Listener;
943  }
944 
945  /// \brief Retrieve a pointer to the AST mutation listener associated
946  /// with this AST context, if any.
948 
949  void PrintStats() const;
950  const SmallVectorImpl<Type *>& getTypes() const { return Types; }
951 
953  const IdentifierInfo *II) const;
954 
955  /// \brief Create a new implicit TU-level CXXRecordDecl or RecordDecl
956  /// declaration.
958  RecordDecl::TagKind TK = TTK_Struct) const;
959 
960  /// \brief Create a new implicit TU-level typedef declaration.
961  TypedefDecl *buildImplicitTypedef(QualType T, StringRef Name) const;
962 
963  /// \brief Retrieve the declaration for the 128-bit signed integer type.
964  TypedefDecl *getInt128Decl() const;
965 
966  /// \brief Retrieve the declaration for the 128-bit unsigned integer type.
967  TypedefDecl *getUInt128Decl() const;
968 
969  /// \brief Retrieve the declaration for a 128-bit float stub type.
970  TypeDecl *getFloat128StubType() const;
971 
972  //===--------------------------------------------------------------------===//
973  // Type Constructors
974  //===--------------------------------------------------------------------===//
975 
976 private:
977  /// \brief Return a type with extended qualifiers.
978  QualType getExtQualType(const Type *Base, Qualifiers Quals) const;
979 
980  QualType getTypeDeclTypeSlow(const TypeDecl *Decl) const;
981 
982 public:
983  /// \brief Return the uniqued reference to the type for an address space
984  /// qualified type with the specified type and address space.
985  ///
986  /// The resulting type has a union of the qualifiers from T and the address
987  /// space. If T already has an address space specifier, it is silently
988  /// replaced.
989  QualType getAddrSpaceQualType(QualType T, unsigned AddressSpace) const;
990 
991  /// \brief Return the uniqued reference to the type for an Objective-C
992  /// gc-qualified type.
993  ///
994  /// The retulting type has a union of the qualifiers from T and the gc
995  /// attribute.
997 
998  /// \brief Return the uniqued reference to the type for a \c restrict
999  /// qualified type.
1000  ///
1001  /// The resulting type has a union of the qualifiers from \p T and
1002  /// \c restrict.
1005  }
1006 
1007  /// \brief Return the uniqued reference to the type for a \c volatile
1008  /// qualified type.
1009  ///
1010  /// The resulting type has a union of the qualifiers from \p T and
1011  /// \c volatile.
1014  }
1015 
1016  /// \brief Return the uniqued reference to the type for a \c const
1017  /// qualified type.
1018  ///
1019  /// The resulting type has a union of the qualifiers from \p T and \c const.
1020  ///
1021  /// It can be reasonably expected that this will always be equivalent to
1022  /// calling T.withConst().
1023  QualType getConstType(QualType T) const { return T.withConst(); }
1024 
1025  /// \brief Change the ExtInfo on a function type.
1026  const FunctionType *adjustFunctionType(const FunctionType *Fn,
1027  FunctionType::ExtInfo EInfo);
1028 
1029  /// Adjust the given function result type.
1031 
1032  /// \brief Change the result type of a function type once it is deduced.
1034 
1035  /// \brief Change the exception specification on a function once it is
1036  /// delay-parsed, instantiated, or computed.
1039  bool AsWritten = false);
1040 
1041  /// \brief Return the uniqued reference to the type for a complex
1042  /// number with the specified element type.
1043  QualType getComplexType(QualType T) const;
1046  }
1047 
1048  /// \brief Return the uniqued reference to the type for a pointer to
1049  /// the specified type.
1050  QualType getPointerType(QualType T) const;
1053  }
1054 
1055  /// \brief Return the uniqued reference to a type adjusted from the original
1056  /// type to a new type.
1057  QualType getAdjustedType(QualType Orig, QualType New) const;
1060  getAdjustedType((QualType)Orig, (QualType)New));
1061  }
1062 
1063  /// \brief Return the uniqued reference to the decayed version of the given
1064  /// type. Can only be called on array and function types which decay to
1065  /// pointer types.
1066  QualType getDecayedType(QualType T) const;
1069  }
1070 
1071  /// \brief Return the uniqued reference to the atomic type for the specified
1072  /// type.
1073  QualType getAtomicType(QualType T) const;
1074 
1075  /// \brief Return the uniqued reference to the type for a block of the
1076  /// specified type.
1078 
1079  /// Gets the struct used to keep track of the descriptor for pointer to
1080  /// blocks.
1082 
1083  /// \brief Return pipe type for the specified type.
1084  QualType getPipeType(QualType T) const;
1085 
1086  /// Gets the struct used to keep track of the extended descriptor for
1087  /// pointer to blocks.
1089 
1091  cudaConfigureCallDecl = FD;
1092  }
1094  return cudaConfigureCallDecl;
1095  }
1096 
1097  /// Returns true iff we need copy/dispose helpers for the given type.
1098  bool BlockRequiresCopying(QualType Ty, const VarDecl *D);
1099 
1100 
1101  /// Returns true, if given type has a known lifetime. HasByrefExtendedLayout is set
1102  /// to false in this case. If HasByrefExtendedLayout returns true, byref variable
1103  /// has extended lifetime.
1104  bool getByrefLifetime(QualType Ty,
1105  Qualifiers::ObjCLifetime &Lifetime,
1106  bool &HasByrefExtendedLayout) const;
1107 
1108  /// \brief Return the uniqued reference to the type for an lvalue reference
1109  /// to the specified type.
1110  QualType getLValueReferenceType(QualType T, bool SpelledAsLValue = true)
1111  const;
1112 
1113  /// \brief Return the uniqued reference to the type for an rvalue reference
1114  /// to the specified type.
1116 
1117  /// \brief Return the uniqued reference to the type for a member pointer to
1118  /// the specified type in the specified class.
1119  ///
1120  /// The class \p Cls is a \c Type because it could be a dependent name.
1121  QualType getMemberPointerType(QualType T, const Type *Cls) const;
1122 
1123  /// \brief Return a non-unique reference to the type for a variable array of
1124  /// the specified element type.
1125  QualType getVariableArrayType(QualType EltTy, Expr *NumElts,
1127  unsigned IndexTypeQuals,
1128  SourceRange Brackets) const;
1129 
1130  /// \brief Return a non-unique reference to the type for a dependently-sized
1131  /// array of the specified element type.
1132  ///
1133  /// FIXME: We will need these to be uniqued, or at least comparable, at some
1134  /// point.
1137  unsigned IndexTypeQuals,
1138  SourceRange Brackets) const;
1139 
1140  /// \brief Return a unique reference to the type for an incomplete array of
1141  /// the specified element type.
1144  unsigned IndexTypeQuals) const;
1145 
1146  /// \brief Return the unique reference to the type for a constant array of
1147  /// the specified element type.
1148  QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize,
1150  unsigned IndexTypeQuals) const;
1151 
1152  /// \brief Returns a vla type where known sizes are replaced with [*].
1154 
1155  /// \brief Return the unique reference to a vector type of the specified
1156  /// element type and size.
1157  ///
1158  /// \pre \p VectorType must be a built-in type.
1159  QualType getVectorType(QualType VectorType, unsigned NumElts,
1160  VectorType::VectorKind VecKind) const;
1161 
1162  /// \brief Return the unique reference to an extended vector type
1163  /// of the specified element type and size.
1164  ///
1165  /// \pre \p VectorType must be a built-in type.
1166  QualType getExtVectorType(QualType VectorType, unsigned NumElts) const;
1167 
1168  /// \pre Return a non-unique reference to the type for a dependently-sized
1169  /// vector of the specified element type.
1170  ///
1171  /// FIXME: We will need these to be uniqued, or at least comparable, at some
1172  /// point.
1174  Expr *SizeExpr,
1175  SourceLocation AttrLoc) const;
1176 
1177  /// \brief Return a K&R style C function type like 'int()'.
1179  const FunctionType::ExtInfo &Info) const;
1180 
1182  return getFunctionNoProtoType(ResultTy, FunctionType::ExtInfo());
1183  }
1184 
1185  /// \brief Return a normal function type with a typed argument list.
1187  const FunctionProtoType::ExtProtoInfo &EPI) const;
1188 
1189  /// \brief Return the unique reference to the type for the specified type
1190  /// declaration.
1192  const TypeDecl *PrevDecl = nullptr) const {
1193  assert(Decl && "Passed null for Decl param");
1194  if (Decl->TypeForDecl) return QualType(Decl->TypeForDecl, 0);
1195 
1196  if (PrevDecl) {
1197  assert(PrevDecl->TypeForDecl && "previous decl has no TypeForDecl");
1198  Decl->TypeForDecl = PrevDecl->TypeForDecl;
1199  return QualType(PrevDecl->TypeForDecl, 0);
1200  }
1201 
1202  return getTypeDeclTypeSlow(Decl);
1203  }
1204 
1205  /// \brief Return the unique reference to the type for the specified
1206  /// typedef-name decl.
1208  QualType Canon = QualType()) const;
1209 
1210  QualType getRecordType(const RecordDecl *Decl) const;
1211 
1212  QualType getEnumType(const EnumDecl *Decl) const;
1213 
1215 
1217  QualType modifiedType,
1218  QualType equivalentType);
1219 
1221  QualType Replacement) const;
1223  const TemplateTypeParmType *Replaced,
1224  const TemplateArgument &ArgPack);
1225 
1226  QualType
1227  getTemplateTypeParmType(unsigned Depth, unsigned Index,
1228  bool ParameterPack,
1229  TemplateTypeParmDecl *ParmDecl = nullptr) const;
1230 
1232  const TemplateArgument *Args,
1233  unsigned NumArgs,
1234  QualType Canon = QualType()) const;
1235 
1237  const TemplateArgument *Args,
1238  unsigned NumArgs) const;
1239 
1241  const TemplateArgumentListInfo &Args,
1242  QualType Canon = QualType()) const;
1243 
1244  TypeSourceInfo *
1246  const TemplateArgumentListInfo &Args,
1247  QualType Canon = QualType()) const;
1248 
1249  QualType getParenType(QualType NamedType) const;
1250 
1252  NestedNameSpecifier *NNS,
1253  QualType NamedType) const;
1255  NestedNameSpecifier *NNS,
1256  const IdentifierInfo *Name,
1257  QualType Canon = QualType()) const;
1258 
1260  NestedNameSpecifier *NNS,
1261  const IdentifierInfo *Name,
1262  const TemplateArgumentListInfo &Args) const;
1264  NestedNameSpecifier *NNS,
1265  const IdentifierInfo *Name,
1266  unsigned NumArgs,
1267  const TemplateArgument *Args) const;
1268 
1270  Optional<unsigned> NumExpansions);
1271 
1273  ObjCInterfaceDecl *PrevDecl = nullptr) const;
1274 
1275  /// Legacy interface: cannot provide type arguments or __kindof.
1277  ObjCProtocolDecl * const *Protocols,
1278  unsigned NumProtocols) const;
1279 
1281  ArrayRef<QualType> typeArgs,
1282  ArrayRef<ObjCProtocolDecl *> protocols,
1283  bool isKindOf) const;
1284 
1286  /// QIdProtocolsAdoptObjCObjectProtocols - Checks that protocols in
1287  /// QT's qualified-id protocol list adopt all protocols in IDecl's list
1288  /// of protocols.
1290  ObjCInterfaceDecl *IDecl);
1291 
1292  /// \brief Return a ObjCObjectPointerType type for the given ObjCObjectType.
1294 
1295  /// \brief GCC extension.
1296  QualType getTypeOfExprType(Expr *e) const;
1297  QualType getTypeOfType(QualType t) const;
1298 
1299  /// \brief C++11 decltype.
1300  QualType getDecltypeType(Expr *e, QualType UnderlyingType) const;
1301 
1302  /// \brief Unary type transforms
1303  QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType,
1304  UnaryTransformType::UTTKind UKind) const;
1305 
1306  /// \brief C++11 deduced auto type.
1307  QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword,
1308  bool IsDependent) const;
1309 
1310  /// \brief C++11 deduction pattern for 'auto' type.
1311  QualType getAutoDeductType() const;
1312 
1313  /// \brief C++11 deduction pattern for 'auto &&' type.
1315 
1316  /// \brief Return the unique reference to the type for the specified TagDecl
1317  /// (struct/union/class/enum) decl.
1318  QualType getTagDeclType(const TagDecl *Decl) const;
1319 
1320  /// \brief Return the unique type for "size_t" (C99 7.17), defined in
1321  /// <stddef.h>.
1322  ///
1323  /// The sizeof operator requires this (C99 6.5.3.4p4).
1324  CanQualType getSizeType() const;
1325 
1326  /// \brief Return the unique type for "intmax_t" (C99 7.18.1.5), defined in
1327  /// <stdint.h>.
1328  CanQualType getIntMaxType() const;
1329 
1330  /// \brief Return the unique type for "uintmax_t" (C99 7.18.1.5), defined in
1331  /// <stdint.h>.
1332  CanQualType getUIntMaxType() const;
1333 
1334  /// \brief Return the unique wchar_t type available in C++ (and available as
1335  /// __wchar_t as a Microsoft extension).
1336  QualType getWCharType() const { return WCharTy; }
1337 
1338  /// \brief Return the type of wide characters. In C++, this returns the
1339  /// unique wchar_t type. In C99, this returns a type compatible with the type
1340  /// defined in <stddef.h> as defined by the target.
1342 
1343  /// \brief Return the type of "signed wchar_t".
1344  ///
1345  /// Used when in C++, as a GCC extension.
1346  QualType getSignedWCharType() const;
1347 
1348  /// \brief Return the type of "unsigned wchar_t".
1349  ///
1350  /// Used when in C++, as a GCC extension.
1352 
1353  /// \brief In C99, this returns a type compatible with the type
1354  /// defined in <stddef.h> as defined by the target.
1355  QualType getWIntType() const { return WIntTy; }
1356 
1357  /// \brief Return a type compatible with "intptr_t" (C99 7.18.1.4),
1358  /// as defined by the target.
1359  QualType getIntPtrType() const;
1360 
1361  /// \brief Return a type compatible with "uintptr_t" (C99 7.18.1.4),
1362  /// as defined by the target.
1363  QualType getUIntPtrType() const;
1364 
1365  /// \brief Return the unique type for "ptrdiff_t" (C99 7.17) defined in
1366  /// <stddef.h>. Pointer - pointer requires this (C99 6.5.6p9).
1367  QualType getPointerDiffType() const;
1368 
1369  /// \brief Return the unique type for "pid_t" defined in
1370  /// <sys/types.h>. We need this to compute the correct type for vfork().
1371  QualType getProcessIDType() const;
1372 
1373  /// \brief Return the C structure type used to represent constant CFStrings.
1375 
1376  /// \brief Returns the C struct type for objc_super
1377  QualType getObjCSuperType() const;
1378  void setObjCSuperType(QualType ST) { ObjCSuperType = ST; }
1379 
1380  /// Get the structure type used to representation CFStrings, or NULL
1381  /// if it hasn't yet been built.
1383  if (CFConstantStringTypeDecl)
1384  return getTagDeclType(CFConstantStringTypeDecl);
1385  return QualType();
1386  }
1388 
1389  // This setter/getter represents the ObjC type for an NSConstantString.
1392  return ObjCConstantStringType;
1393  }
1394 
1396  return ObjCNSStringType;
1397  }
1398 
1400  ObjCNSStringType = T;
1401  }
1402 
1403  /// \brief Retrieve the type that \c id has been defined to, which may be
1404  /// different from the built-in \c id if \c id has been typedef'd.
1406  if (ObjCIdRedefinitionType.isNull())
1407  return getObjCIdType();
1408  return ObjCIdRedefinitionType;
1409  }
1410 
1411  /// \brief Set the user-written type that redefines \c id.
1413  ObjCIdRedefinitionType = RedefType;
1414  }
1415 
1416  /// \brief Retrieve the type that \c Class has been defined to, which may be
1417  /// different from the built-in \c Class if \c Class has been typedef'd.
1419  if (ObjCClassRedefinitionType.isNull())
1420  return getObjCClassType();
1421  return ObjCClassRedefinitionType;
1422  }
1423 
1424  /// \brief Set the user-written type that redefines 'SEL'.
1426  ObjCClassRedefinitionType = RedefType;
1427  }
1428 
1429  /// \brief Retrieve the type that 'SEL' has been defined to, which may be
1430  /// different from the built-in 'SEL' if 'SEL' has been typedef'd.
1432  if (ObjCSelRedefinitionType.isNull())
1433  return getObjCSelType();
1434  return ObjCSelRedefinitionType;
1435  }
1436 
1437 
1438  /// \brief Set the user-written type that redefines 'SEL'.
1440  ObjCSelRedefinitionType = RedefType;
1441  }
1442 
1443  /// Retrieve the identifier 'NSObject'.
1445  if (!NSObjectName) {
1446  NSObjectName = &Idents.get("NSObject");
1447  }
1448 
1449  return NSObjectName;
1450  }
1451 
1452  /// Retrieve the identifier 'NSCopying'.
1454  if (!NSCopyingName) {
1455  NSCopyingName = &Idents.get("NSCopying");
1456  }
1457 
1458  return NSCopyingName;
1459  }
1460 
1462  if (!MakeIntegerSeqName)
1463  MakeIntegerSeqName = &Idents.get("__make_integer_seq");
1464  return MakeIntegerSeqName;
1465  }
1466 
1467  /// \brief Retrieve the Objective-C "instancetype" type, if already known;
1468  /// otherwise, returns a NULL type;
1471  }
1472 
1473  /// \brief Retrieve the typedef declaration corresponding to the Objective-C
1474  /// "instancetype" type.
1476 
1477  /// \brief Set the type for the C FILE type.
1478  void setFILEDecl(TypeDecl *FILEDecl) { this->FILEDecl = FILEDecl; }
1479 
1480  /// \brief Retrieve the C FILE type.
1482  if (FILEDecl)
1483  return getTypeDeclType(FILEDecl);
1484  return QualType();
1485  }
1486 
1487  /// \brief Set the type for the C jmp_buf type.
1488  void setjmp_bufDecl(TypeDecl *jmp_bufDecl) {
1489  this->jmp_bufDecl = jmp_bufDecl;
1490  }
1491 
1492  /// \brief Retrieve the C jmp_buf type.
1494  if (jmp_bufDecl)
1495  return getTypeDeclType(jmp_bufDecl);
1496  return QualType();
1497  }
1498 
1499  /// \brief Set the type for the C sigjmp_buf type.
1500  void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl) {
1501  this->sigjmp_bufDecl = sigjmp_bufDecl;
1502  }
1503 
1504  /// \brief Retrieve the C sigjmp_buf type.
1506  if (sigjmp_bufDecl)
1507  return getTypeDeclType(sigjmp_bufDecl);
1508  return QualType();
1509  }
1510 
1511  /// \brief Set the type for the C ucontext_t type.
1512  void setucontext_tDecl(TypeDecl *ucontext_tDecl) {
1513  this->ucontext_tDecl = ucontext_tDecl;
1514  }
1515 
1516  /// \brief Retrieve the C ucontext_t type.
1518  if (ucontext_tDecl)
1519  return getTypeDeclType(ucontext_tDecl);
1520  return QualType();
1521  }
1522 
1523  /// \brief The result type of logical operations, '<', '>', '!=', etc.
1525  return getLangOpts().CPlusPlus ? BoolTy : IntTy;
1526  }
1527 
1528  /// \brief Emit the Objective-CC type encoding for the given type \p T into
1529  /// \p S.
1530  ///
1531  /// If \p Field is specified then record field names are also encoded.
1532  void getObjCEncodingForType(QualType T, std::string &S,
1533  const FieldDecl *Field=nullptr,
1534  QualType *NotEncodedT=nullptr) const;
1535 
1536  /// \brief Emit the Objective-C property type encoding for the given
1537  /// type \p T into \p S.
1538  void getObjCEncodingForPropertyType(QualType T, std::string &S) const;
1539 
1540  void getLegacyIntegralTypeEncoding(QualType &t) const;
1541 
1542  /// \brief Put the string version of the type qualifiers \p QT into \p S.
1544  std::string &S) const;
1545 
1546  /// \brief Emit the encoded type for the function \p Decl into \p S.
1547  ///
1548  /// This is in the same format as Objective-C method encodings.
1549  ///
1550  /// \returns true if an error occurred (e.g., because one of the parameter
1551  /// types is incomplete), false otherwise.
1552  bool getObjCEncodingForFunctionDecl(const FunctionDecl *Decl, std::string& S);
1553 
1554  /// \brief Emit the encoded type for the method declaration \p Decl into
1555  /// \p S.
1556  ///
1557  /// \returns true if an error occurred (e.g., because one of the parameter
1558  /// types is incomplete), false otherwise.
1559  bool getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl, std::string &S,
1560  bool Extended = false)
1561  const;
1562 
1563  /// \brief Return the encoded type for this block declaration.
1564  std::string getObjCEncodingForBlock(const BlockExpr *blockExpr) const;
1565 
1566  /// getObjCEncodingForPropertyDecl - Return the encoded type for
1567  /// this method declaration. If non-NULL, Container must be either
1568  /// an ObjCCategoryImplDecl or ObjCImplementationDecl; it should
1569  /// only be NULL when getting encodings for protocol properties.
1571  const Decl *Container,
1572  std::string &S) const;
1573 
1575  ObjCProtocolDecl *rProto) const;
1576 
1578  const ObjCPropertyDecl *PD,
1579  const Decl *Container) const;
1580 
1581  /// \brief Return the size of type \p T for Objective-C encoding purpose,
1582  /// in characters.
1584 
1585  /// \brief Retrieve the typedef corresponding to the predefined \c id type
1586  /// in Objective-C.
1587  TypedefDecl *getObjCIdDecl() const;
1588 
1589  /// \brief Represents the Objective-CC \c id type.
1590  ///
1591  /// This is set up lazily, by Sema. \c id is always a (typedef for a)
1592  /// pointer type, a pointer to a struct.
1594  return getTypeDeclType(getObjCIdDecl());
1595  }
1596 
1597  /// \brief Retrieve the typedef corresponding to the predefined 'SEL' type
1598  /// in Objective-C.
1599  TypedefDecl *getObjCSelDecl() const;
1600 
1601  /// \brief Retrieve the type that corresponds to the predefined Objective-C
1602  /// 'SEL' type.
1604  return getTypeDeclType(getObjCSelDecl());
1605  }
1606 
1607  /// \brief Retrieve the typedef declaration corresponding to the predefined
1608  /// Objective-C 'Class' type.
1609  TypedefDecl *getObjCClassDecl() const;
1610 
1611  /// \brief Represents the Objective-C \c Class type.
1612  ///
1613  /// This is set up lazily, by Sema. \c Class is always a (typedef for a)
1614  /// pointer type, a pointer to a struct.
1617  }
1618 
1619  /// \brief Retrieve the Objective-C class declaration corresponding to
1620  /// the predefined \c Protocol class.
1622 
1623  /// \brief Retrieve declaration of 'BOOL' typedef
1625  return BOOLDecl;
1626  }
1627 
1628  /// \brief Save declaration of 'BOOL' typedef
1630  BOOLDecl = TD;
1631  }
1632 
1633  /// \brief type of 'BOOL' type.
1635  return getTypeDeclType(getBOOLDecl());
1636  }
1637 
1638  /// \brief Retrieve the type of the Objective-C \c Protocol class.
1641  }
1642 
1643  /// \brief Retrieve the C type declaration corresponding to the predefined
1644  /// \c __builtin_va_list type.
1646 
1647  /// \brief Retrieve the type of the \c __builtin_va_list type.
1650  }
1651 
1652  /// \brief Retrieve the C type declaration corresponding to the predefined
1653  /// \c __va_list_tag type used to help define the \c __builtin_va_list type
1654  /// for some targets.
1655  Decl *getVaListTagDecl() const;
1656 
1657  /// Retrieve the C type declaration corresponding to the predefined
1658  /// \c __builtin_ms_va_list type.
1660 
1661  /// Retrieve the type of the \c __builtin_ms_va_list type.
1664  }
1665 
1666  /// \brief Return a type with additional \c const, \c volatile, or
1667  /// \c restrict qualifiers.
1668  QualType getCVRQualifiedType(QualType T, unsigned CVR) const {
1669  return getQualifiedType(T, Qualifiers::fromCVRMask(CVR));
1670  }
1671 
1672  /// \brief Un-split a SplitQualType.
1674  return getQualifiedType(split.Ty, split.Quals);
1675  }
1676 
1677  /// \brief Return a type with additional qualifiers.
1679  if (!Qs.hasNonFastQualifiers())
1680  return T.withFastQualifiers(Qs.getFastQualifiers());
1681  QualifierCollector Qc(Qs);
1682  const Type *Ptr = Qc.strip(T);
1683  return getExtQualType(Ptr, Qc);
1684  }
1685 
1686  /// \brief Return a type with additional qualifiers.
1688  if (!Qs.hasNonFastQualifiers())
1689  return QualType(T, Qs.getFastQualifiers());
1690  return getExtQualType(T, Qs);
1691  }
1692 
1693  /// \brief Return a type with the given lifetime qualifier.
1694  ///
1695  /// \pre Neither type.ObjCLifetime() nor \p lifetime may be \c OCL_None.
1697  Qualifiers::ObjCLifetime lifetime) {
1698  assert(type.getObjCLifetime() == Qualifiers::OCL_None);
1699  assert(lifetime != Qualifiers::OCL_None);
1700 
1701  Qualifiers qs;
1702  qs.addObjCLifetime(lifetime);
1703  return getQualifiedType(type, qs);
1704  }
1705 
1706  /// getUnqualifiedObjCPointerType - Returns version of
1707  /// Objective-C pointer type with lifetime qualifier removed.
1709  if (!type.getTypePtr()->isObjCObjectPointerType() ||
1710  !type.getQualifiers().hasObjCLifetime())
1711  return type;
1712  Qualifiers Qs = type.getQualifiers();
1713  Qs.removeObjCLifetime();
1714  return getQualifiedType(type.getUnqualifiedType(), Qs);
1715  }
1716 
1718  SourceLocation NameLoc) const;
1719 
1721  UnresolvedSetIterator End) const;
1722 
1724  bool TemplateKeyword,
1725  TemplateDecl *Template) const;
1726 
1728  const IdentifierInfo *Name) const;
1730  OverloadedOperatorKind Operator) const;
1732  TemplateName replacement) const;
1734  const TemplateArgument &ArgPack) const;
1735 
1737  GE_None, ///< No error
1738  GE_Missing_stdio, ///< Missing a type from <stdio.h>
1739  GE_Missing_setjmp, ///< Missing a type from <setjmp.h>
1740  GE_Missing_ucontext ///< Missing a type from <ucontext.h>
1741  };
1742 
1743  /// \brief Return the type for the specified builtin.
1744  ///
1745  /// If \p IntegerConstantArgs is non-null, it is filled in with a bitmask of
1746  /// arguments to the builtin that are required to be integer constant
1747  /// expressions.
1749  unsigned *IntegerConstantArgs = nullptr) const;
1750 
1751 private:
1752  CanQualType getFromTargetType(unsigned Type) const;
1753  TypeInfo getTypeInfoImpl(const Type *T) const;
1754 
1755  //===--------------------------------------------------------------------===//
1756  // Type Predicates.
1757  //===--------------------------------------------------------------------===//
1758 
1759 public:
1760  /// \brief Return one of the GCNone, Weak or Strong Objective-C garbage
1761  /// collection attributes.
1763 
1764  /// \brief Return true if the given vector types are of the same unqualified
1765  /// type or if they are equivalent to the same GCC vector type.
1766  ///
1767  /// \note This ignores whether they are target-specific (AltiVec or Neon)
1768  /// types.
1769  bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec);
1770 
1771  /// \brief Return true if this is an \c NSObject object with its \c NSObject
1772  /// attribute set.
1773  static bool isObjCNSObjectType(QualType Ty) {
1774  return Ty->isObjCNSObjectType();
1775  }
1776 
1777  //===--------------------------------------------------------------------===//
1778  // Type Sizing and Analysis
1779  //===--------------------------------------------------------------------===//
1780 
1781  /// \brief Return the APFloat 'semantics' for the specified scalar floating
1782  /// point type.
1783  const llvm::fltSemantics &getFloatTypeSemantics(QualType T) const;
1784 
1785  /// \brief Get the size and alignment of the specified complete type in bits.
1786  TypeInfo getTypeInfo(const Type *T) const;
1788 
1789  /// \brief Get default simd alignment of the specified complete type in bits.
1790  unsigned getOpenMPDefaultSimdAlign(QualType T) const;
1791 
1792  /// \brief Return the size of the specified (complete) type \p T, in bits.
1793  uint64_t getTypeSize(QualType T) const { return getTypeInfo(T).Width; }
1794  uint64_t getTypeSize(const Type *T) const { return getTypeInfo(T).Width; }
1795 
1796  /// \brief Return the size of the character type, in bits.
1797  uint64_t getCharWidth() const {
1798  return getTypeSize(CharTy);
1799  }
1800 
1801  /// \brief Convert a size in bits to a size in characters.
1802  CharUnits toCharUnitsFromBits(int64_t BitSize) const;
1803 
1804  /// \brief Convert a size in characters to a size in bits.
1805  int64_t toBits(CharUnits CharSize) const;
1806 
1807  /// \brief Return the size of the specified (complete) type \p T, in
1808  /// characters.
1810  CharUnits getTypeSizeInChars(const Type *T) const;
1811 
1812  /// \brief Return the ABI-specified alignment of a (complete) type \p T, in
1813  /// bits.
1814  unsigned getTypeAlign(QualType T) const { return getTypeInfo(T).Align; }
1815  unsigned getTypeAlign(const Type *T) const { return getTypeInfo(T).Align; }
1816 
1817  /// \brief Return the ABI-specified alignment of a (complete) type \p T, in
1818  /// characters.
1820  CharUnits getTypeAlignInChars(const Type *T) const;
1821 
1822  // getTypeInfoDataSizeInChars - Return the size of a type, in chars. If the
1823  // type is a record, its data size is returned.
1824  std::pair<CharUnits, CharUnits> getTypeInfoDataSizeInChars(QualType T) const;
1825 
1826  std::pair<CharUnits, CharUnits> getTypeInfoInChars(const Type *T) const;
1827  std::pair<CharUnits, CharUnits> getTypeInfoInChars(QualType T) const;
1828 
1829  /// \brief Determine if the alignment the type has was required using an
1830  /// alignment attribute.
1831  bool isAlignmentRequired(const Type *T) const;
1832  bool isAlignmentRequired(QualType T) const;
1833 
1834  /// \brief Return the "preferred" alignment of the specified type \p T for
1835  /// the current target, in bits.
1836  ///
1837  /// This can be different than the ABI alignment in cases where it is
1838  /// beneficial for performance to overalign a data type.
1839  unsigned getPreferredTypeAlign(const Type *T) const;
1840 
1841  /// \brief Return the default alignment for __attribute__((aligned)) on
1842  /// this target, to be used if no alignment value is specified.
1843  unsigned getTargetDefaultAlignForAttributeAligned(void) const;
1844 
1845  /// \brief Return the alignment in bits that should be given to a
1846  /// global variable with type \p T.
1847  unsigned getAlignOfGlobalVar(QualType T) const;
1848 
1849  /// \brief Return the alignment in characters that should be given to a
1850  /// global variable with type \p T.
1852 
1853  /// \brief Return a conservative estimate of the alignment of the specified
1854  /// decl \p D.
1855  ///
1856  /// \pre \p D must not be a bitfield type, as bitfields do not have a valid
1857  /// alignment.
1858  ///
1859  /// If \p ForAlignof, references are treated like their underlying type
1860  /// and large arrays don't get any special treatment. If not \p ForAlignof
1861  /// it computes the value expected by CodeGen: references are treated like
1862  /// pointers and large arrays get extra alignment.
1863  CharUnits getDeclAlign(const Decl *D, bool ForAlignof = false) const;
1864 
1865  /// \brief Get or compute information about the layout of the specified
1866  /// record (struct/union/class) \p D, which indicates its size and field
1867  /// position information.
1868  const ASTRecordLayout &getASTRecordLayout(const RecordDecl *D) const;
1869 
1870  /// \brief Get or compute information about the layout of the specified
1871  /// Objective-C interface.
1873  const;
1874 
1875  void DumpRecordLayout(const RecordDecl *RD, raw_ostream &OS,
1876  bool Simple = false) const;
1877 
1878  /// \brief Get or compute information about the layout of the specified
1879  /// Objective-C implementation.
1880  ///
1881  /// This may differ from the interface if synthesized ivars are present.
1882  const ASTRecordLayout &
1884 
1885  /// \brief Get our current best idea for the key function of the
1886  /// given record decl, or NULL if there isn't one.
1887  ///
1888  /// The key function is, according to the Itanium C++ ABI section 5.2.3:
1889  /// ...the first non-pure virtual function that is not inline at the
1890  /// point of class definition.
1891  ///
1892  /// Other ABIs use the same idea. However, the ARM C++ ABI ignores
1893  /// virtual functions that are defined 'inline', which means that
1894  /// the result of this computation can change.
1896 
1897  /// \brief Observe that the given method cannot be a key function.
1898  /// Checks the key-function cache for the method's class and clears it
1899  /// if matches the given declaration.
1900  ///
1901  /// This is used in ABIs where out-of-line definitions marked
1902  /// inline are not considered to be key functions.
1903  ///
1904  /// \param method should be the declaration from the class definition
1905  void setNonKeyFunction(const CXXMethodDecl *method);
1906 
1907  /// Loading virtual member pointers using the virtual inheritance model
1908  /// always results in an adjustment using the vbtable even if the index is
1909  /// zero.
1910  ///
1911  /// This is usually OK because the first slot in the vbtable points
1912  /// backwards to the top of the MDC. However, the MDC might be reusing a
1913  /// vbptr from an nv-base. In this case, the first slot in the vbtable
1914  /// points to the start of the nv-base which introduced the vbptr and *not*
1915  /// the MDC. Modify the NonVirtualBaseAdjustment to account for this.
1917 
1918  /// Get the offset of a FieldDecl or IndirectFieldDecl, in bits.
1919  uint64_t getFieldOffset(const ValueDecl *FD) const;
1920 
1921  bool isNearlyEmpty(const CXXRecordDecl *RD) const;
1922 
1924 
1926 
1927  void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass,
1929 
1930  unsigned CountNonClassIvars(const ObjCInterfaceDecl *OI) const;
1931  void CollectInheritedProtocols(const Decl *CDecl,
1932  llvm::SmallPtrSet<ObjCProtocolDecl*, 8> &Protocols);
1933 
1934  //===--------------------------------------------------------------------===//
1935  // Type Operators
1936  //===--------------------------------------------------------------------===//
1937 
1938  /// \brief Return the canonical (structural) type corresponding to the
1939  /// specified potentially non-canonical type \p T.
1940  ///
1941  /// The non-canonical version of a type may have many "decorated" versions of
1942  /// types. Decorators can include typedefs, 'typeof' operators, etc. The
1943  /// returned type is guaranteed to be free of any of these, allowing two
1944  /// canonical types to be compared for exact equality with a simple pointer
1945  /// comparison.
1948  }
1949 
1950  const Type *getCanonicalType(const Type *T) const {
1951  return T->getCanonicalTypeInternal().getTypePtr();
1952  }
1953 
1954  /// \brief Return the canonical parameter type corresponding to the specific
1955  /// potentially non-canonical one.
1956  ///
1957  /// Qualifiers are stripped off, functions are turned into function
1958  /// pointers, and arrays decay one level into pointers.
1960 
1961  /// \brief Determine whether the given types \p T1 and \p T2 are equivalent.
1962  bool hasSameType(QualType T1, QualType T2) const {
1963  return getCanonicalType(T1) == getCanonicalType(T2);
1964  }
1965 
1966  bool hasSameType(const Type *T1, const Type *T2) const {
1967  return getCanonicalType(T1) == getCanonicalType(T2);
1968  }
1969 
1970  /// \brief Return this type as a completely-unqualified array type,
1971  /// capturing the qualifiers in \p Quals.
1972  ///
1973  /// This will remove the minimal amount of sugaring from the types, similar
1974  /// to the behavior of QualType::getUnqualifiedType().
1975  ///
1976  /// \param T is the qualified type, which may be an ArrayType
1977  ///
1978  /// \param Quals will receive the full set of qualifiers that were
1979  /// applied to the array.
1980  ///
1981  /// \returns if this is an array type, the completely unqualified array type
1982  /// that corresponds to it. Otherwise, returns T.getUnqualifiedType().
1984 
1985  /// \brief Determine whether the given types are equivalent after
1986  /// cvr-qualifiers have been removed.
1988  return getCanonicalType(T1).getTypePtr() ==
1990  }
1991 
1993  bool IsParam) const {
1994  auto SubTnullability = SubT->getNullability(*this);
1995  auto SuperTnullability = SuperT->getNullability(*this);
1996  if (SubTnullability.hasValue() == SuperTnullability.hasValue()) {
1997  // Neither has nullability; return true
1998  if (!SubTnullability)
1999  return true;
2000  // Both have nullability qualifier.
2001  if (*SubTnullability == *SuperTnullability ||
2002  *SubTnullability == NullabilityKind::Unspecified ||
2003  *SuperTnullability == NullabilityKind::Unspecified)
2004  return true;
2005 
2006  if (IsParam) {
2007  // Ok for the superclass method parameter to be "nonnull" and the subclass
2008  // method parameter to be "nullable"
2009  return (*SuperTnullability == NullabilityKind::NonNull &&
2010  *SubTnullability == NullabilityKind::Nullable);
2011  }
2012  else {
2013  // For the return type, it's okay for the superclass method to specify
2014  // "nullable" and the subclass method specify "nonnull"
2015  return (*SuperTnullability == NullabilityKind::Nullable &&
2016  *SubTnullability == NullabilityKind::NonNull);
2017  }
2018  }
2019  return true;
2020  }
2021 
2022  bool ObjCMethodsAreEqual(const ObjCMethodDecl *MethodDecl,
2023  const ObjCMethodDecl *MethodImp);
2024 
2026 
2027  /// \brief Retrieves the "canonical" nested name specifier for a
2028  /// given nested name specifier.
2029  ///
2030  /// The canonical nested name specifier is a nested name specifier
2031  /// that uniquely identifies a type or namespace within the type
2032  /// system. For example, given:
2033  ///
2034  /// \code
2035  /// namespace N {
2036  /// struct S {
2037  /// template<typename T> struct X { typename T* type; };
2038  /// };
2039  /// }
2040  ///
2041  /// template<typename T> struct Y {
2042  /// typename N::S::X<T>::type member;
2043  /// };
2044  /// \endcode
2045  ///
2046  /// Here, the nested-name-specifier for N::S::X<T>:: will be
2047  /// S::X<template-param-0-0>, since 'S' and 'X' are uniquely defined
2048  /// by declarations in the type system and the canonical type for
2049  /// the template type parameter 'T' is template-param-0-0.
2052 
2053  /// \brief Retrieves the default calling convention for the current target.
2054  CallingConv getDefaultCallingConvention(bool isVariadic,
2055  bool IsCXXMethod) const;
2056 
2057  /// \brief Retrieves the "canonical" template name that refers to a
2058  /// given template.
2059  ///
2060  /// The canonical template name is the simplest expression that can
2061  /// be used to refer to a given template. For most templates, this
2062  /// expression is just the template declaration itself. For example,
2063  /// the template std::vector can be referred to via a variety of
2064  /// names---std::vector, \::std::vector, vector (if vector is in
2065  /// scope), etc.---but all of these names map down to the same
2066  /// TemplateDecl, which is used to form the canonical template name.
2067  ///
2068  /// Dependent template names are more interesting. Here, the
2069  /// template name could be something like T::template apply or
2070  /// std::allocator<T>::template rebind, where the nested name
2071  /// specifier itself is dependent. In this case, the canonical
2072  /// template name uses the shortest form of the dependent
2073  /// nested-name-specifier, which itself contains all canonical
2074  /// types, values, and templates.
2076 
2077  /// \brief Determine whether the given template names refer to the same
2078  /// template.
2080 
2081  /// \brief Retrieve the "canonical" template argument.
2082  ///
2083  /// The canonical template argument is the simplest template argument
2084  /// (which may be a type, value, expression, or declaration) that
2085  /// expresses the value of the argument.
2087  const;
2088 
2089  /// Type Query functions. If the type is an instance of the specified class,
2090  /// return the Type pointer for the underlying maximally pretty type. This
2091  /// is a member of ASTContext because this may need to do some amount of
2092  /// canonicalization, e.g. to move type qualifiers into the element type.
2093  const ArrayType *getAsArrayType(QualType T) const;
2095  return dyn_cast_or_null<ConstantArrayType>(getAsArrayType(T));
2096  }
2098  return dyn_cast_or_null<VariableArrayType>(getAsArrayType(T));
2099  }
2101  return dyn_cast_or_null<IncompleteArrayType>(getAsArrayType(T));
2102  }
2104  const {
2105  return dyn_cast_or_null<DependentSizedArrayType>(getAsArrayType(T));
2106  }
2107 
2108  /// \brief Return the innermost element type of an array type.
2109  ///
2110  /// For example, will return "int" for int[m][n]
2111  QualType getBaseElementType(const ArrayType *VAT) const;
2112 
2113  /// \brief Return the innermost element type of a type (which needn't
2114  /// actually be an array type).
2116 
2117  /// \brief Return number of constant array elements.
2118  uint64_t getConstantArrayElementCount(const ConstantArrayType *CA) const;
2119 
2120  /// \brief Perform adjustment on the parameter type of a function.
2121  ///
2122  /// This routine adjusts the given parameter type @p T to the actual
2123  /// parameter type used by semantic analysis (C99 6.7.5.3p[7,8],
2124  /// C++ [dcl.fct]p3). The adjusted parameter type is returned.
2126 
2127  /// \brief Retrieve the parameter type as adjusted for use in the signature
2128  /// of a function, decaying array and function types and removing top-level
2129  /// cv-qualifiers.
2131 
2133 
2134  /// \brief Return the properly qualified result of decaying the specified
2135  /// array type to a pointer.
2136  ///
2137  /// This operation is non-trivial when handling typedefs etc. The canonical
2138  /// type of \p T must be an array type, this returns a pointer to a properly
2139  /// qualified element of the array.
2140  ///
2141  /// See C99 6.7.5.3p7 and C99 6.3.2.1p3.
2143 
2144  /// \brief Return the type that \p PromotableType will promote to: C99
2145  /// 6.3.1.1p2, assuming that \p PromotableType is a promotable integer type.
2146  QualType getPromotedIntegerType(QualType PromotableType) const;
2147 
2148  /// \brief Recurses in pointer/array types until it finds an Objective-C
2149  /// retainable type and returns its ownership.
2151 
2152  /// \brief Whether this is a promotable bitfield reference according
2153  /// to C99 6.3.1.1p2, bullet 2 (and GCC extensions).
2154  ///
2155  /// \returns the type this bit-field will promote to, or NULL if no
2156  /// promotion occurs.
2158 
2159  /// \brief Return the highest ranked integer type, see C99 6.3.1.8p1.
2160  ///
2161  /// If \p LHS > \p RHS, returns 1. If \p LHS == \p RHS, returns 0. If
2162  /// \p LHS < \p RHS, return -1.
2163  int getIntegerTypeOrder(QualType LHS, QualType RHS) const;
2164 
2165  /// \brief Compare the rank of the two specified floating point types,
2166  /// ignoring the domain of the type (i.e. 'double' == '_Complex double').
2167  ///
2168  /// If \p LHS > \p RHS, returns 1. If \p LHS == \p RHS, returns 0. If
2169  /// \p LHS < \p RHS, return -1.
2170  int getFloatingTypeOrder(QualType LHS, QualType RHS) const;
2171 
2172  /// \brief Return a real floating point or a complex type (based on
2173  /// \p typeDomain/\p typeSize).
2174  ///
2175  /// \param typeDomain a real floating point or complex type.
2176  /// \param typeSize a real floating point or complex type.
2178  QualType typeDomain) const;
2179 
2180  unsigned getTargetAddressSpace(QualType T) const {
2182  }
2183 
2184  unsigned getTargetAddressSpace(Qualifiers Q) const {
2186  }
2187 
2188  unsigned getTargetAddressSpace(unsigned AS) const {
2189  if (AS < LangAS::Offset || AS >= LangAS::Offset + LangAS::Count)
2190  return AS;
2191  else
2192  return (*AddrSpaceMap)[AS - LangAS::Offset];
2193  }
2194 
2195  bool addressSpaceMapManglingFor(unsigned AS) const {
2196  return AddrSpaceMapMangling ||
2197  AS < LangAS::Offset ||
2198  AS >= LangAS::Offset + LangAS::Count;
2199  }
2200 
2201 private:
2202  // Helper for integer ordering
2203  unsigned getIntegerRank(const Type *T) const;
2204 
2205 public:
2206 
2207  //===--------------------------------------------------------------------===//
2208  // Type Compatibility Predicates
2209  //===--------------------------------------------------------------------===//
2210 
2211  /// Compatibility predicates used to check assignment expressions.
2212  bool typesAreCompatible(QualType T1, QualType T2,
2213  bool CompareUnqualified = false); // C99 6.2.7p1
2214 
2217 
2218  bool isObjCIdType(QualType T) const {
2219  return T == getObjCIdType();
2220  }
2221  bool isObjCClassType(QualType T) const {
2222  return T == getObjCClassType();
2223  }
2224  bool isObjCSelType(QualType T) const {
2225  return T == getObjCSelType();
2226  }
2228  bool ForCompare);
2229 
2231 
2232  // Check the safety of assignment from LHS to RHS
2234  const ObjCObjectPointerType *RHSOPT);
2235  bool canAssignObjCInterfaces(const ObjCObjectType *LHS,
2236  const ObjCObjectType *RHS);
2238  const ObjCObjectPointerType *LHSOPT,
2239  const ObjCObjectPointerType *RHSOPT,
2240  bool BlockReturnType);
2243  const ObjCObjectPointerType *RHSOPT);
2244  bool canBindObjCObjectType(QualType To, QualType From);
2245 
2246  // Functions for calculating composite types
2247  QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false,
2248  bool Unqualified = false, bool BlockReturnType = false);
2249  QualType mergeFunctionTypes(QualType, QualType, bool OfBlockPointer=false,
2250  bool Unqualified = false);
2252  bool OfBlockPointer = false,
2253  bool Unqualified = false);
2255  bool OfBlockPointer=false,
2256  bool Unqualified = false);
2257 
2259 
2261  const FunctionProtoType *FromFunctionType,
2262  const FunctionProtoType *ToFunctionType);
2263 
2264  void ResetObjCLayout(const ObjCContainerDecl *CD);
2265 
2266  //===--------------------------------------------------------------------===//
2267  // Integer Predicates
2268  //===--------------------------------------------------------------------===//
2269 
2270  // The width of an integer, as defined in C99 6.2.6.2. This is the number
2271  // of bits in an integer type excluding any padding bits.
2272  unsigned getIntWidth(QualType T) const;
2273 
2274  // Per C99 6.2.5p6, for every signed integer type, there is a corresponding
2275  // unsigned integer type. This method takes a signed type, and returns the
2276  // corresponding unsigned integer type.
2278 
2279  //===--------------------------------------------------------------------===//
2280  // Integer Values
2281  //===--------------------------------------------------------------------===//
2282 
2283  /// \brief Make an APSInt of the appropriate width and signedness for the
2284  /// given \p Value and integer \p Type.
2285  llvm::APSInt MakeIntValue(uint64_t Value, QualType Type) const {
2286  // If Type is a signed integer type larger than 64 bits, we need to be sure
2287  // to sign extend Res appropriately.
2288  llvm::APSInt Res(64, !Type->isSignedIntegerOrEnumerationType());
2289  Res = Value;
2290  unsigned Width = getIntWidth(Type);
2291  if (Width != Res.getBitWidth())
2292  return Res.extOrTrunc(Width);
2293  return Res;
2294  }
2295 
2296  bool isSentinelNullExpr(const Expr *E);
2297 
2298  /// \brief Get the implementation of the ObjCInterfaceDecl \p D, or NULL if
2299  /// none exists.
2301  /// \brief Get the implementation of the ObjCCategoryDecl \p D, or NULL if
2302  /// none exists.
2304 
2305  /// \brief Return true if there is at least one \@implementation in the TU.
2307  return !ObjCImpls.empty();
2308  }
2309 
2310  /// \brief Set the implementation of ObjCInterfaceDecl.
2312  ObjCImplementationDecl *ImplD);
2313  /// \brief Set the implementation of ObjCCategoryDecl.
2315  ObjCCategoryImplDecl *ImplD);
2316 
2317  /// \brief Get the duplicate declaration of a ObjCMethod in the same
2318  /// interface, or null if none exists.
2319  const ObjCMethodDecl *
2320  getObjCMethodRedeclaration(const ObjCMethodDecl *MD) const;
2321 
2323  const ObjCMethodDecl *Redecl);
2324 
2325  /// \brief Returns the Objective-C interface that \p ND belongs to if it is
2326  /// an Objective-C method/property/ivar etc. that is part of an interface,
2327  /// otherwise returns null.
2328  const ObjCInterfaceDecl *getObjContainingInterface(const NamedDecl *ND) const;
2329 
2330  /// \brief Set the copy inialization expression of a block var decl.
2331  void setBlockVarCopyInits(VarDecl*VD, Expr* Init);
2332  /// \brief Get the copy initialization expression of the VarDecl \p VD, or
2333  /// NULL if none exists.
2334  Expr *getBlockVarCopyInits(const VarDecl* VD);
2335 
2336  /// \brief Allocate an uninitialized TypeSourceInfo.
2337  ///
2338  /// The caller should initialize the memory held by TypeSourceInfo using
2339  /// the TypeLoc wrappers.
2340  ///
2341  /// \param T the type that will be the basis for type source info. This type
2342  /// should refer to how the declarator was written in source code, not to
2343  /// what type semantic analysis resolved the declarator to.
2344  ///
2345  /// \param Size the size of the type info to create, or 0 if the size
2346  /// should be calculated based on the type.
2347  TypeSourceInfo *CreateTypeSourceInfo(QualType T, unsigned Size = 0) const;
2348 
2349  /// \brief Allocate a TypeSourceInfo where all locations have been
2350  /// initialized to a given location, which defaults to the empty
2351  /// location.
2352  TypeSourceInfo *
2354  SourceLocation Loc = SourceLocation()) const;
2355 
2356  /// \brief Add a deallocation callback that will be invoked when the
2357  /// ASTContext is destroyed.
2358  ///
2359  /// \param Callback A callback function that will be invoked on destruction.
2360  ///
2361  /// \param Data Pointer data that will be provided to the callback function
2362  /// when it is called.
2363  void AddDeallocation(void (*Callback)(void*), void *Data);
2364 
2367 
2368  /// \brief Determines if the decl can be CodeGen'ed or deserialized from PCH
2369  /// lazily, only when used; this is only relevant for function or file scoped
2370  /// var definitions.
2371  ///
2372  /// \returns true if the function/var must be CodeGen'ed/deserialized even if
2373  /// it is not used.
2374  bool DeclMustBeEmitted(const Decl *D);
2375 
2376  const CXXConstructorDecl *
2378 
2380  CXXConstructorDecl *CD);
2381 
2383  unsigned ParmIdx, Expr *DAE);
2384 
2386  unsigned ParmIdx);
2387 
2389 
2391 
2393 
2395 
2396  void setManglingNumber(const NamedDecl *ND, unsigned Number);
2397  unsigned getManglingNumber(const NamedDecl *ND) const;
2398 
2399  void setStaticLocalNumber(const VarDecl *VD, unsigned Number);
2400  unsigned getStaticLocalNumber(const VarDecl *VD) const;
2401 
2402  /// \brief Retrieve the context for computing mangling numbers in the given
2403  /// DeclContext.
2405 
2407 
2408  /// \brief Used by ParmVarDecl to store on the side the
2409  /// index of the parameter when it exceeds the size of the normal bitfield.
2410  void setParameterIndex(const ParmVarDecl *D, unsigned index);
2411 
2412  /// \brief Used by ParmVarDecl to retrieve on the side the
2413  /// index of the parameter when it exceeds the size of the normal bitfield.
2414  unsigned getParameterIndex(const ParmVarDecl *D) const;
2415 
2416  /// \brief Get the storage for the constant value of a materialized temporary
2417  /// of static storage duration.
2419  bool MayCreate);
2420 
2421  //===--------------------------------------------------------------------===//
2422  // Statistics
2423  //===--------------------------------------------------------------------===//
2424 
2425  /// \brief The number of implicitly-declared default constructors.
2427 
2428  /// \brief The number of implicitly-declared default constructors for
2429  /// which declarations were built.
2431 
2432  /// \brief The number of implicitly-declared copy constructors.
2434 
2435  /// \brief The number of implicitly-declared copy constructors for
2436  /// which declarations were built.
2438 
2439  /// \brief The number of implicitly-declared move constructors.
2441 
2442  /// \brief The number of implicitly-declared move constructors for
2443  /// which declarations were built.
2445 
2446  /// \brief The number of implicitly-declared copy assignment operators.
2448 
2449  /// \brief The number of implicitly-declared copy assignment operators for
2450  /// which declarations were built.
2452 
2453  /// \brief The number of implicitly-declared move assignment operators.
2455 
2456  /// \brief The number of implicitly-declared move assignment operators for
2457  /// which declarations were built.
2459 
2460  /// \brief The number of implicitly-declared destructors.
2461  static unsigned NumImplicitDestructors;
2462 
2463  /// \brief The number of implicitly-declared destructors for which
2464  /// declarations were built.
2466 
2467 private:
2468  ASTContext(const ASTContext &) = delete;
2469  void operator=(const ASTContext &) = delete;
2470 
2471 public:
2472  /// \brief Initialize built-in types.
2473  ///
2474  /// This routine may only be invoked once for a given ASTContext object.
2475  /// It is normally invoked after ASTContext construction.
2476  ///
2477  /// \param Target The target
2478  void InitBuiltinTypes(const TargetInfo &Target,
2479  const TargetInfo *AuxTarget = nullptr);
2480 
2481 private:
2482  void InitBuiltinType(CanQualType &R, BuiltinType::Kind K);
2483 
2484  // Return the Objective-C type encoding for a given type.
2485  void getObjCEncodingForTypeImpl(QualType t, std::string &S,
2486  bool ExpandPointedToStructures,
2487  bool ExpandStructures,
2488  const FieldDecl *Field,
2489  bool OutermostType = false,
2490  bool EncodingProperty = false,
2491  bool StructField = false,
2492  bool EncodeBlockParameters = false,
2493  bool EncodeClassNames = false,
2494  bool EncodePointerToObjCTypedef = false,
2495  QualType *NotEncodedT=nullptr) const;
2496 
2497  // Adds the encoding of the structure's members.
2498  void getObjCEncodingForStructureImpl(RecordDecl *RD, std::string &S,
2499  const FieldDecl *Field,
2500  bool includeVBases = true,
2501  QualType *NotEncodedT=nullptr) const;
2502 public:
2503  // Adds the encoding of a method parameter or return type.
2505  QualType T, std::string& S,
2506  bool Extended) const;
2507 
2508  /// \brief Returns true if this is an inline-initialized static data member
2509  /// which is treated as a definition for MSVC compatibility.
2510  bool isMSStaticDataMemberInlineDefinition(const VarDecl *VD) const;
2511 
2512 private:
2513  const ASTRecordLayout &
2514  getObjCLayout(const ObjCInterfaceDecl *D,
2515  const ObjCImplementationDecl *Impl) const;
2516 
2517  /// \brief A set of deallocations that should be performed when the
2518  /// ASTContext is destroyed.
2519  // FIXME: We really should have a better mechanism in the ASTContext to
2520  // manage running destructors for types which do variable sized allocation
2521  // within the AST. In some places we thread the AST bump pointer allocator
2522  // into the datastructures which avoids this mess during deallocation but is
2523  // wasteful of memory, and here we require a lot of error prone book keeping
2524  // in order to track and run destructors while we're tearing things down.
2527  DeallocationFunctionsAndArguments Deallocations;
2528 
2529  // FIXME: This currently contains the set of StoredDeclMaps used
2530  // by DeclContext objects. This probably should not be in ASTContext,
2531  // but we include it here so that ASTContext can quickly deallocate them.
2532  llvm::PointerIntPair<StoredDeclsMap*,1> LastSDM;
2533 
2534  friend class DeclContext;
2535  friend class DeclarationNameTable;
2536  void ReleaseDeclContextMaps();
2537  void ReleaseParentMapEntries();
2538 
2539  std::unique_ptr<ParentMapPointers> PointerParents;
2540  std::unique_ptr<ParentMapOtherNodes> OtherParents;
2541 
2542  std::unique_ptr<VTableContextBase> VTContext;
2543 
2544 public:
2545  enum PragmaSectionFlag : unsigned {
2547  PSF_Read = 0x1,
2548  PSF_Write = 0x2,
2551  PSF_Invalid = 0x80000000U,
2552  };
2553 
2554  struct SectionInfo {
2561  int SectionFlags)
2562  : Decl(Decl),
2563  PragmaSectionLocation(PragmaSectionLocation),
2564  SectionFlags(SectionFlags) {}
2565  };
2566 
2567  llvm::StringMap<SectionInfo> SectionInfos;
2568 };
2569 
2570 /// \brief Utility function for constructing a nullary selector.
2571 static inline Selector GetNullarySelector(StringRef name, ASTContext& Ctx) {
2572  IdentifierInfo* II = &Ctx.Idents.get(name);
2573  return Ctx.Selectors.getSelector(0, &II);
2574 }
2575 
2576 /// \brief Utility function for constructing an unary selector.
2577 static inline Selector GetUnarySelector(StringRef name, ASTContext& Ctx) {
2578  IdentifierInfo* II = &Ctx.Idents.get(name);
2579  return Ctx.Selectors.getSelector(1, &II);
2580 }
2581 
2582 } // end namespace clang
2583 
2584 // operator new and delete aren't allowed inside namespaces.
2585 
2586 /// @brief Placement new for using the ASTContext's allocator.
2587 ///
2588 /// This placement form of operator new uses the ASTContext's allocator for
2589 /// obtaining memory.
2590 ///
2591 /// IMPORTANT: These are also declared in clang/AST/AttrIterator.h! Any changes
2592 /// here need to also be made there.
2593 ///
2594 /// We intentionally avoid using a nothrow specification here so that the calls
2595 /// to this operator will not perform a null check on the result -- the
2596 /// underlying allocator never returns null pointers.
2597 ///
2598 /// Usage looks like this (assuming there's an ASTContext 'Context' in scope):
2599 /// @code
2600 /// // Default alignment (8)
2601 /// IntegerLiteral *Ex = new (Context) IntegerLiteral(arguments);
2602 /// // Specific alignment
2603 /// IntegerLiteral *Ex2 = new (Context, 4) IntegerLiteral(arguments);
2604 /// @endcode
2605 /// Memory allocated through this placement new operator does not need to be
2606 /// explicitly freed, as ASTContext will free all of this memory when it gets
2607 /// destroyed. Please note that you cannot use delete on the pointer.
2608 ///
2609 /// @param Bytes The number of bytes to allocate. Calculated by the compiler.
2610 /// @param C The ASTContext that provides the allocator.
2611 /// @param Alignment The alignment of the allocated memory (if the underlying
2612 /// allocator supports it).
2613 /// @return The allocated memory. Could be NULL.
2614 inline void *operator new(size_t Bytes, const clang::ASTContext &C,
2615  size_t Alignment) {
2616  return C.Allocate(Bytes, Alignment);
2617 }
2618 /// @brief Placement delete companion to the new above.
2619 ///
2620 /// This operator is just a companion to the new above. There is no way of
2621 /// invoking it directly; see the new operator for more details. This operator
2622 /// is called implicitly by the compiler if a placement new expression using
2623 /// the ASTContext throws in the object constructor.
2624 inline void operator delete(void *Ptr, const clang::ASTContext &C, size_t) {
2625  C.Deallocate(Ptr);
2626 }
2627 
2628 /// This placement form of operator new[] uses the ASTContext's allocator for
2629 /// obtaining memory.
2630 ///
2631 /// We intentionally avoid using a nothrow specification here so that the calls
2632 /// to this operator will not perform a null check on the result -- the
2633 /// underlying allocator never returns null pointers.
2634 ///
2635 /// Usage looks like this (assuming there's an ASTContext 'Context' in scope):
2636 /// @code
2637 /// // Default alignment (8)
2638 /// char *data = new (Context) char[10];
2639 /// // Specific alignment
2640 /// char *data = new (Context, 4) char[10];
2641 /// @endcode
2642 /// Memory allocated through this placement new[] operator does not need to be
2643 /// explicitly freed, as ASTContext will free all of this memory when it gets
2644 /// destroyed. Please note that you cannot use delete on the pointer.
2645 ///
2646 /// @param Bytes The number of bytes to allocate. Calculated by the compiler.
2647 /// @param C The ASTContext that provides the allocator.
2648 /// @param Alignment The alignment of the allocated memory (if the underlying
2649 /// allocator supports it).
2650 /// @return The allocated memory. Could be NULL.
2651 inline void *operator new[](size_t Bytes, const clang::ASTContext& C,
2652  size_t Alignment = 8) {
2653  return C.Allocate(Bytes, Alignment);
2654 }
2655 
2656 /// @brief Placement delete[] companion to the new[] above.
2657 ///
2658 /// This operator is just a companion to the new[] above. There is no way of
2659 /// invoking it directly; see the new[] operator for more details. This operator
2660 /// is called implicitly by the compiler if a placement new[] expression using
2661 /// the ASTContext throws in the object constructor.
2662 inline void operator delete[](void *Ptr, const clang::ASTContext &C, size_t) {
2663  C.Deallocate(Ptr);
2664 }
2665 
2666 /// \brief Create the representation of a LazyGenerationalUpdatePtr.
2667 template <typename Owner, typename T,
2668  void (clang::ExternalASTSource::*Update)(Owner)>
2671  const clang::ASTContext &Ctx, T Value) {
2672  // Note, this is implemented here so that ExternalASTSource.h doesn't need to
2673  // include ASTContext.h. We explicitly instantiate it for all relevant types
2674  // in ASTContext.cpp.
2675  if (auto *Source = Ctx.getExternalSource())
2676  return new (Ctx) LazyData(Source, Value);
2677  return Value;
2678 }
2679 
2680 #endif
static CanQual< Type > CreateUnsafe(QualType Other)
Builds a canonical type from a QualType.
void setExternalSource(IntrusiveRefCntPtr< ExternalASTSource > Source)
Attach an external AST source to the AST context.
Definition: ASTContext.cpp:818
MemberSpecializationInfo * getInstantiatedFromStaticDataMember(const VarDecl *Var)
If this variable is an instantiated static data member of a class template specialization, returns the templated static data member from which it was instantiated.
TypedefDecl * getObjCInstanceTypeDecl()
Retrieve the typedef declaration corresponding to the Objective-C "instancetype" type.
void setPrimaryMergedDecl(Decl *D, Decl *Primary)
Definition: ASTContext.h:854
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i...
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType) const
void setTemplateOrSpecializationInfo(VarDecl *Inst, TemplateOrSpecializationInfo TSI)
ASTMutationListener * Listener
Definition: ASTContext.h:456
const Type * Ty
The locally-unqualified type.
Definition: Type.h:520
static Selector GetNullarySelector(StringRef name, ASTContext &Ctx)
Utility function for constructing a nullary selector.
Definition: ASTContext.h:2571
CanQualType LongLongTy
Definition: ASTContext.h:889
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Definition: Decl.h:1483
void setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl, TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
Note that the static data member Inst is an instantiation of the static data member template Tmpl of ...
llvm::PointerUnion< VarTemplateDecl *, MemberSpecializationInfo * > TemplateOrSpecializationInfo
A type synonym for the TemplateOrInstantiation mapping.
Definition: ASTContext.h:311
AttrVec & getDeclAttrs(const Decl *D)
Retrieve the attributes for the given declaration.
CanQualType WIntTy
Definition: ASTContext.h:886
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
void setjmp_bufDecl(TypeDecl *jmp_bufDecl)
Set the type for the C jmp_buf type.
Definition: ASTContext.h:1488
ObjCPropertyImplDecl * getObjCPropertyImplDeclForPropertyDecl(const ObjCPropertyDecl *PD, const Decl *Container) const
CanQualType OCLQueueTy
Definition: ASTContext.h:907
Smart pointer class that efficiently represents Objective-C method names.
Holds information about both target-independent and target-specific builtins, allowing easy queries b...
Definition: Builtins.h:64
CanQualType LongDoubleComplexTy
Definition: ASTContext.h:894
GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const
QualType mergeFunctionTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false)
CanQualType VoidPtrTy
Definition: ASTContext.h:895
A (possibly-)qualified type.
Definition: Type.h:575
unsigned overridden_methods_size(const CXXMethodDecl *Method) const
QualType areCommonBaseCompatible(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
TypedefDecl * getUInt128Decl() const
Retrieve the declaration for the 128-bit unsigned integer type.
Definition: ASTContext.cpp:963
CanQualType OCLImage1dBufferTy
Definition: ASTContext.h:901
unsigned getTypeAlign(const Type *T) const
Definition: ASTContext.h:1815
void getObjCEncodingForPropertyType(QualType T, std::string &S) const
Emit the Objective-C property type encoding for the given type T into S.
bool ProtocolCompatibleWithProtocol(ObjCProtocolDecl *lProto, ObjCProtocolDecl *rProto) const
ProtocolCompatibleWithProtocol - return 'true' if 'lProto' is in the inheritance hierarchy of 'rProto...
NestedNameSpecifier * getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const
Retrieves the "canonical" nested name specifier for a given nested name specifier.
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
ASTContext(LangOptions &LOpts, SourceManager &SM, IdentifierTable &idents, SelectorTable &sels, Builtin::Context &builtins)
Definition: ASTContext.cpp:730
static Selector GetUnarySelector(StringRef name, ASTContext &Ctx)
Utility function for constructing an unary selector.
Definition: ASTContext.h:2577
QualType getAdjustedType(QualType Orig, QualType New) const
Return the uniqued reference to a type adjusted from the original type to a new type.
bool operator==(CanQual< T > x, CanQual< U > y)
static unsigned NumImplicitMoveAssignmentOperatorsDeclared
The number of implicitly-declared move assignment operators for which declarations were built...
Definition: ASTContext.h:2458
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type...
RecordDecl * buildImplicitRecord(StringRef Name, RecordDecl::TagKind TK=TTK_Struct) const
Create a new implicit TU-level CXXRecordDecl or RecordDecl declaration.
Definition: ASTContext.cpp:931
void getObjCEncodingForTypeQualifier(Decl::ObjCDeclQualifier QT, std::string &S) const
Put the string version of the type qualifiers QT into S.
unsigned getFastQualifiers() const
Definition: Type.h:331
CanQualType Char32Ty
Definition: ASTContext.h:888
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
Definition: ASTContext.h:1673
static unsigned NumImplicitDefaultConstructors
The number of implicitly-declared default constructors.
Definition: ASTContext.h:2426
CanQualType OCLImage2dMSAADepthTy
Definition: ASTContext.h:904
uint64_t getTypeSize(const Type *T) const
Definition: ASTContext.h:1794
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
Definition: Type.h:1214
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:2847
CanQualType getComplexType(CanQualType T) const
Definition: ASTContext.h:1044
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
bool CommentsLoaded
True if comments are already loaded from ExternalASTSource.
Definition: ASTContext.h:612
void addComment(const RawComment &RC, llvm::BumpPtrAllocator &Allocator)
unsigned getIntWidth(QualType T) const
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth, signed/unsigned.
TypedefDecl - Represents the declaration of a typedef-name via the 'typedef' type specifier...
Definition: Decl.h:2598
C Language Family Type Representation.
void setObjCClassRedefinitionType(QualType RedefType)
Set the user-written type that redefines 'SEL'.
Definition: ASTContext.h:1425
QualType getWCharType() const
Return the unique wchar_t type available in C++ (and available as __wchar_t as a Microsoft extension)...
Definition: ASTContext.h:1336
static unsigned NumImplicitMoveAssignmentOperators
The number of implicitly-declared move assignment operators.
Definition: ASTContext.h:2454
void setucontext_tDecl(TypeDecl *ucontext_tDecl)
Set the type for the C ucontext_t type.
Definition: ASTContext.h:1512
QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType, UnaryTransformType::UTTKind UKind) const
Unary type transforms.
CanQualType FloatComplexTy
Definition: ASTContext.h:894
RawCommentList Comments
All comments in this translation unit.
Definition: ASTContext.h:609
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:77
CanQualType ObjCBuiltinSelTy
Definition: ASTContext.h:899
void addDefaultArgExprForConstructor(const CXXConstructorDecl *CD, unsigned ParmIdx, Expr *DAE)
QualType getVolatileType(QualType T) const
Return the uniqued reference to the type for a volatile qualified type.
Definition: ASTContext.h:1012
std::string getObjCEncodingForBlock(const BlockExpr *blockExpr) const
Return the encoded type for this block declaration.
bool isAlignmentRequired(const Type *T) const
Determine if the alignment the type has was required using an alignment attribute.
llvm::iterator_range< import_iterator > import_range
Definition: ASTContext.h:845
const DynTypedNode & operator[](size_t N) const
Definition: ASTContext.h:509
FullSourceLoc getFullLoc(SourceLocation Loc) const
Definition: ASTContext.h:604
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
CanQualType ARCUnbridgedCastTy
Definition: ASTContext.h:898
The base class of the type hierarchy.
Definition: Type.h:1249
void setParameterIndex(const ParmVarDecl *D, unsigned index)
Used by ParmVarDecl to store on the side the index of the parameter when it exceeds the size of the n...
CanQualType LongTy
Definition: ASTContext.h:889
const IncompleteArrayType * getAsIncompleteArrayType(QualType T) const
Definition: ASTContext.h:2100
DependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, unsigned NumArgs, const TemplateArgument *Args, QualType Canon)
Definition: Type.cpp:2454
QualType getRecordType(const RecordDecl *Decl) const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition: Type.h:2424
QualType getObjCClassRedefinitionType() const
Retrieve the type that Class has been defined to, which may be different from the built-in Class if C...
Definition: ASTContext.h:1418
A container of type source information.
Definition: Decl.h:61
FieldDecl * getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field)
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2134
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Definition: ExprCXX.h:3864
CanQualType WideCharTy
Definition: ASTContext.h:885
QualType getPipeType(QualType T) const
Return pipe type for the specified type.
SourceRange getSourceRange() const LLVM_READONLY
CanQualType HalfTy
Definition: ASTContext.h:893
void setInstantiatedFromUsingDecl(UsingDecl *Inst, NamedDecl *Pattern)
Remember that the using decl Inst is an instantiation of the using decl Pattern of a class template...
const ASTRecordLayout & getASTObjCImplementationLayout(const ObjCImplementationDecl *D) const
Get or compute information about the layout of the specified Objective-C implementation.
const ast_type_traits::DynTypedNode * begin() const
Definition: ASTContext.h:493
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
QualType getVariableArrayDecayedType(QualType Ty) const
Returns a vla type where known sizes are replaced with [*].
const RawComment * getRaw() const LLVM_READONLY
Definition: ASTContext.h:647
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Definition: Decl.h:699
QualType getRestrictType(QualType T) const
Return the uniqued reference to the type for a restrict qualified type.
Definition: ASTContext.h:1003
QualType getFloatingTypeOfSizeWithinDomain(QualType typeSize, QualType typeDomain) const
Return a real floating point or a complex type (based on typeDomain/typeSize).
TypedefDecl * getBuiltinVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_va_list type...
void removeObjCLifetime()
Definition: Type.h:296
comments::FullComment * getLocalCommentForDeclUncached(const Decl *D) const
Return parsed documentation comment attached to a given declaration.
Definition: ASTContext.cpp:436
void setClassScopeSpecializationPattern(FunctionDecl *FD, FunctionDecl *Pattern)
MangleContext * createMangleContext()
QualType isPromotableBitField(Expr *E) const
Whether this is a promotable bitfield reference according to C99 6.3.1.1p2, bullet 2 (and GCC extensi...
Extra information about a function prototype.
Definition: Type.h:3067
Declaration context for names declared as extern "C" in C++.
Definition: Decl.h:123
QualType getObjCClassType() const
Represents the Objective-C Class type.
Definition: ASTContext.h:1615
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
Definition: ASTContext.h:1793
QualType getucontext_tType() const
Retrieve the C ucontext_t type.
Definition: ASTContext.h:1517
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:113
ObjCImplementationDecl * getObjCImplementation(ObjCInterfaceDecl *D)
Get the implementation of the ObjCInterfaceDecl D, or NULL if none exists.
void setRaw(const RawComment *RC)
Definition: ASTContext.h:651
void PrintStats() const
Definition: ASTContext.cpp:822
Describes how types, statements, expressions, and declarations should be printed. ...
Definition: PrettyPrinter.h:35
bool FunctionTypesMatchOnNSConsumedAttrs(const FunctionProtoType *FromFunctionType, const FunctionProtoType *ToFunctionType)
ParmVarDecl - Represents a parameter to a function.
Definition: Decl.h:1299
QualType getRawCFConstantStringType() const
Get the structure type used to representation CFStrings, or NULL if it hasn't yet been built...
Definition: ASTContext.h:1382
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
Represents the builtin template declaration which is used to implement __make_integer_seq.
The collection of all-type qualifiers we support.
Definition: Type.h:116
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
CanQualType OCLSamplerTy
Definition: ASTContext.h:906
unsigned getStaticLocalNumber(const VarDecl *VD) const
const SmallVectorImpl< Type * > & getTypes() const
Definition: ASTContext.h:950
RecordDecl - Represents a struct/union/class.
Definition: Decl.h:3166
ObjCInterfaceDecl * getObjCProtocolDecl() const
Retrieve the Objective-C class declaration corresponding to the predefined Protocol class...
CharUnits getOffsetOfBaseWithVBPtr(const CXXRecordDecl *RD) const
Loading virtual member pointers using the virtual inheritance model always results in an adjustment u...
CanQualType getIntMaxType() const
Return the unique type for "intmax_t" (C99 7.18.1.5), defined in <stdint.h>.
One of these records is kept for each identifier that is lexed.
comments::CommandTraits & getCommentCommandTraits() const
Definition: ASTContext.h:760
This table allows us to fully hide how we implement multi-keyword caching.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
Definition: Type.h:4381
CanQualType OCLImage2dArrayMSAADepthTy
Definition: ASTContext.h:904
void getOverriddenMethods(const NamedDecl *Method, SmallVectorImpl< const NamedDecl * > &Overridden) const
Return C++ or ObjC overridden methods for the given Method.
Represents a class type in Objective C.
Definition: Type.h:4557
void setManglingNumber(const NamedDecl *ND, unsigned Number)
QualType getUnsignedWCharType() const
Return the type of "unsigned wchar_t".
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:91
static unsigned NumImplicitMoveConstructorsDeclared
The number of implicitly-declared move constructors for which declarations were built.
Definition: ASTContext.h:2444
CanQualType OCLImage2dArrayTy
Definition: ASTContext.h:902
void setObjCConstantStringInterface(ObjCInterfaceDecl *Decl)
void setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst, FieldDecl *Tmpl)
Missing a type from <ucontext.h>
Definition: ASTContext.h:1740
QualType getAddrSpaceQualType(QualType T, unsigned AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
QualType getLifetimeQualifiedType(QualType type, Qualifiers::ObjCLifetime lifetime)
Return a type with the given lifetime qualifier.
Definition: ASTContext.h:1696
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size...
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Definition: Decl.h:2209
This class represents all comments included in the translation unit, sorted in order of appearance in...
DynTypedNodeList getParents(const NodeT &Node)
Returns the parents of the given node.
Definition: ASTContext.h:539
void setBOOLDecl(TypedefDecl *TD)
Save declaration of 'BOOL' typedef.
Definition: ASTContext.h:1629
void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass, SmallVectorImpl< const ObjCIvarDecl * > &Ivars) const
DeepCollectObjCIvars - This routine first collects all declared, but not synthesized, ivars in super class and then collects all ivars, including those synthesized for current class.
const ast_type_traits::DynTypedNode * end() const
Definition: ASTContext.h:500
DynTypedNodeList(ArrayRef< DynTypedNode > A)
Definition: ASTContext.h:489
void Deallocate(void *Ptr) const
Definition: ASTContext.h:566
QualType getBlockDescriptorType() const
Gets the struct used to keep track of the descriptor for pointer to blocks.
CanQualType OCLEventTy
Definition: ASTContext.h:906
The iterator over UnresolvedSets.
Definition: UnresolvedSet.h:28
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
Definition: ASTContext.h:1962
void getObjCEncodingForMethodParameter(Decl::ObjCDeclQualifier QT, QualType T, std::string &S, bool Extended) const
getObjCEncodingForMethodParameter - Return the encoded type for a single method parameter or return t...
Container for either a single DynTypedNode or for an ArrayRef to DynTypedNode.
Definition: ASTContext.h:479
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
QualType getTypeOfType(QualType t) const
getTypeOfType - Unlike many "get<Type>" functions, we don't unique TypeOfType nodes...
clang::CharUnits operator*(clang::CharUnits::QuantityType Scale, const clang::CharUnits &CU)
Definition: CharUnits.h:201
void setPrintingPolicy(const clang::PrintingPolicy &Policy)
Definition: ASTContext.h:549
unsigned getTargetDefaultAlignForAttributeAligned(void) const
Return the default alignment for attribute((aligned)) on this target, to be used if no alignment valu...
CanQualType OCLReserveIDTy
Definition: ASTContext.h:907
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:48
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
Definition: ASTContext.h:1191
llvm::BumpPtrAllocator & getAllocator() const
Definition: ASTContext.h:556
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
Definition: ASTContext.h:1987
Describes a module or submodule.
Definition: Basic/Module.h:47
IdentifierTable & Idents
Definition: ASTContext.h:451
bool ObjCObjectAdoptsQTypeProtocols(QualType QT, ObjCInterfaceDecl *Decl)
ObjCObjectAdoptsQTypeProtocols - Checks that protocols in IC's protocol list adopt all protocols in Q...
RawCommentList & getRawCommentList()
Definition: ASTContext.h:684
Values of this type can be null.
bool isNearlyEmpty(const CXXRecordDecl *RD) const
unsigned CountNonClassIvars(const ObjCInterfaceDecl *OI) const
QualType mergeObjCGCQualifiers(QualType, QualType)
mergeObjCGCQualifiers - This routine merges ObjC's GC attribute of 'LHS' and 'RHS' attributes and ret...
QualType getObjCNSStringType() const
Definition: ASTContext.h:1395
Represents a C++ using-declaration.
Definition: DeclCXX.h:2858
bool hasNonFastQualifiers() const
Return true if the set contains any qualifiers which require an ExtQuals node to be allocated...
Definition: Type.h:350
QualType getParenType(QualType NamedType) const
const TargetInfo & getTargetInfo() const
Definition: ASTContext.h:580
bool UnwrapSimilarPointerTypes(QualType &T1, QualType &T2)
UnwrapSimilarPointerTypes - If T1 and T2 are pointer types that may be similar (C++ 4...
CanQualType OCLImage2dTy
Definition: ASTContext.h:902
ObjCContainerDecl - Represents a container for method declarations.
Definition: DeclObjC.h:696
const LangOptions & getLangOpts() const
Definition: ASTContext.h:596
CharUnits - This is an opaque type for sizes expressed in character units.
Definition: CharUnits.h:38
A convenient class for passing around template argument information.
Definition: TemplateBase.h:517
void setcudaConfigureCallDecl(FunctionDecl *FD)
Definition: ASTContext.h:1090
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error, unsigned *IntegerConstantArgs=nullptr) const
Return the type for the specified builtin.
Whether values of this type can be null is (explicitly) unspecified.
Qualifiers::ObjCLifetime getInnerObjCOwnership(QualType T) const
Recurses in pointer/array types until it finds an Objective-C retainable type and returns its ownersh...
TemplateName getSubstTemplateTemplateParm(TemplateTemplateParmDecl *param, TemplateName replacement) const
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:135
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
TypeDecl - Represents a declaration of a type.
Definition: Decl.h:2486
bool getByrefLifetime(QualType Ty, Qualifiers::ObjCLifetime &Lifetime, bool &HasByrefExtendedLayout) const
Returns true, if given type has a known lifetime.
unsigned getOpenMPDefaultSimdAlign(QualType T) const
Get default simd alignment of the specified complete type in bits.
CanQualType PseudoObjectTy
Definition: ASTContext.h:898
QualType getIntPtrType() const
Return a type compatible with "intptr_t" (C99 7.18.1.4), as defined by the target.
Decl * getVaListTagDecl() const
Retrieve the C type declaration corresponding to the predefined __va_list_tag type used to help defin...
TypedefDecl * getObjCIdDecl() const
Retrieve the typedef corresponding to the predefined id type in Objective-C.
const SanitizerBlacklist & getSanitizerBlacklist() const
Definition: ASTContext.h:598
CanQualType LongDoubleTy
Definition: ASTContext.h:892
Values of this type can never be null.
unsigned Align
Definition: ASTContext.h:82
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D...
QualType getSignatureParameterType(QualType T) const
Retrieve the parameter type as adjusted for use in the signature of a function, decaying array and fu...
bool AlignIsRequired
Definition: ASTContext.h:83
QualType getsigjmp_bufType() const
Retrieve the C sigjmp_buf type.
Definition: ASTContext.h:1505
void eraseDeclAttrs(const Decl *D)
Erase the attributes corresponding to the given declaration.
CanQualType getAdjustedType(CanQualType Orig, CanQualType New) const
Definition: ASTContext.h:1058
static unsigned NumImplicitDefaultConstructorsDeclared
The number of implicitly-declared default constructors for which declarations were built...
Definition: ASTContext.h:2430
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:1728
A cache of the value of this pointer, in the most recent generation in which we queried it...
QualType mergeTransparentUnionType(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false)
mergeTransparentUnionType - if T is a transparent union type and a member of T is compatible with Sub...
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
Represents an ObjC class declaration.
Definition: DeclObjC.h:853
Decl * getPrimaryMergedDecl(Decl *D)
Definition: ASTContext.h:850
const DependentSizedArrayType * getAsDependentSizedArrayType(QualType T) const
Definition: ASTContext.h:2103
CanQualType OCLImage3dTy
Definition: ASTContext.h:905
TypedefDecl * getObjCClassDecl() const
Retrieve the typedef declaration corresponding to the predefined Objective-C 'Class' type...
QualType getCanonicalTypeInternal() const
Definition: Type.h:1973
QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const
getInjectedClassNameType - Return the unique reference to the injected class name type for the specif...
std::pair< CharUnits, CharUnits > getTypeInfoInChars(const Type *T) const
IntrusiveRefCntPtr< ExternalASTSource > ExternalSource
Definition: ASTContext.h:455
CanQualType UnsignedCharTy
Definition: ASTContext.h:890
DiagnosticsEngine & getDiagnostics() const
unsigned getPreferredTypeAlign(const Type *T) const
Return the "preferred" alignment of the specified type T for the current target, in bits...
bool addressSpaceMapManglingFor(unsigned AS) const
Definition: ASTContext.h:2195
QualType getAutoRRefDeductType() const
C++11 deduction pattern for 'auto &&' type.
QualType getTemplateSpecializationType(TemplateName T, const TemplateArgument *Args, unsigned NumArgs, QualType Canon=QualType()) const
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition: DeclObjC.h:2605
Provides definitions for the various language-specific address spaces.
void adjustDeducedFunctionResultType(FunctionDecl *FD, QualType ResultType)
Change the result type of a function type once it is deduced.
llvm::StringMap< SectionInfo > SectionInfos
Definition: ASTContext.h:2567
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
bool AtomicUsesUnsupportedLibcall(const AtomicExpr *E) const
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3041
T * Allocate(size_t Num=1) const
Definition: ASTContext.h:563
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
Definition: Type.h:980
static unsigned NumImplicitCopyConstructors
The number of implicitly-declared copy constructors.
Definition: ASTContext.h:2433
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:577
ArrayRef< Module * > getModulesWithMergedDefinition(NamedDecl *Def)
Get the additional modules in which the definition Def has been merged.
Definition: ASTContext.h:868
DeclarationNameTable DeclarationNames
Definition: ASTContext.h:454
QualType getLogicalOperationType() const
The result type of logical operations, '<', '>', '!=', etc.
Definition: ASTContext.h:1524
void getObjCEncodingForType(QualType T, std::string &S, const FieldDecl *Field=nullptr, QualType *NotEncodedT=nullptr) const
Emit the Objective-CC type encoding for the given type T into S.
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition: Type.h:2430
overridden_cxx_method_iterator overridden_methods_end(const CXXMethodDecl *Method) const
void addObjCLifetime(ObjCLifetime type)
Definition: Type.h:297
void setCFConstantStringType(QualType T)
const SmallVectorImpl< AnnotatedLine * >::const_iterator End
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
bool AnyObjCImplementation()
Return true if there is at least one @implementation in the TU.
Definition: ASTContext.h:2306
ID
Defines the set of possible language-specific address spaces.
Definition: AddressSpaces.h:27
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
SourceManager & SM
bool ObjCMethodsAreEqual(const ObjCMethodDecl *MethodDecl, const ObjCMethodDecl *MethodImp)
std::pair< CharUnits, CharUnits > getTypeInfoDataSizeInChars(QualType T) const
CanQualType OCLNDRangeTy
Definition: ASTContext.h:907
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
Definition: RecordLayout.h:34
Exposes information about the current target.
QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, const TemplateArgumentListInfo &Args) const
Represents an array type in C++ whose size is a value-dependent expression.
Definition: Type.h:2627
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
Definition: Type.cpp:1716
int * Depth
bool hasSameType(const Type *T1, const Type *T2) const
Definition: ASTContext.h:1966
bool isMSStaticDataMemberInlineDefinition(const VarDecl *VD) const
Returns true if this is an inline-initialized static data member which is treated as a definition for...
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Definition: Decl.h:521
Expr - This represents one expression.
Definition: Expr.h:104
Defines the clang::LangOptions interface.
CanQualType getCanonicalFunctionResultType(QualType ResultType) const
Adjust the given function result type.
QualType getBlockDescriptorExtendedType() const
Gets the struct used to keep track of the extended descriptor for pointer to blocks.
void setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst, UsingShadowDecl *Pattern)
void addTypedefNameForUnnamedTagDecl(TagDecl *TD, TypedefNameDecl *TND)
void ResetObjCLayout(const ObjCContainerDecl *CD)
MatchFinder::MatchCallback * Callback
CanQualType OCLImage1dTy
Definition: ASTContext.h:901
Declaration of a template type parameter.
Implements an efficient mapping from strings to IdentifierInfo nodes.
DeclarationNameTable - Used to store and retrieve DeclarationName instances for the various kinds of ...
void setObjCMethodRedeclaration(const ObjCMethodDecl *MD, const ObjCMethodDecl *Redecl)
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition: Type.h:4189
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:4580
unsigned getParameterIndex(const ParmVarDecl *D) const
Used by ParmVarDecl to retrieve on the side the index of the parameter when it exceeds the size of th...
QualType getWIntType() const
In C99, this returns a type compatible with the type defined in <stddef.h> as defined by the target...
Definition: ASTContext.h:1355
CanQualType OMPArraySectionTy
Definition: ASTContext.h:908
CanQualType getUIntMaxType() const
Return the unique type for "uintmax_t" (C99 7.18.1.5), defined in <stdint.h>.
TranslationUnitDecl * getTranslationUnitDecl() const
Definition: ASTContext.h:875
static unsigned NumImplicitMoveConstructors
The number of implicitly-declared move constructors.
Definition: ASTContext.h:2440
CanQualType OCLImage2dArrayMSAATy
Definition: ASTContext.h:903
QualType getUnqualifiedObjCPointerType(QualType type) const
getUnqualifiedObjCPointerType - Returns version of Objective-C pointer type with lifetime qualifier r...
Definition: ASTContext.h:1708
Defines an enumeration for C++ overloaded operators.
overridden_cxx_method_iterator overridden_methods_begin(const CXXMethodDecl *Method) const
static ImportDecl * getNextLocalImport(ImportDecl *Import)
Definition: ASTContext.h:841
void setObjCIdRedefinitionType(QualType RedefType)
Set the user-written type that redefines id.
Definition: ASTContext.h:1412
UsingShadowDecl * getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst)
An allocator for Storage objects, which uses a small cache to objects, used to reduce malloc()/free()...
CanQualType ShortTy
Definition: ASTContext.h:889
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
DynTypedNodeList(const DynTypedNode &N)
Definition: ASTContext.h:486
QualType getObjCSuperType() const
Returns the C struct type for objc_super.
Represents a C++ template name within the type system.
Definition: TemplateName.h:175
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
MangleNumberingContext * createMangleNumberingContext() const
TypeSourceInfo * getTemplateSpecializationTypeInfo(TemplateName T, SourceLocation TLoc, const TemplateArgumentListInfo &Args, QualType Canon=QualType()) const
TemplateOrSpecializationInfo getTemplateOrSpecializationInfo(const VarDecl *Var)
void setObjCImplementation(ObjCInterfaceDecl *IFaceD, ObjCImplementationDecl *ImplD)
Set the implementation of ObjCInterfaceDecl.
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
CanQualType UnsignedInt128Ty
Definition: ASTContext.h:891
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
Definition: Type.h:518
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
QualType getFILEType() const
Retrieve the C FILE type.
Definition: ASTContext.h:1481
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
CanQualType OCLImage2dMSAATy
Definition: ASTContext.h:903
PartialDiagnostic::StorageAllocator & getDiagAllocator()
Definition: ASTContext.h:576
Qualifiers Quals
The local qualifiers.
Definition: Type.h:523
CanQualType OCLImage2dArrayDepthTy
Definition: ASTContext.h:903
QualType getObjCIdType() const
Represents the Objective-CC id type.
Definition: ASTContext.h:1593
QualType withFastQualifiers(unsigned TQs) const
Definition: Type.h:784
Represents a GCC generic vector type.
Definition: Type.h:2724
NamedDecl * getInstantiatedFromUsingDecl(UsingDecl *Inst)
If the given using decl Inst is an instantiation of a (possibly unresolved) using decl from a templat...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
void addDeclaratorForUnnamedTagDecl(TagDecl *TD, DeclaratorDecl *DD)
QualType getSubstTemplateTypeParmPackType(const TemplateTypeParmType *Replaced, const TemplateArgument &ArgPack)
Retrieve a.
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
Definition: Type.h:3988
Implements C++ ABI-specific semantic analysis functions.
Definition: CXXABI.h:30
void deduplicateMergedDefinitonsFor(NamedDecl *ND)
Clean up the merged definition list.
Definition: ASTContext.cpp:893
bool isObjCClassType(QualType T) const
Definition: ASTContext.h:2221
void CollectInheritedProtocols(const Decl *CDecl, llvm::SmallPtrSet< ObjCProtocolDecl *, 8 > &Protocols)
CollectInheritedProtocols - Collect all protocols in current class and those inherited by it...
BuiltinTemplateDecl * getMakeIntegerSeqDecl() const
Definition: ASTContext.cpp:924
QualType getCVRQualifiedType(QualType T, unsigned CVR) const
Return a type with additional const, volatile, or restrict qualifiers.
Definition: ASTContext.h:1668
The result type of a method or function.
bool ObjCQualifiedClassTypesAreCompatible(QualType LHS, QualType RHS)
ObjCQualifiedClassTypesAreCompatible - compare Class<pr,...> and Class<pr1, ...>. ...
IdentifierInfo * getNSObjectName()
Retrieve the identifier 'NSObject'.
Definition: ASTContext.h:1444
bool getObjCEncodingForFunctionDecl(const FunctionDecl *Decl, std::string &S)
Emit the encoded type for the function Decl into S.
QualType getObjCConstantStringInterface() const
Definition: ASTContext.h:1391
void setOriginalDecl(const Decl *Orig)
Definition: ASTContext.h:659
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:228
QualType getWideCharType() const
Return the type of wide characters.
Definition: ASTContext.h:1341
CanQualType SignedCharTy
Definition: ASTContext.h:889
const clang::PrintingPolicy & getPrintingPolicy() const
Definition: ASTContext.h:545
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateDecl *Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
Decl * VaListTagDecl
Definition: ASTContext.h:916
bool hasObjCLifetime() const
Definition: Type.h:289
IdentifierInfo * getNSCopyingName()
Retrieve the identifier 'NSCopying'.
Definition: ASTContext.h:1453
This class provides information about commands that can be used in comments.
uint64_t getFieldOffset(const ValueDecl *FD) const
Get the offset of a FieldDecl or IndirectFieldDecl, in bits.
QualType getPackExpansionType(QualType Pattern, Optional< unsigned > NumExpansions)
QualType getFunctionNoProtoType(QualType ResultTy) const
Definition: ASTContext.h:1181
Abstract interface for external sources of AST nodes.
SourceLocation PragmaSectionLocation
Definition: ASTContext.h:2556
llvm::SmallVector< ast_type_traits::DynTypedNode, 2 > ParentVector
Contains parents of a node.
Definition: ASTContext.h:459
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
CanQualType OverloadTy
Definition: ASTContext.h:896
There is no lifetime qualification on this type.
Definition: Type.h:133
static unsigned NumImplicitDestructorsDeclared
The number of implicitly-declared destructors for which declarations were built.
Definition: ASTContext.h:2465
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
Definition: ASTContext.h:1814
int getIntegerTypeOrder(QualType LHS, QualType RHS) const
Return the highest ranked integer type, see C99 6.3.1.8p1.
TypeInfo getTypeInfo(const Type *T) const
Get the size and alignment of the specified complete type in bits.
#define false
Definition: stdbool.h:33
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
CanQualType BuiltinFnTy
Definition: ASTContext.h:897
This declaration does not have an attached comment, and we have searched the redeclaration chain...
Definition: ASTContext.h:636
The "struct" keyword.
Definition: Type.h:4176
SelectorTable & Selectors
Definition: ASTContext.h:452
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
bool QIdProtocolsAdoptObjCObjectProtocols(QualType QT, ObjCInterfaceDecl *IDecl)
QIdProtocolsAdoptObjCObjectProtocols - Checks that protocols in QT's qualified-id protocol list adopt...
Expr * getBlockVarCopyInits(const VarDecl *VD)
Get the copy initialization expression of the VarDecl VD, or NULL if none exists. ...
void AddDeallocation(void(*Callback)(void *), void *Data)
Add a deallocation callback that will be invoked when the ASTContext is destroyed.
Definition: ASTContext.cpp:813
ExternCContextDecl * getExternCContextDecl() const
Definition: ASTContext.cpp:906
Encodes a location in the source.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
Definition: ASTContext.h:932
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition: Type.h:5089
bool hasSameTemplateName(TemplateName X, TemplateName Y)
Determine whether the given template names refer to the same template.
CanQualType Int128Ty
Definition: ASTContext.h:889
const ObjCMethodDecl * getObjCMethodRedeclaration(const ObjCMethodDecl *MD) const
Get the duplicate declaration of a ObjCMethod in the same interface, or null if none exists...
RawComment * getRawCommentForDeclNoCache(const Decl *D) const
Return the documentation comment attached to a given declaration, without looking into cache...
Definition: ASTContext.cpp:64
A structure for storing an already-substituted template template parameter pack.
Definition: TemplateName.h:118
CharUnits getObjCEncodingTypeSize(QualType T) const
Return the size of type T for Objective-C encoding purpose, in characters.
static unsigned NumImplicitCopyAssignmentOperatorsDeclared
The number of implicitly-declared copy assignment operators for which declarations were built...
Definition: ASTContext.h:2451
Kind getKind() const LLVM_READONLY
Definition: ASTContext.h:639
void getLegacyIntegralTypeEncoding(QualType &t) const
getLegacyIntegralTypeEncoding - Another legacy compatibility encoding: 32-bit longs are encoded as 'l...
TagDecl - Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:2644
TemplateName getDependentTemplateName(NestedNameSpecifier *NNS, const IdentifierInfo *Name) const
Retrieve the template name that represents a dependent template name such as MetaFun::template apply...
IdentifierInfo * getMakeIntegerSeqName() const
Definition: ASTContext.h:1461
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a dependently-sized array of the specified element type...
CanQualType getPointerType(CanQualType T) const
Definition: ASTContext.h:1051
QualType withConst() const
Definition: Type.h:741
QualType getConstType(QualType T) const
Return the uniqued reference to the type for a const qualified type.
Definition: ASTContext.h:1023
MangleContext - Context for tracking state which persists across multiple calls to the C++ name mangl...
Definition: Mangle.h:41
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1701
TypedefNameDecl * getTypedefNameForUnnamedTagDecl(const TagDecl *TD)
CanQualType getCanonicalParamType(QualType T) const
Return the canonical parameter type corresponding to the specific potentially non-canonical one...
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
QualType getQualifiedType(QualType T, Qualifiers Qs) const
Return a type with additional qualifiers.
Definition: ASTContext.h:1678
CanQualType FloatTy
Definition: ASTContext.h:892
QualType getIncompleteArrayType(QualType EltTy, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a unique reference to the type for an incomplete array of the specified element type...
QualType getObjCSelRedefinitionType() const
Retrieve the type that 'SEL' has been defined to, which may be different from the built-in 'SEL' if '...
Definition: ASTContext.h:1431
const ConstantArrayType * getAsConstantArrayType(QualType T) const
Definition: ASTContext.h:2094
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
Definition: Type.h:4095
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:1931
BuiltinTemplateKind
Kinds of BuiltinTemplateDecl.
Definition: Builtins.h:214
QualType getObjCGCQualType(QualType T, Qualifiers::GC gcAttr) const
Return the uniqued reference to the type for an Objective-C gc-qualified type.
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load, __atomic_store, and __atomic_compare_exchange_*, for the similarly-named C++11 instructions, and __c11 variants for <stdatomic.h>.
Definition: Expr.h:4817
CanQualType VoidTy
Definition: ASTContext.h:881
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:2416
bool canBindObjCObjectType(QualType To, QualType From)
We have found a comment attached to this particular declaration.
Definition: ASTContext.h:626
void InitBuiltinTypes(const TargetInfo &Target, const TargetInfo *AuxTarget=nullptr)
Initialize built-in types.
Definition: ASTContext.cpp:983
SourceLocation getBegin() const
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent) const
C++11 deduced auto type.
bool typesAreBlockPointerCompatible(QualType, QualType)
FunctionDecl * getcudaConfigureCallDecl()
Definition: ASTContext.h:1093
TypedefDecl * getInt128Decl() const
Retrieve the declaration for the 128-bit signed integer type.
Definition: ASTContext.cpp:957
FunctionDecl * getClassScopeSpecializationPattern(const FunctionDecl *FD)
QualType getRealTypeForBitwidth(unsigned DestWidth) const
getRealTypeForBitwidth - sets floating point QualTy according to specified bitwidth.
QualType AutoDeductTy
Definition: ASTContext.h:911
TypeInfo getTypeInfo(QualType T) const
Definition: ASTContext.h:1787
void setObjCSuperType(QualType ST)
Definition: ASTContext.h:1378
llvm::DenseMap< const Decl *, RawCommentAndCacheFlags > RedeclComments
Mapping from declarations to comments attached to any redeclaration.
Definition: ASTContext.h:673
static DynTypedNode create(const T &Node)
Creates a DynTypedNode from Node.
__SIZE_TYPE__ size_t
Definition: stddef.h:62
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition: Decl.h:3658
unsigned getManglingNumber(const NamedDecl *ND) const
QualType getObjCInstanceType()
Retrieve the Objective-C "instancetype" type, if already known; otherwise, returns a NULL type;...
Definition: ASTContext.h:1469
void getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD, const Decl *Container, std::string &S) const
getObjCEncodingForPropertyDecl - Return the encoded type for this method declaration.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
const SourceManager & getSourceManager() const
Definition: ASTContext.h:554
QualType getObjCSelType() const
Retrieve the type that corresponds to the predefined Objective-C 'SEL' type.
Definition: ASTContext.h:1603
CanQualType UnsignedShortTy
Definition: ASTContext.h:890
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:2526
ast_type_traits::DynTypedNode Node
CanQualType CharTy
Definition: ASTContext.h:883
bool propertyTypesAreCompatible(QualType, QualType)
Represents a template argument.
Definition: TemplateBase.h:40
TypedefDecl * buildImplicitTypedef(QualType T, StringRef Name) const
Create a new implicit TU-level typedef declaration.
Definition: ASTContext.cpp:947
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
TagTypeKind
The kind of a tag type.
Definition: Type.h:4174
TemplateName getSubstTemplateTemplateParmPack(TemplateTemplateParmDecl *Param, const TemplateArgument &ArgPack) const
CanQualType ObjCBuiltinIdTy
Definition: ASTContext.h:899
SectionInfo(DeclaratorDecl *Decl, SourceLocation PragmaSectionLocation, int SectionFlags)
Definition: ASTContext.h:2559
QualType getCanonicalTemplateSpecializationType(TemplateName T, const TemplateArgument *Args, unsigned NumArgs) const
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
A qualifier set is used to build a set of qualifiers.
Definition: Type.h:5055
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1121
CanQualType NullPtrTy
Definition: ASTContext.h:895
TypedefDecl * getBOOLDecl() const
Retrieve declaration of 'BOOL' typedef.
Definition: ASTContext.h:1624
unsigned getTargetAddressSpace(Qualifiers Q) const
Definition: ASTContext.h:2184
bool isSentinelNullExpr(const Expr *E)
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:331
CanQualType DoubleComplexTy
Definition: ASTContext.h:894
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:22
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Definition: ASTMatchers.h:1723
void addCopyConstructorForExceptionObject(CXXRecordDecl *RD, CXXConstructorDecl *CD)
comments::FullComment * getCommentForDecl(const Decl *D, const Preprocessor *PP) const
Return parsed documentation comment attached to a given declaration.
Definition: ASTContext.cpp:441
TemplateName getCanonicalTemplateName(TemplateName Name) const
Retrieves the "canonical" template name that refers to a given template.
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:311
CanQualType UnsignedLongLongTy
Definition: ASTContext.h:891
QualType getEnumType(const EnumDecl *Decl) const
const TargetInfo * getAuxTargetInfo() const
Definition: ASTContext.h:581
QualType getExceptionObjectType(QualType T) const
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getObjCProtoType() const
Retrieve the type of the Objective-C Protocol class.
Definition: ASTContext.h:1639
void setASTMutationListener(ASTMutationListener *Listener)
Attach an AST mutation listener to the AST context.
Definition: ASTContext.h:941
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
Definition: Type.h:5062
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
MangleNumberingContext & getManglingNumberContext(const DeclContext *DC)
Retrieve the context for computing mangling numbers in the given DeclContext.
QualType getTemplateTypeParmType(unsigned Depth, unsigned Index, bool ParameterPack, TemplateTypeParmDecl *ParmDecl=nullptr) const
Retrieve the template type parameter type for a template parameter or parameter pack with the given d...
EnumDecl - Represents an enum.
Definition: Decl.h:2930
detail::InMemoryDirectory::const_iterator E
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
bool canAssignObjCInterfacesInBlockPointer(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT, bool BlockReturnType)
canAssignObjCInterfacesInBlockPointer - This routine is specifically written for providing type-safet...
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Definition: Specifiers.h:138
QualType AutoRRefDeductTy
Definition: ASTContext.h:912
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Definition: ASTContext.h:1946
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
QualType getCorrespondingUnsignedType(QualType T) const
unsigned Map[Count]
The type of a lookup table which maps from language-specific address spaces to target-specific ones...
Definition: AddressSpaces.h:45
bool areComparableObjCPointerTypes(QualType LHS, QualType RHS)
QualType getBuiltinVaListType() const
Retrieve the type of the __builtin_va_list type.
Definition: ASTContext.h:1648
static unsigned NumImplicitCopyAssignmentOperators
The number of implicitly-declared copy assignment operators.
Definition: ASTContext.h:2447
const VariableArrayType * getAsVariableArrayType(QualType T) const
Definition: ASTContext.h:2097
GVALinkage GetGVALinkageForVariable(const VarDecl *VD)
A dynamically typed AST node container.
const Decl * getOriginalDecl() const LLVM_READONLY
Definition: ASTContext.h:655
QualType getDependentSizedExtVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc) const
Represents a pointer to an Objective C object.
Definition: Type.h:4821
QualType getBuiltinMSVaListType() const
Retrieve the type of the __builtin_ms_va_list type.
Definition: ASTContext.h:1662
CanQualType ObjCBuiltinBoolTy
Definition: ASTContext.h:900
const RawComment * getRawCommentForAnyRedecl(const Decl *D, const Decl **OriginalDecl=nullptr) const
Return the documentation comment attached to a given declaration.
Definition: ASTContext.cpp:333
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2220
unsigned getAlignOfGlobalVar(QualType T) const
Return the alignment in bits that should be given to a global variable with type T.
BuiltinTemplateDecl * buildBuiltinTemplateDecl(BuiltinTemplateKind BTK, const IdentifierInfo *II) const
Definition: ASTContext.cpp:914
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
bool isObjCNSObjectType() const
Definition: Type.cpp:3694
CanQualType UnknownAnyTy
Definition: ASTContext.h:896
comments::FullComment * cloneFullComment(comments::FullComment *FC, const Decl *D) const
Definition: ASTContext.cpp:421
QualType getCanonicalType() const
Definition: Type.h:5128
CanQualType UnsignedLongTy
Definition: ASTContext.h:890
bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec)
Return true if the given vector types are of the same unqualified type or if they are equivalent to t...
Selector getSelector(unsigned NumArgs, IdentifierInfo **IIV)
Can create any sort of selector.
unsigned getTargetAddressSpace(unsigned AS) const
Definition: ASTContext.h:2188
CanQualType DependentTy
Definition: ASTContext.h:896
CanQualType WCharTy
Definition: ASTContext.h:884
void setNonKeyFunction(const CXXMethodDecl *method)
Observe that the given method cannot be a key function.
CanQualType ObjCBuiltinClassTy
Definition: ASTContext.h:899
DeclaratorDecl * getDeclaratorForUnnamedTagDecl(const TagDecl *TD)
QualType getQualifiedType(const Type *T, Qualifiers Qs) const
Return a type with additional qualifiers.
Definition: ASTContext.h:1687
CanQualType BoundMemberTy
Definition: ASTContext.h:896
unsigned getAddressSpace() const
Definition: Type.h:316
void addComment(const RawComment &RC)
Definition: ASTContext.h:688
CanQualType OCLImage2dDepthTy
Definition: ASTContext.h:902
uint64_t getCharWidth() const
Return the size of the character type, in bits.
Definition: ASTContext.h:1797
llvm::DenseMap< const Decl *, comments::FullComment * > ParsedComments
Mapping from declarations to parsed comments attached to any redeclaration.
Definition: ASTContext.h:677
QualType getObjCIdRedefinitionType() const
Retrieve the type that id has been defined to, which may be different from the built-in id if id has ...
Definition: ASTContext.h:1405
import_range local_imports() const
Definition: ASTContext.h:846
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
void setBlockVarCopyInits(VarDecl *VD, Expr *Init)
Set the copy inialization expression of a block var decl.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
Definition: APValue.h:38
bool getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl, std::string &S, bool Extended=false) const
Emit the encoded type for the method declaration Decl into S.
ASTMutationListener * getASTMutationListener() const
Retrieve a pointer to the AST mutation listener associated with this AST context, if any...
Definition: ASTContext.h:947
const Type * getCanonicalType(const Type *T) const
Definition: ASTContext.h:1950
SourceManager & getSourceManager()
Definition: ASTContext.h:553
TypeDecl * getFloat128StubType() const
Retrieve the declaration for a 128-bit float stub type.
Definition: ASTContext.cpp:969
void mergeDefinitionIntoModule(NamedDecl *ND, Module *M, bool NotifyListeners=true)
Note that the definition ND has been merged into module M, and should be visible whenever M is visibl...
Definition: ASTContext.cpp:881
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
Definition: SemaDecl.cpp:11761
QualType getTypedefType(const TypedefNameDecl *Decl, QualType Canon=QualType()) const
Return the unique reference to the type for the specified typedef-name decl.
void setObjCNSStringType(QualType T)
Definition: ASTContext.h:1399
QualType getTypeOfExprType(Expr *e) const
GCC extension.
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a variable array of the specified element type...
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Definition: Type.h:5169
CanQualType getDecayedType(CanQualType T) const
Definition: ASTContext.h:1067
const CXXMethodDecl * getCurrentKeyFunction(const CXXRecordDecl *RD)
Get our current best idea for the key function of the given record decl, or NULL if there isn't one...
Represents a C++ struct/union/class.
Definition: DeclCXX.h:285
bool isObjCObjectPointerType() const
Definition: Type.h:5377
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
Definition: DeclBase.h:186
Represents a C array with an unspecified size.
Definition: Type.h:2530
VTableContextBase * getVTableContext()
Missing a type from <stdio.h>
Definition: ASTContext.h:1738
CanQualType OCLImage1dArrayTy
Definition: ASTContext.h:901
bool operator!=(CanQual< T > x, CanQual< U > y)
void * Allocate(size_t Size, unsigned Align=8) const
Definition: ASTContext.h:560
CallingConv getDefaultCallingConvention(bool isVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current target.
Provides information a specialization of a member of a class template, which may be a member function...
Definition: DeclTemplate.h:492
CanQualType Char16Ty
Definition: ASTContext.h:887
void DumpRecordLayout(const RecordDecl *RD, raw_ostream &OS, bool Simple=false) const
size_t getASTAllocatedMemory() const
Return the total amount of physical memory allocated for representing AST nodes and type information...
Definition: ASTContext.h:570
bool isObjCSelType(QualType T) const
Definition: ASTContext.h:2224
size_t getSideTableAllocatedMemory() const
Return the total memory used for various side tables.
We searched for a comment attached to the particular declaration, but didn't find any...
Definition: ASTContext.h:621
static unsigned NumImplicitCopyConstructorsDeclared
The number of implicitly-declared copy constructors for which declarations were built.
Definition: ASTContext.h:2437
Builtin::Context & BuiltinInfo
Definition: ASTContext.h:453
llvm::APSInt MakeIntValue(uint64_t Value, QualType Type) const
Make an APSInt of the appropriate width and signedness for the given Value and integer Type...
Definition: ASTContext.h:2285
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorType::VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
Writes an AST file containing the contents of a translation unit.
Definition: ASTWriter.h:84
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
Definition: CanonicalType.h:70
A SourceLocation and its associated SourceManager.
Defines the clang::VersionTuple class, which represents a version in the form major[.minor[.subminor]].
static Qualifiers fromCVRMask(unsigned CVR)
Definition: Type.h:211
void adjustExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI, bool AsWritten=false)
Change the exception specification on a function once it is delay-parsed, instantiated, or computed.
CXXMethodVector::const_iterator overridden_cxx_method_iterator
Definition: ASTContext.h:812
void setObjCSelRedefinitionType(QualType RedefType)
Set the user-written type that redefines 'SEL'.
Definition: ASTContext.h:1439
uint64_t Width
Definition: ASTContext.h:81
CanQualType IntTy
Definition: ASTContext.h:889
TranslationUnitDecl - The top declaration context.
Definition: Decl.h:79
unsigned getTargetAddressSpace(QualType T) const
Definition: ASTContext.h:2180
QualType getDecltypeType(Expr *e, QualType UnderlyingType) const
C++11 decltype.
QualType getjmp_bufType() const
Retrieve the C jmp_buf type.
Definition: ASTContext.h:1493
QualType getUIntPtrType() const
Return a type compatible with "uintptr_t" (C99 7.18.1.4), as defined by the target.
GVALinkage
A more specific kind of linkage than enum Linkage.
Definition: Linkage.h:64
A lazy value (of type T) that is within an AST node of type Owner, where the value might change in la...
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
uint64_t getConstantArrayElementCount(const ConstantArrayType *CA) const
Return number of constant array elements.
QualType mergeFunctionParameterTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false)
mergeFunctionParameterTypes - merge two types which appear as function parameter types ...
Expr * getDefaultArgExprForConstructor(const CXXConstructorDecl *CD, unsigned ParmIdx)
const ObjCInterfaceDecl * getObjContainingInterface(const NamedDecl *ND) const
Returns the Objective-C interface that ND belongs to if it is an Objective-C method/property/ivar etc...
TypedefDecl * getObjCSelDecl() const
Retrieve the typedef corresponding to the predefined 'SEL' type in Objective-C.
bool isObjCIdType(QualType T) const
Definition: ASTContext.h:2218
TypedefDecl * getBuiltinMSVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_ms_va_list type...
Qualifiers::GC getObjCGCAttrKind(QualType Ty) const
Return one of the GCNone, Weak or Strong Objective-C garbage collection attributes.
#define true
Definition: stdbool.h:32
int64_t toBits(CharUnits CharSize) const
Convert a size in characters to a size in bits.
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
A trivial tuple used to represent a source range.
NamedDecl - This represents a decl with a name.
Definition: Decl.h:145
void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl)
Set the type for the C sigjmp_buf type.
Definition: ASTContext.h:1500
void setFILEDecl(TypeDecl *FILEDecl)
Set the type for the C FILE type.
Definition: ASTContext.h:1478
QualType getSignedWCharType() const
Return the type of "signed wchar_t".
TypeInfo(uint64_t Width, unsigned Align, bool AlignIsRequired)
Definition: ASTContext.h:85
bool hasSameNullabilityTypeQualifier(QualType SubT, QualType SuperT, bool IsParam) const
Definition: ASTContext.h:1992
Represents a C array with a specified size that is not an integer-constant-expression.
Definition: Type.h:2575
CanQualType BoolTy
Definition: ASTContext.h:882
const ASTRecordLayout & getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D) const
Get or compute information about the layout of the specified Objective-C interface.
void addOverriddenMethod(const CXXMethodDecl *Method, const CXXMethodDecl *Overridden)
Note that the given C++ Method overrides the given Overridden method.
bool DeclMustBeEmitted(const Decl *D)
Determines if the decl can be CodeGen'ed or deserialized from PCH lazily, only when used; this is onl...
const CXXConstructorDecl * getCopyConstructorForExceptionObject(CXXRecordDecl *RD)
llvm::PointerUnion< T, LazyData * > ValueType
bool ObjCQualifiedIdTypesAreCompatible(QualType LHS, QualType RHS, bool ForCompare)
ObjCQualifiedIdTypesAreCompatible - We know that one of lhs/rhs is an ObjCQualifiedIDType.
llvm::DenseMap< const void *, llvm::PointerUnion4< const Decl *, const Stmt *, ast_type_traits::DynTypedNode *, ParentVector * > > ParentMapPointers
Maps from a node to its parents.
Definition: ASTContext.h:467
CharUnits getAlignOfGlobalVarInChars(QualType T) const
Return the alignment in characters that should be given to a global variable with type T...
CanQualType DoubleTy
Definition: ASTContext.h:892
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:642
static bool isObjCNSObjectType(QualType Ty)
Return true if this is an NSObject object with its NSObject attribute set.
Definition: ASTContext.h:1773
void addedLocalImportDecl(ImportDecl *Import)
Notify the AST context that a new import declaration has been parsed or implicitly created within thi...
QualType getSubstTemplateTypeParmType(const TemplateTypeParmType *Replaced, QualType Replacement) const
Retrieve a substitution-result type.
Missing a type from <setjmp.h>
Definition: ASTContext.h:1739
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
Definition: Type.cpp:3476
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
Definition: DeclObjC.h:2139
Represents the canonical version of C arrays with a specified constant size.
Definition: Type.h:2480
This class handles loading and caching of source files into memory.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
llvm::DenseMap< ast_type_traits::DynTypedNode, llvm::PointerUnion4< const Decl *, const Stmt *, ast_type_traits::DynTypedNode *, ParentVector * > > ParentMapOtherNodes
Parent map for nodes without pointer identity.
Definition: ASTContext.h:475
QualType getBOOLType() const
type of 'BOOL' type.
Definition: ASTContext.h:1634
A class which abstracts out some details necessary for making a call.
Definition: Type.h:2872
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals)
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals...
bool BlockRequiresCopying(QualType Ty, const VarDecl *D)
Returns true iff we need copy/dispose helpers for the given type.
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
Definition: DeclCXX.h:2766
A full comment attached to a declaration, contains block content.
Definition: Comment.h:1097
APValue * getMaterializedTemporaryValue(const MaterializeTemporaryExpr *E, bool MayCreate)
Get the storage for the constant value of a materialized temporary of static storage duration...
CanQualType OCLClkEventTy
Definition: ASTContext.h:906
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:96
CanQualType UnsignedIntTy
Definition: ASTContext.h:890
QualType getProcessIDType() const
Return the unique type for "pid_t" defined in <sys/types.h>.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Definition: Type.h:5116
static unsigned NumImplicitDestructors
The number of implicitly-declared destructors.
Definition: ASTContext.h:2461
QualType getCFConstantStringType() const
Return the C structure type used to represent constant CFStrings.