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