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