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