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, LangOpts.CommentOpts, 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  /// constructing 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  /// Return whether a declaration to a builtin is allowed to be
1885  /// overloaded/redeclared.
1886  bool canBuiltinBeRedeclared(const FunctionDecl *) const;
1887 
1888  /// \brief Return a type with additional \c const, \c volatile, or
1889  /// \c restrict qualifiers.
1890  QualType getCVRQualifiedType(QualType T, unsigned CVR) const {
1891  return getQualifiedType(T, Qualifiers::fromCVRMask(CVR));
1892  }
1893 
1894  /// \brief Un-split a SplitQualType.
1896  return getQualifiedType(split.Ty, split.Quals);
1897  }
1898 
1899  /// \brief Return a type with additional qualifiers.
1901  if (!Qs.hasNonFastQualifiers())
1902  return T.withFastQualifiers(Qs.getFastQualifiers());
1903  QualifierCollector Qc(Qs);
1904  const Type *Ptr = Qc.strip(T);
1905  return getExtQualType(Ptr, Qc);
1906  }
1907 
1908  /// \brief Return a type with additional qualifiers.
1910  if (!Qs.hasNonFastQualifiers())
1911  return QualType(T, Qs.getFastQualifiers());
1912  return getExtQualType(T, Qs);
1913  }
1914 
1915  /// \brief Return a type with the given lifetime qualifier.
1916  ///
1917  /// \pre Neither type.ObjCLifetime() nor \p lifetime may be \c OCL_None.
1919  Qualifiers::ObjCLifetime lifetime) {
1920  assert(type.getObjCLifetime() == Qualifiers::OCL_None);
1921  assert(lifetime != Qualifiers::OCL_None);
1922 
1923  Qualifiers qs;
1924  qs.addObjCLifetime(lifetime);
1925  return getQualifiedType(type, qs);
1926  }
1927 
1928  /// getUnqualifiedObjCPointerType - Returns version of
1929  /// Objective-C pointer type with lifetime qualifier removed.
1931  if (!type.getTypePtr()->isObjCObjectPointerType() ||
1932  !type.getQualifiers().hasObjCLifetime())
1933  return type;
1934  Qualifiers Qs = type.getQualifiers();
1935  Qs.removeObjCLifetime();
1936  return getQualifiedType(type.getUnqualifiedType(), Qs);
1937  }
1938 
1939  DeclarationNameInfo getNameForTemplate(TemplateName Name,
1940  SourceLocation NameLoc) const;
1941 
1942  TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin,
1943  UnresolvedSetIterator End) const;
1944 
1945  TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS,
1946  bool TemplateKeyword,
1947  TemplateDecl *Template) const;
1948 
1949  TemplateName getDependentTemplateName(NestedNameSpecifier *NNS,
1950  const IdentifierInfo *Name) const;
1951  TemplateName getDependentTemplateName(NestedNameSpecifier *NNS,
1952  OverloadedOperatorKind Operator) const;
1953  TemplateName getSubstTemplateTemplateParm(TemplateTemplateParmDecl *param,
1954  TemplateName replacement) const;
1955  TemplateName getSubstTemplateTemplateParmPack(TemplateTemplateParmDecl *Param,
1956  const TemplateArgument &ArgPack) const;
1957 
1959  /// No error
1961 
1962  /// Missing a type from <stdio.h>
1964 
1965  /// Missing a type from <setjmp.h>
1967 
1968  /// Missing a type from <ucontext.h>
1969  GE_Missing_ucontext
1970  };
1971 
1972  /// \brief Return the type for the specified builtin.
1973  ///
1974  /// If \p IntegerConstantArgs is non-null, it is filled in with a bitmask of
1975  /// arguments to the builtin that are required to be integer constant
1976  /// expressions.
1977  QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error,
1978  unsigned *IntegerConstantArgs = nullptr) const;
1979 
1980 private:
1981  CanQualType getFromTargetType(unsigned Type) const;
1982  TypeInfo getTypeInfoImpl(const Type *T) const;
1983 
1984  //===--------------------------------------------------------------------===//
1985  // Type Predicates.
1986  //===--------------------------------------------------------------------===//
1987 
1988 public:
1989  /// \brief Return one of the GCNone, Weak or Strong Objective-C garbage
1990  /// collection attributes.
1991  Qualifiers::GC getObjCGCAttrKind(QualType Ty) const;
1992 
1993  /// \brief Return true if the given vector types are of the same unqualified
1994  /// type or if they are equivalent to the same GCC vector type.
1995  ///
1996  /// \note This ignores whether they are target-specific (AltiVec or Neon)
1997  /// types.
1998  bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec);
1999 
2000  /// \brief Return true if this is an \c NSObject object with its \c NSObject
2001  /// attribute set.
2002  static bool isObjCNSObjectType(QualType Ty) {
2003  return Ty->isObjCNSObjectType();
2004  }
2005 
2006  //===--------------------------------------------------------------------===//
2007  // Type Sizing and Analysis
2008  //===--------------------------------------------------------------------===//
2009 
2010  /// \brief Return the APFloat 'semantics' for the specified scalar floating
2011  /// point type.
2012  const llvm::fltSemantics &getFloatTypeSemantics(QualType T) const;
2013 
2014  /// \brief Get the size and alignment of the specified complete type in bits.
2015  TypeInfo getTypeInfo(const Type *T) const;
2017 
2018  /// \brief Get default simd alignment of the specified complete type in bits.
2019  unsigned getOpenMPDefaultSimdAlign(QualType T) const;
2020 
2021  /// \brief Return the size of the specified (complete) type \p T, in bits.
2022  uint64_t getTypeSize(QualType T) const { return getTypeInfo(T).Width; }
2023  uint64_t getTypeSize(const Type *T) const { return getTypeInfo(T).Width; }
2024 
2025  /// \brief Return the size of the character type, in bits.
2026  uint64_t getCharWidth() const {
2027  return getTypeSize(CharTy);
2028  }
2029 
2030  /// \brief Convert a size in bits to a size in characters.
2031  CharUnits toCharUnitsFromBits(int64_t BitSize) const;
2032 
2033  /// \brief Convert a size in characters to a size in bits.
2034  int64_t toBits(CharUnits CharSize) const;
2035 
2036  /// \brief Return the size of the specified (complete) type \p T, in
2037  /// characters.
2038  CharUnits getTypeSizeInChars(QualType T) const;
2039  CharUnits getTypeSizeInChars(const Type *T) const;
2040 
2041  /// \brief Return the ABI-specified alignment of a (complete) type \p T, in
2042  /// bits.
2043  unsigned getTypeAlign(QualType T) const { return getTypeInfo(T).Align; }
2044  unsigned getTypeAlign(const Type *T) const { return getTypeInfo(T).Align; }
2045 
2046  /// \brief Return the ABI-specified alignment of a type, in bits, or 0 if
2047  /// the type is incomplete and we cannot determine the alignment (for
2048  /// example, from alignment attributes).
2049  unsigned getTypeAlignIfKnown(QualType T) const;
2050 
2051  /// \brief Return the ABI-specified alignment of a (complete) type \p T, in
2052  /// characters.
2053  CharUnits getTypeAlignInChars(QualType T) const;
2054  CharUnits getTypeAlignInChars(const Type *T) const;
2055 
2056  // getTypeInfoDataSizeInChars - Return the size of a type, in chars. If the
2057  // type is a record, its data size is returned.
2058  std::pair<CharUnits, CharUnits> getTypeInfoDataSizeInChars(QualType T) const;
2059 
2060  std::pair<CharUnits, CharUnits> getTypeInfoInChars(const Type *T) const;
2061  std::pair<CharUnits, CharUnits> getTypeInfoInChars(QualType T) const;
2062 
2063  /// \brief Determine if the alignment the type has was required using an
2064  /// alignment attribute.
2065  bool isAlignmentRequired(const Type *T) const;
2066  bool isAlignmentRequired(QualType T) const;
2067 
2068  /// \brief Return the "preferred" alignment of the specified type \p T for
2069  /// the current target, in bits.
2070  ///
2071  /// This can be different than the ABI alignment in cases where it is
2072  /// beneficial for performance to overalign a data type.
2073  unsigned getPreferredTypeAlign(const Type *T) const;
2074 
2075  /// \brief Return the default alignment for __attribute__((aligned)) on
2076  /// this target, to be used if no alignment value is specified.
2077  unsigned getTargetDefaultAlignForAttributeAligned() const;
2078 
2079  /// \brief Return the alignment in bits that should be given to a
2080  /// global variable with type \p T.
2081  unsigned getAlignOfGlobalVar(QualType T) const;
2082 
2083  /// \brief Return the alignment in characters that should be given to a
2084  /// global variable with type \p T.
2085  CharUnits getAlignOfGlobalVarInChars(QualType T) const;
2086 
2087  /// \brief Return a conservative estimate of the alignment of the specified
2088  /// decl \p D.
2089  ///
2090  /// \pre \p D must not be a bitfield type, as bitfields do not have a valid
2091  /// alignment.
2092  ///
2093  /// If \p ForAlignof, references are treated like their underlying type
2094  /// and large arrays don't get any special treatment. If not \p ForAlignof
2095  /// it computes the value expected by CodeGen: references are treated like
2096  /// pointers and large arrays get extra alignment.
2097  CharUnits getDeclAlign(const Decl *D, bool ForAlignof = false) const;
2098 
2099  /// \brief Get or compute information about the layout of the specified
2100  /// record (struct/union/class) \p D, which indicates its size and field
2101  /// position information.
2102  const ASTRecordLayout &getASTRecordLayout(const RecordDecl *D) const;
2103 
2104  /// \brief Get or compute information about the layout of the specified
2105  /// Objective-C interface.
2106  const ASTRecordLayout &getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D)
2107  const;
2108 
2109  void DumpRecordLayout(const RecordDecl *RD, raw_ostream &OS,
2110  bool Simple = false) const;
2111 
2112  /// \brief Get or compute information about the layout of the specified
2113  /// Objective-C implementation.
2114  ///
2115  /// This may differ from the interface if synthesized ivars are present.
2116  const ASTRecordLayout &
2117  getASTObjCImplementationLayout(const ObjCImplementationDecl *D) const;
2118 
2119  /// \brief Get our current best idea for the key function of the
2120  /// given record decl, or nullptr if there isn't one.
2121  ///
2122  /// The key function is, according to the Itanium C++ ABI section 5.2.3:
2123  /// ...the first non-pure virtual function that is not inline at the
2124  /// point of class definition.
2125  ///
2126  /// Other ABIs use the same idea. However, the ARM C++ ABI ignores
2127  /// virtual functions that are defined 'inline', which means that
2128  /// the result of this computation can change.
2129  const CXXMethodDecl *getCurrentKeyFunction(const CXXRecordDecl *RD);
2130 
2131  /// \brief Observe that the given method cannot be a key function.
2132  /// Checks the key-function cache for the method's class and clears it
2133  /// if matches the given declaration.
2134  ///
2135  /// This is used in ABIs where out-of-line definitions marked
2136  /// inline are not considered to be key functions.
2137  ///
2138  /// \param method should be the declaration from the class definition
2139  void setNonKeyFunction(const CXXMethodDecl *method);
2140 
2141  /// Loading virtual member pointers using the virtual inheritance model
2142  /// always results in an adjustment using the vbtable even if the index is
2143  /// zero.
2144  ///
2145  /// This is usually OK because the first slot in the vbtable points
2146  /// backwards to the top of the MDC. However, the MDC might be reusing a
2147  /// vbptr from an nv-base. In this case, the first slot in the vbtable
2148  /// points to the start of the nv-base which introduced the vbptr and *not*
2149  /// the MDC. Modify the NonVirtualBaseAdjustment to account for this.
2150  CharUnits getOffsetOfBaseWithVBPtr(const CXXRecordDecl *RD) const;
2151 
2152  /// Get the offset of a FieldDecl or IndirectFieldDecl, in bits.
2153  uint64_t getFieldOffset(const ValueDecl *FD) const;
2154 
2155  /// Get the offset of an ObjCIvarDecl in bits.
2156  uint64_t lookupFieldBitOffset(const ObjCInterfaceDecl *OID,
2157  const ObjCImplementationDecl *ID,
2158  const ObjCIvarDecl *Ivar) const;
2159 
2160  bool isNearlyEmpty(const CXXRecordDecl *RD) const;
2161 
2162  VTableContextBase *getVTableContext();
2163 
2164  MangleContext *createMangleContext();
2165 
2166  void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass,
2168 
2169  unsigned CountNonClassIvars(const ObjCInterfaceDecl *OI) const;
2170  void CollectInheritedProtocols(const Decl *CDecl,
2171  llvm::SmallPtrSet<ObjCProtocolDecl*, 8> &Protocols);
2172 
2173  /// \brief Return true if the specified type has unique object representations
2174  /// according to (C++17 [meta.unary.prop]p9)
2175  bool hasUniqueObjectRepresentations(QualType Ty) const;
2176 
2177  //===--------------------------------------------------------------------===//
2178  // Type Operators
2179  //===--------------------------------------------------------------------===//
2180 
2181  /// \brief Return the canonical (structural) type corresponding to the
2182  /// specified potentially non-canonical type \p T.
2183  ///
2184  /// The non-canonical version of a type may have many "decorated" versions of
2185  /// types. Decorators can include typedefs, 'typeof' operators, etc. The
2186  /// returned type is guaranteed to be free of any of these, allowing two
2187  /// canonical types to be compared for exact equality with a simple pointer
2188  /// comparison.
2190  return CanQualType::CreateUnsafe(T.getCanonicalType());
2191  }
2192 
2193  const Type *getCanonicalType(const Type *T) const {
2194  return T->getCanonicalTypeInternal().getTypePtr();
2195  }
2196 
2197  /// \brief Return the canonical parameter type corresponding to the specific
2198  /// potentially non-canonical one.
2199  ///
2200  /// Qualifiers are stripped off, functions are turned into function
2201  /// pointers, and arrays decay one level into pointers.
2203 
2204  /// \brief Determine whether the given types \p T1 and \p T2 are equivalent.
2205  bool hasSameType(QualType T1, QualType T2) const {
2206  return getCanonicalType(T1) == getCanonicalType(T2);
2207  }
2208  bool hasSameType(const Type *T1, const Type *T2) const {
2209  return getCanonicalType(T1) == getCanonicalType(T2);
2210  }
2211 
2212  /// \brief Return this type as a completely-unqualified array type,
2213  /// capturing the qualifiers in \p Quals.
2214  ///
2215  /// This will remove the minimal amount of sugaring from the types, similar
2216  /// to the behavior of QualType::getUnqualifiedType().
2217  ///
2218  /// \param T is the qualified type, which may be an ArrayType
2219  ///
2220  /// \param Quals will receive the full set of qualifiers that were
2221  /// applied to the array.
2222  ///
2223  /// \returns if this is an array type, the completely unqualified array type
2224  /// that corresponds to it. Otherwise, returns T.getUnqualifiedType().
2225  QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals);
2226 
2227  /// \brief Determine whether the given types are equivalent after
2228  /// cvr-qualifiers have been removed.
2230  return getCanonicalType(T1).getTypePtr() ==
2231  getCanonicalType(T2).getTypePtr();
2232  }
2233 
2235  bool IsParam) const {
2236  auto SubTnullability = SubT->getNullability(*this);
2237  auto SuperTnullability = SuperT->getNullability(*this);
2238  if (SubTnullability.hasValue() == SuperTnullability.hasValue()) {
2239  // Neither has nullability; return true
2240  if (!SubTnullability)
2241  return true;
2242  // Both have nullability qualifier.
2243  if (*SubTnullability == *SuperTnullability ||
2244  *SubTnullability == NullabilityKind::Unspecified ||
2245  *SuperTnullability == NullabilityKind::Unspecified)
2246  return true;
2247 
2248  if (IsParam) {
2249  // Ok for the superclass method parameter to be "nonnull" and the subclass
2250  // method parameter to be "nullable"
2251  return (*SuperTnullability == NullabilityKind::NonNull &&
2252  *SubTnullability == NullabilityKind::Nullable);
2253  }
2254  else {
2255  // For the return type, it's okay for the superclass method to specify
2256  // "nullable" and the subclass method specify "nonnull"
2257  return (*SuperTnullability == NullabilityKind::Nullable &&
2258  *SubTnullability == NullabilityKind::NonNull);
2259  }
2260  }
2261  return true;
2262  }
2263 
2264  bool ObjCMethodsAreEqual(const ObjCMethodDecl *MethodDecl,
2265  const ObjCMethodDecl *MethodImp);
2266 
2267  bool UnwrapSimilarPointerTypes(QualType &T1, QualType &T2);
2268 
2269  /// \brief Retrieves the "canonical" nested name specifier for a
2270  /// given nested name specifier.
2271  ///
2272  /// The canonical nested name specifier is a nested name specifier
2273  /// that uniquely identifies a type or namespace within the type
2274  /// system. For example, given:
2275  ///
2276  /// \code
2277  /// namespace N {
2278  /// struct S {
2279  /// template<typename T> struct X { typename T* type; };
2280  /// };
2281  /// }
2282  ///
2283  /// template<typename T> struct Y {
2284  /// typename N::S::X<T>::type member;
2285  /// };
2286  /// \endcode
2287  ///
2288  /// Here, the nested-name-specifier for N::S::X<T>:: will be
2289  /// S::X<template-param-0-0>, since 'S' and 'X' are uniquely defined
2290  /// by declarations in the type system and the canonical type for
2291  /// the template type parameter 'T' is template-param-0-0.
2293  getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const;
2294 
2295  /// \brief Retrieves the default calling convention for the current target.
2296  CallingConv getDefaultCallingConvention(bool IsVariadic,
2297  bool IsCXXMethod) const;
2298 
2299  /// \brief Retrieves the "canonical" template name that refers to a
2300  /// given template.
2301  ///
2302  /// The canonical template name is the simplest expression that can
2303  /// be used to refer to a given template. For most templates, this
2304  /// expression is just the template declaration itself. For example,
2305  /// the template std::vector can be referred to via a variety of
2306  /// names---std::vector, \::std::vector, vector (if vector is in
2307  /// scope), etc.---but all of these names map down to the same
2308  /// TemplateDecl, which is used to form the canonical template name.
2309  ///
2310  /// Dependent template names are more interesting. Here, the
2311  /// template name could be something like T::template apply or
2312  /// std::allocator<T>::template rebind, where the nested name
2313  /// specifier itself is dependent. In this case, the canonical
2314  /// template name uses the shortest form of the dependent
2315  /// nested-name-specifier, which itself contains all canonical
2316  /// types, values, and templates.
2317  TemplateName getCanonicalTemplateName(TemplateName Name) const;
2318 
2319  /// \brief Determine whether the given template names refer to the same
2320  /// template.
2321  bool hasSameTemplateName(TemplateName X, TemplateName Y);
2322 
2323  /// \brief Retrieve the "canonical" template argument.
2324  ///
2325  /// The canonical template argument is the simplest template argument
2326  /// (which may be a type, value, expression, or declaration) that
2327  /// expresses the value of the argument.
2328  TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg)
2329  const;
2330 
2331  /// Type Query functions. If the type is an instance of the specified class,
2332  /// return the Type pointer for the underlying maximally pretty type. This
2333  /// is a member of ASTContext because this may need to do some amount of
2334  /// canonicalization, e.g. to move type qualifiers into the element type.
2335  const ArrayType *getAsArrayType(QualType T) const;
2337  return dyn_cast_or_null<ConstantArrayType>(getAsArrayType(T));
2338  }
2340  return dyn_cast_or_null<VariableArrayType>(getAsArrayType(T));
2341  }
2343  return dyn_cast_or_null<IncompleteArrayType>(getAsArrayType(T));
2344  }
2346  const {
2347  return dyn_cast_or_null<DependentSizedArrayType>(getAsArrayType(T));
2348  }
2349 
2350  /// \brief Return the innermost element type of an array type.
2351  ///
2352  /// For example, will return "int" for int[m][n]
2353  QualType getBaseElementType(const ArrayType *VAT) const;
2354 
2355  /// \brief Return the innermost element type of a type (which needn't
2356  /// actually be an array type).
2357  QualType getBaseElementType(QualType QT) const;
2358 
2359  /// \brief Return number of constant array elements.
2360  uint64_t getConstantArrayElementCount(const ConstantArrayType *CA) const;
2361 
2362  /// \brief Perform adjustment on the parameter type of a function.
2363  ///
2364  /// This routine adjusts the given parameter type @p T to the actual
2365  /// parameter type used by semantic analysis (C99 6.7.5.3p[7,8],
2366  /// C++ [dcl.fct]p3). The adjusted parameter type is returned.
2367  QualType getAdjustedParameterType(QualType T) const;
2368 
2369  /// \brief Retrieve the parameter type as adjusted for use in the signature
2370  /// of a function, decaying array and function types and removing top-level
2371  /// cv-qualifiers.
2372  QualType getSignatureParameterType(QualType T) const;
2373 
2374  QualType getExceptionObjectType(QualType T) const;
2375 
2376  /// \brief Return the properly qualified result of decaying the specified
2377  /// array type to a pointer.
2378  ///
2379  /// This operation is non-trivial when handling typedefs etc. The canonical
2380  /// type of \p T must be an array type, this returns a pointer to a properly
2381  /// qualified element of the array.
2382  ///
2383  /// See C99 6.7.5.3p7 and C99 6.3.2.1p3.
2384  QualType getArrayDecayedType(QualType T) const;
2385 
2386  /// \brief Return the type that \p PromotableType will promote to: C99
2387  /// 6.3.1.1p2, assuming that \p PromotableType is a promotable integer type.
2388  QualType getPromotedIntegerType(QualType PromotableType) const;
2389 
2390  /// \brief Recurses in pointer/array types until it finds an Objective-C
2391  /// retainable type and returns its ownership.
2392  Qualifiers::ObjCLifetime getInnerObjCOwnership(QualType T) const;
2393 
2394  /// \brief Whether this is a promotable bitfield reference according
2395  /// to C99 6.3.1.1p2, bullet 2 (and GCC extensions).
2396  ///
2397  /// \returns the type this bit-field will promote to, or NULL if no
2398  /// promotion occurs.
2399  QualType isPromotableBitField(Expr *E) const;
2400 
2401  /// \brief Return the highest ranked integer type, see C99 6.3.1.8p1.
2402  ///
2403  /// If \p LHS > \p RHS, returns 1. If \p LHS == \p RHS, returns 0. If
2404  /// \p LHS < \p RHS, return -1.
2405  int getIntegerTypeOrder(QualType LHS, QualType RHS) const;
2406 
2407  /// \brief Compare the rank of the two specified floating point types,
2408  /// ignoring the domain of the type (i.e. 'double' == '_Complex double').
2409  ///
2410  /// If \p LHS > \p RHS, returns 1. If \p LHS == \p RHS, returns 0. If
2411  /// \p LHS < \p RHS, return -1.
2412  int getFloatingTypeOrder(QualType LHS, QualType RHS) const;
2413 
2414  /// \brief Return a real floating point or a complex type (based on
2415  /// \p typeDomain/\p typeSize).
2416  ///
2417  /// \param typeDomain a real floating point or complex type.
2418  /// \param typeSize a real floating point or complex type.
2419  QualType getFloatingTypeOfSizeWithinDomain(QualType typeSize,
2420  QualType typeDomain) const;
2421 
2422  unsigned getTargetAddressSpace(QualType T) const {
2423  return getTargetAddressSpace(T.getQualifiers());
2424  }
2425 
2426  unsigned getTargetAddressSpace(Qualifiers Q) const {
2427  return getTargetAddressSpace(Q.getAddressSpace());
2428  }
2429 
2430  unsigned getTargetAddressSpace(LangAS AS) const;
2431 
2432  /// Get target-dependent integer value for null pointer which is used for
2433  /// constant folding.
2434  uint64_t getTargetNullPointerValue(QualType QT) const;
2435 
2437  return AddrSpaceMapMangling || isTargetAddressSpace(AS);
2438  }
2439 
2440 private:
2441  // Helper for integer ordering
2442  unsigned getIntegerRank(const Type *T) const;
2443 
2444 public:
2445  //===--------------------------------------------------------------------===//
2446  // Type Compatibility Predicates
2447  //===--------------------------------------------------------------------===//
2448 
2449  /// Compatibility predicates used to check assignment expressions.
2450  bool typesAreCompatible(QualType T1, QualType T2,
2451  bool CompareUnqualified = false); // C99 6.2.7p1
2452 
2453  bool propertyTypesAreCompatible(QualType, QualType);
2454  bool typesAreBlockPointerCompatible(QualType, QualType);
2455 
2456  bool isObjCIdType(QualType T) const {
2457  return T == getObjCIdType();
2458  }
2459 
2460  bool isObjCClassType(QualType T) const {
2461  return T == getObjCClassType();
2462  }
2463 
2464  bool isObjCSelType(QualType T) const {
2465  return T == getObjCSelType();
2466  }
2467 
2468  bool ObjCQualifiedIdTypesAreCompatible(QualType LHS, QualType RHS,
2469  bool ForCompare);
2470 
2471  bool ObjCQualifiedClassTypesAreCompatible(QualType LHS, QualType RHS);
2472 
2473  // Check the safety of assignment from LHS to RHS
2474  bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT,
2475  const ObjCObjectPointerType *RHSOPT);
2476  bool canAssignObjCInterfaces(const ObjCObjectType *LHS,
2477  const ObjCObjectType *RHS);
2478  bool canAssignObjCInterfacesInBlockPointer(
2479  const ObjCObjectPointerType *LHSOPT,
2480  const ObjCObjectPointerType *RHSOPT,
2481  bool BlockReturnType);
2482  bool areComparableObjCPointerTypes(QualType LHS, QualType RHS);
2483  QualType areCommonBaseCompatible(const ObjCObjectPointerType *LHSOPT,
2484  const ObjCObjectPointerType *RHSOPT);
2485  bool canBindObjCObjectType(QualType To, QualType From);
2486 
2487  // Functions for calculating composite types
2488  QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false,
2489  bool Unqualified = false, bool BlockReturnType = false);
2490  QualType mergeFunctionTypes(QualType, QualType, bool OfBlockPointer=false,
2491  bool Unqualified = false);
2492  QualType mergeFunctionParameterTypes(QualType, QualType,
2493  bool OfBlockPointer = false,
2494  bool Unqualified = false);
2495  QualType mergeTransparentUnionType(QualType, QualType,
2496  bool OfBlockPointer=false,
2497  bool Unqualified = false);
2498 
2499  QualType mergeObjCGCQualifiers(QualType, QualType);
2500 
2501  /// This function merges the ExtParameterInfo lists of two functions. It
2502  /// returns true if the lists are compatible. The merged list is returned in
2503  /// NewParamInfos.
2504  ///
2505  /// \param FirstFnType The type of the first function.
2506  ///
2507  /// \param SecondFnType The type of the second function.
2508  ///
2509  /// \param CanUseFirst This flag is set to true if the first function's
2510  /// ExtParameterInfo list can be used as the composite list of
2511  /// ExtParameterInfo.
2512  ///
2513  /// \param CanUseSecond This flag is set to true if the second function's
2514  /// ExtParameterInfo list can be used as the composite list of
2515  /// ExtParameterInfo.
2516  ///
2517  /// \param NewParamInfos The composite list of ExtParameterInfo. The list is
2518  /// empty if none of the flags are set.
2519  ///
2520  bool mergeExtParameterInfo(
2521  const FunctionProtoType *FirstFnType,
2522  const FunctionProtoType *SecondFnType,
2523  bool &CanUseFirst, bool &CanUseSecond,
2525 
2526  void ResetObjCLayout(const ObjCContainerDecl *CD);
2527 
2528  //===--------------------------------------------------------------------===//
2529  // Integer Predicates
2530  //===--------------------------------------------------------------------===//
2531 
2532  // The width of an integer, as defined in C99 6.2.6.2. This is the number
2533  // of bits in an integer type excluding any padding bits.
2534  unsigned getIntWidth(QualType T) const;
2535 
2536  // Per C99 6.2.5p6, for every signed integer type, there is a corresponding
2537  // unsigned integer type. This method takes a signed type, and returns the
2538  // corresponding unsigned integer type.
2539  QualType getCorrespondingUnsignedType(QualType T) const;
2540 
2541  //===--------------------------------------------------------------------===//
2542  // Integer Values
2543  //===--------------------------------------------------------------------===//
2544 
2545  /// \brief Make an APSInt of the appropriate width and signedness for the
2546  /// given \p Value and integer \p Type.
2547  llvm::APSInt MakeIntValue(uint64_t Value, QualType Type) const {
2548  // If Type is a signed integer type larger than 64 bits, we need to be sure
2549  // to sign extend Res appropriately.
2550  llvm::APSInt Res(64, !Type->isSignedIntegerOrEnumerationType());
2551  Res = Value;
2552  unsigned Width = getIntWidth(Type);
2553  if (Width != Res.getBitWidth())
2554  return Res.extOrTrunc(Width);
2555  return Res;
2556  }
2557 
2558  bool isSentinelNullExpr(const Expr *E);
2559 
2560  /// \brief Get the implementation of the ObjCInterfaceDecl \p D, or nullptr if
2561  /// none exists.
2562  ObjCImplementationDecl *getObjCImplementation(ObjCInterfaceDecl *D);
2563 
2564  /// \brief Get the implementation of the ObjCCategoryDecl \p D, or nullptr if
2565  /// none exists.
2566  ObjCCategoryImplDecl *getObjCImplementation(ObjCCategoryDecl *D);
2567 
2568  /// \brief Return true if there is at least one \@implementation in the TU.
2570  return !ObjCImpls.empty();
2571  }
2572 
2573  /// \brief Set the implementation of ObjCInterfaceDecl.
2574  void setObjCImplementation(ObjCInterfaceDecl *IFaceD,
2575  ObjCImplementationDecl *ImplD);
2576 
2577  /// \brief Set the implementation of ObjCCategoryDecl.
2578  void setObjCImplementation(ObjCCategoryDecl *CatD,
2579  ObjCCategoryImplDecl *ImplD);
2580 
2581  /// \brief Get the duplicate declaration of a ObjCMethod in the same
2582  /// interface, or null if none exists.
2583  const ObjCMethodDecl *
2584  getObjCMethodRedeclaration(const ObjCMethodDecl *MD) const;
2585 
2586  void setObjCMethodRedeclaration(const ObjCMethodDecl *MD,
2587  const ObjCMethodDecl *Redecl);
2588 
2589  /// \brief Returns the Objective-C interface that \p ND belongs to if it is
2590  /// an Objective-C method/property/ivar etc. that is part of an interface,
2591  /// otherwise returns null.
2592  const ObjCInterfaceDecl *getObjContainingInterface(const NamedDecl *ND) const;
2593 
2594  /// \brief Set the copy inialization expression of a block var decl.
2595  void setBlockVarCopyInits(VarDecl*VD, Expr* Init);
2596 
2597  /// \brief Get the copy initialization expression of the VarDecl \p VD, or
2598  /// nullptr if none exists.
2599  Expr *getBlockVarCopyInits(const VarDecl* VD);
2600 
2601  /// \brief Allocate an uninitialized TypeSourceInfo.
2602  ///
2603  /// The caller should initialize the memory held by TypeSourceInfo using
2604  /// the TypeLoc wrappers.
2605  ///
2606  /// \param T the type that will be the basis for type source info. This type
2607  /// should refer to how the declarator was written in source code, not to
2608  /// what type semantic analysis resolved the declarator to.
2609  ///
2610  /// \param Size the size of the type info to create, or 0 if the size
2611  /// should be calculated based on the type.
2612  TypeSourceInfo *CreateTypeSourceInfo(QualType T, unsigned Size = 0) const;
2613 
2614  /// \brief Allocate a TypeSourceInfo where all locations have been
2615  /// initialized to a given location, which defaults to the empty
2616  /// location.
2617  TypeSourceInfo *
2618  getTrivialTypeSourceInfo(QualType T,
2619  SourceLocation Loc = SourceLocation()) const;
2620 
2621  /// \brief Add a deallocation callback that will be invoked when the
2622  /// ASTContext is destroyed.
2623  ///
2624  /// \param Callback A callback function that will be invoked on destruction.
2625  ///
2626  /// \param Data Pointer data that will be provided to the callback function
2627  /// when it is called.
2628  void AddDeallocation(void (*Callback)(void*), void *Data);
2629 
2630  /// If T isn't trivially destructible, calls AddDeallocation to register it
2631  /// for destruction.
2632  template <typename T>
2633  void addDestruction(T *Ptr) {
2634  if (!std::is_trivially_destructible<T>::value) {
2635  auto DestroyPtr = [](void *V) { static_cast<T *>(V)->~T(); };
2636  AddDeallocation(DestroyPtr, Ptr);
2637  }
2638  }
2639 
2640  GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const;
2641  GVALinkage GetGVALinkageForVariable(const VarDecl *VD);
2642 
2643  /// \brief Determines if the decl can be CodeGen'ed or deserialized from PCH
2644  /// lazily, only when used; this is only relevant for function or file scoped
2645  /// var definitions.
2646  ///
2647  /// \returns true if the function/var must be CodeGen'ed/deserialized even if
2648  /// it is not used.
2649  bool DeclMustBeEmitted(const Decl *D);
2650 
2651  /// \brief Visits all versions of a multiversioned function with the passed
2652  /// predicate.
2653  void forEachMultiversionedFunctionVersion(
2654  const FunctionDecl *FD,
2655  llvm::function_ref<void(const FunctionDecl *)> Pred) const;
2656 
2657  const CXXConstructorDecl *
2658  getCopyConstructorForExceptionObject(CXXRecordDecl *RD);
2659 
2660  void addCopyConstructorForExceptionObject(CXXRecordDecl *RD,
2661  CXXConstructorDecl *CD);
2662 
2663  void addTypedefNameForUnnamedTagDecl(TagDecl *TD, TypedefNameDecl *TND);
2664 
2665  TypedefNameDecl *getTypedefNameForUnnamedTagDecl(const TagDecl *TD);
2666 
2667  void addDeclaratorForUnnamedTagDecl(TagDecl *TD, DeclaratorDecl *DD);
2668 
2669  DeclaratorDecl *getDeclaratorForUnnamedTagDecl(const TagDecl *TD);
2670 
2671  void setManglingNumber(const NamedDecl *ND, unsigned Number);
2672  unsigned getManglingNumber(const NamedDecl *ND) const;
2673 
2674  void setStaticLocalNumber(const VarDecl *VD, unsigned Number);
2675  unsigned getStaticLocalNumber(const VarDecl *VD) const;
2676 
2677  /// \brief Retrieve the context for computing mangling numbers in the given
2678  /// DeclContext.
2679  MangleNumberingContext &getManglingNumberContext(const DeclContext *DC);
2680 
2681  std::unique_ptr<MangleNumberingContext> createMangleNumberingContext() const;
2682 
2683  /// \brief Used by ParmVarDecl to store on the side the
2684  /// index of the parameter when it exceeds the size of the normal bitfield.
2685  void setParameterIndex(const ParmVarDecl *D, unsigned index);
2686 
2687  /// \brief Used by ParmVarDecl to retrieve on the side the
2688  /// index of the parameter when it exceeds the size of the normal bitfield.
2689  unsigned getParameterIndex(const ParmVarDecl *D) const;
2690 
2691  /// \brief Get the storage for the constant value of a materialized temporary
2692  /// of static storage duration.
2693  APValue *getMaterializedTemporaryValue(const MaterializeTemporaryExpr *E,
2694  bool MayCreate);
2695 
2696  //===--------------------------------------------------------------------===//
2697  // Statistics
2698  //===--------------------------------------------------------------------===//
2699 
2700  /// \brief The number of implicitly-declared default constructors.
2702 
2703  /// \brief The number of implicitly-declared default constructors for
2704  /// which declarations were built.
2706 
2707  /// \brief The number of implicitly-declared copy constructors.
2709 
2710  /// \brief The number of implicitly-declared copy constructors for
2711  /// which declarations were built.
2713 
2714  /// \brief The number of implicitly-declared move constructors.
2716 
2717  /// \brief The number of implicitly-declared move constructors for
2718  /// which declarations were built.
2720 
2721  /// \brief The number of implicitly-declared copy assignment operators.
2723 
2724  /// \brief The number of implicitly-declared copy assignment operators for
2725  /// which declarations were built.
2727 
2728  /// \brief The number of implicitly-declared move assignment operators.
2730 
2731  /// \brief The number of implicitly-declared move assignment operators for
2732  /// which declarations were built.
2734 
2735  /// \brief The number of implicitly-declared destructors.
2736  static unsigned NumImplicitDestructors;
2737 
2738  /// \brief The number of implicitly-declared destructors for which
2739  /// declarations were built.
2741 
2742 public:
2743  /// \brief Initialize built-in types.
2744  ///
2745  /// This routine may only be invoked once for a given ASTContext object.
2746  /// It is normally invoked after ASTContext construction.
2747  ///
2748  /// \param Target The target
2749  void InitBuiltinTypes(const TargetInfo &Target,
2750  const TargetInfo *AuxTarget = nullptr);
2751 
2752 private:
2753  void InitBuiltinType(CanQualType &R, BuiltinType::Kind K);
2754 
2755  // Return the Objective-C type encoding for a given type.
2756  void getObjCEncodingForTypeImpl(QualType t, std::string &S,
2757  bool ExpandPointedToStructures,
2758  bool ExpandStructures,
2759  const FieldDecl *Field,
2760  bool OutermostType = false,
2761  bool EncodingProperty = false,
2762  bool StructField = false,
2763  bool EncodeBlockParameters = false,
2764  bool EncodeClassNames = false,
2765  bool EncodePointerToObjCTypedef = false,
2766  QualType *NotEncodedT=nullptr) const;
2767 
2768  // Adds the encoding of the structure's members.
2769  void getObjCEncodingForStructureImpl(RecordDecl *RD, std::string &S,
2770  const FieldDecl *Field,
2771  bool includeVBases = true,
2772  QualType *NotEncodedT=nullptr) const;
2773 
2774 public:
2775  // Adds the encoding of a method parameter or return type.
2776  void getObjCEncodingForMethodParameter(Decl::ObjCDeclQualifier QT,
2777  QualType T, std::string& S,
2778  bool Extended) const;
2779 
2780  /// \brief Returns true if this is an inline-initialized static data member
2781  /// which is treated as a definition for MSVC compatibility.
2782  bool isMSStaticDataMemberInlineDefinition(const VarDecl *VD) const;
2783 
2785  /// Not an inline variable.
2786  None,
2787 
2788  /// Weak definition of inline variable.
2789  Weak,
2790 
2791  /// Weak for now, might become strong later in this TU.
2792  WeakUnknown,
2793 
2794  /// Strong definition.
2795  Strong
2796  };
2797 
2798  /// \brief Determine whether a definition of this inline variable should
2799  /// be treated as a weak or strong definition. For compatibility with
2800  /// C++14 and before, for a constexpr static data member, if there is an
2801  /// out-of-line declaration of the member, we may promote it from weak to
2802  /// strong.
2804  getInlineVariableDefinitionKind(const VarDecl *VD) const;
2805 
2806 private:
2807  friend class DeclarationNameTable;
2808  friend class DeclContext;
2809 
2810  const ASTRecordLayout &
2811  getObjCLayout(const ObjCInterfaceDecl *D,
2812  const ObjCImplementationDecl *Impl) const;
2813 
2814  /// \brief A set of deallocations that should be performed when the
2815  /// ASTContext is destroyed.
2816  // FIXME: We really should have a better mechanism in the ASTContext to
2817  // manage running destructors for types which do variable sized allocation
2818  // within the AST. In some places we thread the AST bump pointer allocator
2819  // into the datastructures which avoids this mess during deallocation but is
2820  // wasteful of memory, and here we require a lot of error prone book keeping
2821  // in order to track and run destructors while we're tearing things down.
2824  DeallocationFunctionsAndArguments Deallocations;
2825 
2826  // FIXME: This currently contains the set of StoredDeclMaps used
2827  // by DeclContext objects. This probably should not be in ASTContext,
2828  // but we include it here so that ASTContext can quickly deallocate them.
2829  llvm::PointerIntPair<StoredDeclsMap *, 1> LastSDM;
2830 
2831  std::unique_ptr<ParentMapPointers> PointerParents;
2832  std::unique_ptr<ParentMapOtherNodes> OtherParents;
2833 
2834  std::unique_ptr<VTableContextBase> VTContext;
2835 
2836  void ReleaseDeclContextMaps();
2837  void ReleaseParentMapEntries();
2838 
2839 public:
2840  enum PragmaSectionFlag : unsigned {
2841  PSF_None = 0,
2842  PSF_Read = 0x1,
2843  PSF_Write = 0x2,
2844  PSF_Execute = 0x4,
2845  PSF_Implicit = 0x8,
2846  PSF_Invalid = 0x80000000U,
2847  };
2848 
2849  struct SectionInfo {
2853 
2854  SectionInfo() = default;
2856  SourceLocation PragmaSectionLocation,
2857  int SectionFlags)
2858  : Decl(Decl), PragmaSectionLocation(PragmaSectionLocation),
2859  SectionFlags(SectionFlags) {}
2860  };
2861 
2862  llvm::StringMap<SectionInfo> SectionInfos;
2863 };
2864 
2865 /// \brief Utility function for constructing a nullary selector.
2866 inline Selector GetNullarySelector(StringRef name, ASTContext &Ctx) {
2867  IdentifierInfo* II = &Ctx.Idents.get(name);
2868  return Ctx.Selectors.getSelector(0, &II);
2869 }
2870 
2871 /// \brief Utility function for constructing an unary selector.
2872 inline Selector GetUnarySelector(StringRef name, ASTContext &Ctx) {
2873  IdentifierInfo* II = &Ctx.Idents.get(name);
2874  return Ctx.Selectors.getSelector(1, &II);
2875 }
2876 
2877 } // namespace clang
2878 
2879 // operator new and delete aren't allowed inside namespaces.
2880 
2881 /// @brief Placement new for using the ASTContext's allocator.
2882 ///
2883 /// This placement form of operator new uses the ASTContext's allocator for
2884 /// obtaining memory.
2885 ///
2886 /// IMPORTANT: These are also declared in clang/AST/AttrIterator.h! Any changes
2887 /// here need to also be made there.
2888 ///
2889 /// We intentionally avoid using a nothrow specification here so that the calls
2890 /// to this operator will not perform a null check on the result -- the
2891 /// underlying allocator never returns null pointers.
2892 ///
2893 /// Usage looks like this (assuming there's an ASTContext 'Context' in scope):
2894 /// @code
2895 /// // Default alignment (8)
2896 /// IntegerLiteral *Ex = new (Context) IntegerLiteral(arguments);
2897 /// // Specific alignment
2898 /// IntegerLiteral *Ex2 = new (Context, 4) IntegerLiteral(arguments);
2899 /// @endcode
2900 /// Memory allocated through this placement new operator does not need to be
2901 /// explicitly freed, as ASTContext will free all of this memory when it gets
2902 /// destroyed. Please note that you cannot use delete on the pointer.
2903 ///
2904 /// @param Bytes The number of bytes to allocate. Calculated by the compiler.
2905 /// @param C The ASTContext that provides the allocator.
2906 /// @param Alignment The alignment of the allocated memory (if the underlying
2907 /// allocator supports it).
2908 /// @return The allocated memory. Could be nullptr.
2909 inline void *operator new(size_t Bytes, const clang::ASTContext &C,
2910  size_t Alignment) {
2911  return C.Allocate(Bytes, Alignment);
2912 }
2913 
2914 /// @brief Placement delete companion to the new above.
2915 ///
2916 /// This operator is just a companion to the new above. There is no way of
2917 /// invoking it directly; see the new operator for more details. This operator
2918 /// is called implicitly by the compiler if a placement new expression using
2919 /// the ASTContext throws in the object constructor.
2920 inline void operator delete(void *Ptr, const clang::ASTContext &C, size_t) {
2921  C.Deallocate(Ptr);
2922 }
2923 
2924 /// This placement form of operator new[] uses the ASTContext's allocator for
2925 /// obtaining memory.
2926 ///
2927 /// We intentionally avoid using a nothrow specification here so that the calls
2928 /// to this operator will not perform a null check on the result -- the
2929 /// underlying allocator never returns null pointers.
2930 ///
2931 /// Usage looks like this (assuming there's an ASTContext 'Context' in scope):
2932 /// @code
2933 /// // Default alignment (8)
2934 /// char *data = new (Context) char[10];
2935 /// // Specific alignment
2936 /// char *data = new (Context, 4) char[10];
2937 /// @endcode
2938 /// Memory allocated through this placement new[] operator does not need to be
2939 /// explicitly freed, as ASTContext will free all of this memory when it gets
2940 /// destroyed. Please note that you cannot use delete on the pointer.
2941 ///
2942 /// @param Bytes The number of bytes to allocate. Calculated by the compiler.
2943 /// @param C The ASTContext that provides the allocator.
2944 /// @param Alignment The alignment of the allocated memory (if the underlying
2945 /// allocator supports it).
2946 /// @return The allocated memory. Could be nullptr.
2947 inline void *operator new[](size_t Bytes, const clang::ASTContext& C,
2948  size_t Alignment = 8) {
2949  return C.Allocate(Bytes, Alignment);
2950 }
2951 
2952 /// @brief Placement delete[] companion to the new[] above.
2953 ///
2954 /// This operator is just a companion to the new[] above. There is no way of
2955 /// invoking it directly; see the new[] operator for more details. This operator
2956 /// is called implicitly by the compiler if a placement new[] expression using
2957 /// the ASTContext throws in the object constructor.
2958 inline void operator delete[](void *Ptr, const clang::ASTContext &C, size_t) {
2959  C.Deallocate(Ptr);
2960 }
2961 
2962 /// \brief Create the representation of a LazyGenerationalUpdatePtr.
2963 template <typename Owner, typename T,
2964  void (clang::ExternalASTSource::*Update)(Owner)>
2967  const clang::ASTContext &Ctx, T Value) {
2968  // Note, this is implemented here so that ExternalASTSource.h doesn't need to
2969  // include ASTContext.h. We explicitly instantiate it for all relevant types
2970  // in ASTContext.cpp.
2971  if (auto *Source = Ctx.getExternalSource())
2972  return new (Ctx) LazyData(Source, Value);
2973  return Value;
2974 }
2975 
2976 #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:2342
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:1709
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:2733
CanQualType Char32Ty
Definition: ASTContext.h:1003
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: Dominators.h:30
static unsigned NumImplicitDefaultConstructors
The number of implicitly-declared default constructors.
Definition: ASTContext.h:2701
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
Definition: Type.h:1382
Stmt - This represents one statement.
Definition: Stmt.h:66
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3125
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
Definition: TargetInfo.h:795
Represents the declaration of a typedef-name via the &#39;typedef&#39; type specifier.
Definition: Decl.h:2955
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:2729
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:1895
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:1930
The base class of the type hierarchy.
Definition: Type.h:1419
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:2627
QualType withConst() const
Definition: Type.h:818
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:2448
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:2043
QualType withFastQualifiers(unsigned TQs) const
Definition: Type.h:861
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:3465
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:1528
QualType getQualifiedType(QualType T, Qualifiers Qs) const
Return a type with additional qualifiers.
Definition: ASTContext.h:1900
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:3543
One of these records is kept for each identifier that is lexed.
bool isObjCClassType(QualType T) const
Definition: ASTContext.h:2460
bool isObjCIdType(QualType T) const
Definition: ASTContext.h:2456
This table allows us to fully hide how we implement multi-keyword caching.
Represents a class type in Objective C.
Definition: Type.h:5263
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:2719
QualType getLifetimeQualifiedType(QualType type, Qualifiers::ObjCLifetime lifetime)
Return a type with the given lifetime qualifier.
Definition: ASTContext.h:1918
Represents a member of a struct/union/class.
Definition: Decl.h:2516
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:2436
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:2547
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:2866
Represents a declaration of a type.
Definition: Decl.h:2811
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:1890
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition: Type.h:5797
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:2345
Defines the Linkage enumeration and various utility functions.
import_range local_imports() const
Definition: ASTContext.h:948
static unsigned NumImplicitDefaultConstructorsDeclared
The number of implicitly-declared default constructors for which declarations were built...
Definition: ASTContext.h:2705
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2083
unsigned getTypeAlign(const Type *T) const
Definition: ASTContext.h:2044
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
void addComment(const RawComment &RC, const CommentOptions &CommentOpts, llvm::BumpPtrAllocator &Allocator)
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:2862
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:3346
llvm::iterator_range< import_iterator > import_range
Definition: ASTContext.h:946
static unsigned NumImplicitCopyConstructors
The number of implicitly-declared copy constructors.
Definition: ASTContext.h:2708
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:2016
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition: Type.h:2633
bool hasSameType(const Type *T1, const Type *T2) const
Definition: ASTContext.h:2208
bool isObjCSelType(QualType T) const
Definition: ASTContext.h:2464
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:2569
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:2841
CommentOptions CommentOpts
Options for parsing comments.
Definition: LangOptions.h:192
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:636
Expr - This represents one expression.
Definition: Expr.h:106
Defines the clang::LangOptions interface.
SourceLocation End
QualType getucontext_tType() const
Retrieve the C ucontext_t type.
Definition: ASTContext.h: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:4784
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:4873
CanQualType OMPArraySectionTy
Definition: ASTContext.h:1023
static unsigned NumImplicitMoveConstructors
The number of implicitly-declared move constructors.
Definition: ASTContext.h:2715
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:2234
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:2983
const Type * getCanonicalType(const Type *T) const
Definition: ASTContext.h:2193
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:4440
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:2633
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:718
const SourceManager & SM
Definition: Format.cpp:1419
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:2851
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:2740
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:4767
SelectorTable & Selectors
Definition: ASTContext.h:538
QualType getCanonicalType() const
Definition: Type.h:5836
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:2726
Kind getKind() const LLVM_READONLY
Definition: ASTContext.h:735
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3001
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:43
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2016
const ConstantArrayType * getAsConstantArrayType(QualType T) const
Definition: ASTContext.h:2336
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:241
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:5125
CanQualType VoidTy
Definition: ASTContext.h:996
CanQualType Float16Ty
Definition: ASTContext.h:1009
bool isObjCObjectPointerType() const
Definition: Type.h:6118
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:2229
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition: Decl.h:4117
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:2426
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:2853
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:4765
Dataflow Directional Tag Classes.
SectionInfo(DeclaratorDecl *Decl, SourceLocation PragmaSectionLocation, int SectionFlags)
Definition: ASTContext.h:2855
A qualifier set is used to build a set of qualifiers.
Definition: Type.h:5764
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
unsigned[(unsigned) LangAS::FirstTargetAddressSpace] LangASMap
The type of a lookup table which maps from language-specific address spaces to target-specific ones...
Definition: AddressSpaces.h:54
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:354
CanQualType getPointerType(CanQualType T) const
Definition: ASTContext.h: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:5771
Represents an enum.
Definition: Decl.h:3294
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:2722
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:5519
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:2176
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:2026
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:2205
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:3625
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:2022
QualType getQualifiedType(const Type *T, Qualifiers Qs) const
Return a type with additional qualifiers.
Definition: ASTContext.h:1909
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:2189
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
Definition: SemaDecl.cpp:13491
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:5877
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:300
IdentifierInfo * getTypePackElementName() const
Definition: ASTContext.h:1684
Represents a template specialization type whose template cannot be resolved, e.g. ...
Definition: Type.h:4980
Selector GetUnarySelector(StringRef name, ASTContext &Ctx)
Utility function for constructing an unary selector.
Definition: ASTContext.h:2872
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:2741
Missing a type from <stdio.h>
Definition: ASTContext.h:1963
IdentifierInfo * getMakeIntegerSeqName() const
Definition: ASTContext.h:1678
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Definition: Type.h:5824
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1964
bool operator!=(CanQual< T > x, CanQual< U > y)
Provides information a specialization of a member of a class template, which may be a member function...
Definition: DeclTemplate.h:608
CanQualType Char16Ty
Definition: ASTContext.h:1002
static unsigned NumImplicitCopyConstructorsDeclared
The number of implicitly-declared copy constructors for which declarations were built.
Definition: ASTContext.h:2712
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:2339
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:74
A lazy value (of type T) that is within an AST node of type Owner, where the value might change in la...
llvm::DenseMap< ast_type_traits::DynTypedNode, llvm::PointerUnion4< const Decl *, const Stmt *, ast_type_traits::DynTypedNode *, ParentVector * > > ParentMapOtherNodes
Parent map for nodes without pointer identity.
Definition: ASTContext.h: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:2786
CanQualType BoolTy
Definition: ASTContext.h:997
unsigned getTargetAddressSpace(QualType T) const
Definition: ASTContext.h:2422
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:2002
IdentifierInfo * getBoolName() const
Retrieve the identifier &#39;bool&#39;.
Definition: ASTContext.h:1672
Missing a type from <setjmp.h>
Definition: ASTContext.h:1966
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:2687
This class handles loading and caching of source files into memory.
uint64_t getTypeSize(const Type *T) const
Definition: ASTContext.h:2023
bool isObjCNSObjectType() const
Definition: Type.cpp:3832
A class which abstracts out some details necessary for making a call.
Definition: Type.h:3150
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
Definition: DeclCXX.h:3117
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:1070
static unsigned NumImplicitDestructors
The number of implicitly-declared destructors.
Definition: ASTContext.h:2736