clang 19.0.0git
ASTContext.h
Go to the documentation of this file.
1//===- ASTContext.h - Context to hold long-lived AST nodes ------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9/// \file
10/// Defines the clang::ASTContext interface.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_AST_ASTCONTEXT_H
15#define LLVM_CLANG_AST_ASTCONTEXT_H
16
17#include "clang/AST/ASTFwd.h"
21#include "clang/AST/Decl.h"
27#include "clang/Basic/LLVM.h"
30#include "llvm/ADT/DenseMap.h"
31#include "llvm/ADT/DenseSet.h"
32#include "llvm/ADT/FoldingSet.h"
33#include "llvm/ADT/IntrusiveRefCntPtr.h"
34#include "llvm/ADT/MapVector.h"
35#include "llvm/ADT/PointerIntPair.h"
36#include "llvm/ADT/PointerUnion.h"
37#include "llvm/ADT/SmallVector.h"
38#include "llvm/ADT/StringMap.h"
39#include "llvm/ADT/StringRef.h"
40#include "llvm/ADT/StringSet.h"
41#include "llvm/ADT/TinyPtrVector.h"
42#include "llvm/Support/TypeSize.h"
43#include <optional>
44
45namespace llvm {
46
47class APFixedPoint;
48class FixedPointSemantics;
49struct fltSemantics;
50template <typename T, unsigned N> class SmallPtrSet;
51
52} // namespace llvm
53
54namespace clang {
55
56class APValue;
57class ASTMutationListener;
58class ASTRecordLayout;
59class AtomicExpr;
60class BlockExpr;
61struct BlockVarCopyInit;
62class BuiltinTemplateDecl;
63class CharUnits;
64class ConceptDecl;
65class CXXABI;
66class CXXConstructorDecl;
67class CXXMethodDecl;
68class CXXRecordDecl;
69class DiagnosticsEngine;
70class DynTypedNodeList;
71class Expr;
72enum class FloatModeKind;
73class GlobalDecl;
74class IdentifierTable;
75class LangOptions;
76class MangleContext;
77class MangleNumberingContext;
78class MemberSpecializationInfo;
79class Module;
80struct MSGuidDeclParts;
81class NestedNameSpecifier;
82class NoSanitizeList;
83class ObjCCategoryDecl;
84class ObjCCategoryImplDecl;
85class ObjCContainerDecl;
86class ObjCImplDecl;
87class ObjCImplementationDecl;
88class ObjCInterfaceDecl;
89class ObjCIvarDecl;
90class ObjCMethodDecl;
91class ObjCPropertyDecl;
92class ObjCPropertyImplDecl;
93class ObjCProtocolDecl;
94class ObjCTypeParamDecl;
95class OMPTraitInfo;
96class ParentMapContext;
97struct ParsedTargetAttr;
98class Preprocessor;
99class ProfileList;
100class StoredDeclsMap;
101class TargetAttr;
102class TargetInfo;
103class TemplateDecl;
104class TemplateParameterList;
105class TemplateTemplateParmDecl;
106class TemplateTypeParmDecl;
107class TypeConstraint;
108class UnresolvedSetIterator;
109class UsingShadowDecl;
110class VarTemplateDecl;
111class VTableContextBase;
112class XRayFunctionFilter;
113
114/// A simple array of base specifiers.
116
117namespace Builtin {
118
119class Context;
120
121} // namespace Builtin
122
124enum OpenCLTypeKind : uint8_t;
125
126namespace comments {
127
128class FullComment;
129
130} // namespace comments
131
132namespace interp {
133
134class Context;
135
136} // namespace interp
137
138namespace serialization {
139template <class> class AbstractTypeReader;
140} // namespace serialization
141
143 /// The alignment was not explicit in code.
144 None,
145
146 /// The alignment comes from an alignment attribute on a typedef.
148
149 /// The alignment comes from an alignment attribute on a record type.
151
152 /// The alignment comes from an alignment attribute on a enum type.
154};
155
156struct TypeInfo {
157 uint64_t Width = 0;
158 unsigned Align = 0;
160
162 TypeInfo(uint64_t Width, unsigned Align,
167 }
168};
169
174
181 }
182};
183
184/// Holds long-lived AST nodes (such as types and decls) that can be
185/// referred to throughout the semantic analysis of a file.
186class ASTContext : public RefCountedBase<ASTContext> {
188
189 mutable SmallVector<Type *, 0> Types;
190 mutable llvm::FoldingSet<ExtQuals> ExtQualNodes;
191 mutable llvm::FoldingSet<ComplexType> ComplexTypes;
192 mutable llvm::FoldingSet<PointerType> PointerTypes{GeneralTypesLog2InitSize};
193 mutable llvm::FoldingSet<AdjustedType> AdjustedTypes;
194 mutable llvm::FoldingSet<BlockPointerType> BlockPointerTypes;
195 mutable llvm::FoldingSet<LValueReferenceType> LValueReferenceTypes;
196 mutable llvm::FoldingSet<RValueReferenceType> RValueReferenceTypes;
197 mutable llvm::FoldingSet<MemberPointerType> MemberPointerTypes;
198 mutable llvm::ContextualFoldingSet<ConstantArrayType, ASTContext &>
199 ConstantArrayTypes;
200 mutable llvm::FoldingSet<IncompleteArrayType> IncompleteArrayTypes;
201 mutable std::vector<VariableArrayType*> VariableArrayTypes;
202 mutable llvm::ContextualFoldingSet<DependentSizedArrayType, ASTContext &>
203 DependentSizedArrayTypes;
204 mutable llvm::ContextualFoldingSet<DependentSizedExtVectorType, ASTContext &>
205 DependentSizedExtVectorTypes;
206 mutable llvm::ContextualFoldingSet<DependentAddressSpaceType, ASTContext &>
207 DependentAddressSpaceTypes;
208 mutable llvm::FoldingSet<VectorType> VectorTypes;
209 mutable llvm::ContextualFoldingSet<DependentVectorType, ASTContext &>
210 DependentVectorTypes;
211 mutable llvm::FoldingSet<ConstantMatrixType> MatrixTypes;
212 mutable llvm::ContextualFoldingSet<DependentSizedMatrixType, ASTContext &>
213 DependentSizedMatrixTypes;
214 mutable llvm::FoldingSet<FunctionNoProtoType> FunctionNoProtoTypes;
215 mutable llvm::ContextualFoldingSet<FunctionProtoType, ASTContext&>
216 FunctionProtoTypes;
217 mutable llvm::ContextualFoldingSet<DependentTypeOfExprType, ASTContext &>
218 DependentTypeOfExprTypes;
219 mutable llvm::ContextualFoldingSet<DependentDecltypeType, ASTContext &>
220 DependentDecltypeTypes;
221
222 mutable llvm::FoldingSet<PackIndexingType> DependentPackIndexingTypes;
223
224 mutable llvm::FoldingSet<TemplateTypeParmType> TemplateTypeParmTypes;
225 mutable llvm::FoldingSet<ObjCTypeParamType> ObjCTypeParamTypes;
226 mutable llvm::FoldingSet<SubstTemplateTypeParmType>
227 SubstTemplateTypeParmTypes;
228 mutable llvm::FoldingSet<SubstTemplateTypeParmPackType>
229 SubstTemplateTypeParmPackTypes;
230 mutable llvm::ContextualFoldingSet<TemplateSpecializationType, ASTContext&>
231 TemplateSpecializationTypes;
232 mutable llvm::FoldingSet<ParenType> ParenTypes{GeneralTypesLog2InitSize};
233 mutable llvm::FoldingSet<UsingType> UsingTypes;
234 mutable llvm::FoldingSet<TypedefType> TypedefTypes;
235 mutable llvm::FoldingSet<ElaboratedType> ElaboratedTypes{
236 GeneralTypesLog2InitSize};
237 mutable llvm::FoldingSet<DependentNameType> DependentNameTypes;
238 mutable llvm::ContextualFoldingSet<DependentTemplateSpecializationType,
239 ASTContext&>
240 DependentTemplateSpecializationTypes;
241 llvm::FoldingSet<PackExpansionType> PackExpansionTypes;
242 mutable llvm::FoldingSet<ObjCObjectTypeImpl> ObjCObjectTypes;
243 mutable llvm::FoldingSet<ObjCObjectPointerType> ObjCObjectPointerTypes;
244 mutable llvm::FoldingSet<DependentUnaryTransformType>
245 DependentUnaryTransformTypes;
246 mutable llvm::ContextualFoldingSet<AutoType, ASTContext&> AutoTypes;
247 mutable llvm::FoldingSet<DeducedTemplateSpecializationType>
248 DeducedTemplateSpecializationTypes;
249 mutable llvm::FoldingSet<AtomicType> AtomicTypes;
250 mutable llvm::FoldingSet<AttributedType> AttributedTypes;
251 mutable llvm::FoldingSet<PipeType> PipeTypes;
252 mutable llvm::FoldingSet<BitIntType> BitIntTypes;
253 mutable llvm::ContextualFoldingSet<DependentBitIntType, ASTContext &>
254 DependentBitIntTypes;
255 llvm::FoldingSet<BTFTagAttributedType> BTFTagAttributedTypes;
256
257 mutable llvm::FoldingSet<CountAttributedType> CountAttributedTypes;
258
259 mutable llvm::FoldingSet<QualifiedTemplateName> QualifiedTemplateNames;
260 mutable llvm::FoldingSet<DependentTemplateName> DependentTemplateNames;
261 mutable llvm::FoldingSet<SubstTemplateTemplateParmStorage>
262 SubstTemplateTemplateParms;
263 mutable llvm::ContextualFoldingSet<SubstTemplateTemplateParmPackStorage,
264 ASTContext&>
265 SubstTemplateTemplateParmPacks;
266
267 mutable llvm::ContextualFoldingSet<ArrayParameterType, ASTContext &>
268 ArrayParameterTypes;
269
270 /// The set of nested name specifiers.
271 ///
272 /// This set is managed by the NestedNameSpecifier class.
273 mutable llvm::FoldingSet<NestedNameSpecifier> NestedNameSpecifiers;
274 mutable NestedNameSpecifier *GlobalNestedNameSpecifier = nullptr;
275
276 /// A cache mapping from RecordDecls to ASTRecordLayouts.
277 ///
278 /// This is lazily created. This is intentionally not serialized.
279 mutable llvm::DenseMap<const RecordDecl*, const ASTRecordLayout*>
280 ASTRecordLayouts;
281 mutable llvm::DenseMap<const ObjCContainerDecl*, const ASTRecordLayout*>
282 ObjCLayouts;
283
284 /// A cache from types to size and alignment information.
285 using TypeInfoMap = llvm::DenseMap<const Type *, struct TypeInfo>;
286 mutable TypeInfoMap MemoizedTypeInfo;
287
288 /// A cache from types to unadjusted alignment information. Only ARM and
289 /// AArch64 targets need this information, keeping it separate prevents
290 /// imposing overhead on TypeInfo size.
291 using UnadjustedAlignMap = llvm::DenseMap<const Type *, unsigned>;
292 mutable UnadjustedAlignMap MemoizedUnadjustedAlign;
293
294 /// A cache mapping from CXXRecordDecls to key functions.
295 llvm::DenseMap<const CXXRecordDecl*, LazyDeclPtr> KeyFunctions;
296
297 /// Mapping from ObjCContainers to their ObjCImplementations.
298 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*> ObjCImpls;
299
300 /// Mapping from ObjCMethod to its duplicate declaration in the same
301 /// interface.
302 llvm::DenseMap<const ObjCMethodDecl*,const ObjCMethodDecl*> ObjCMethodRedecls;
303
304 /// Mapping from __block VarDecls to BlockVarCopyInit.
305 llvm::DenseMap<const VarDecl *, BlockVarCopyInit> BlockVarCopyInits;
306
307 /// Mapping from GUIDs to the corresponding MSGuidDecl.
308 mutable llvm::FoldingSet<MSGuidDecl> MSGuidDecls;
309
310 /// Mapping from APValues to the corresponding UnnamedGlobalConstantDecl.
311 mutable llvm::FoldingSet<UnnamedGlobalConstantDecl>
312 UnnamedGlobalConstantDecls;
313
314 /// Mapping from APValues to the corresponding TemplateParamObjects.
315 mutable llvm::FoldingSet<TemplateParamObjectDecl> TemplateParamObjectDecls;
316
317 /// A cache mapping a string value to a StringLiteral object with the same
318 /// value.
319 ///
320 /// This is lazily created. This is intentionally not serialized.
321 mutable llvm::StringMap<StringLiteral *> StringLiteralCache;
322
323 /// MD5 hash of CUID. It is calculated when first used and cached by this
324 /// data member.
325 mutable std::string CUIDHash;
326
327 /// Representation of a "canonical" template template parameter that
328 /// is used in canonical template names.
329 class CanonicalTemplateTemplateParm : public llvm::FoldingSetNode {
330 TemplateTemplateParmDecl *Parm;
331
332 public:
333 CanonicalTemplateTemplateParm(TemplateTemplateParmDecl *Parm)
334 : Parm(Parm) {}
335
336 TemplateTemplateParmDecl *getParam() const { return Parm; }
337
338 void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &C) {
339 Profile(ID, C, Parm);
340 }
341
342 static void Profile(llvm::FoldingSetNodeID &ID,
343 const ASTContext &C,
344 TemplateTemplateParmDecl *Parm);
345 };
346 mutable llvm::ContextualFoldingSet<CanonicalTemplateTemplateParm,
347 const ASTContext&>
348 CanonTemplateTemplateParms;
349
350 TemplateTemplateParmDecl *
351 getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const;
352
353 /// The typedef for the __int128_t type.
354 mutable TypedefDecl *Int128Decl = nullptr;
355
356 /// The typedef for the __uint128_t type.
357 mutable TypedefDecl *UInt128Decl = nullptr;
358
359 /// The typedef for the target specific predefined
360 /// __builtin_va_list type.
361 mutable TypedefDecl *BuiltinVaListDecl = nullptr;
362
363 /// The typedef for the predefined \c __builtin_ms_va_list type.
364 mutable TypedefDecl *BuiltinMSVaListDecl = nullptr;
365
366 /// The typedef for the predefined \c id type.
367 mutable TypedefDecl *ObjCIdDecl = nullptr;
368
369 /// The typedef for the predefined \c SEL type.
370 mutable TypedefDecl *ObjCSelDecl = nullptr;
371
372 /// The typedef for the predefined \c Class type.
373 mutable TypedefDecl *ObjCClassDecl = nullptr;
374
375 /// The typedef for the predefined \c Protocol class in Objective-C.
376 mutable ObjCInterfaceDecl *ObjCProtocolClassDecl = nullptr;
377
378 /// The typedef for the predefined 'BOOL' type.
379 mutable TypedefDecl *BOOLDecl = nullptr;
380
381 // Typedefs which may be provided defining the structure of Objective-C
382 // pseudo-builtins
383 QualType ObjCIdRedefinitionType;
384 QualType ObjCClassRedefinitionType;
385 QualType ObjCSelRedefinitionType;
386
387 /// The identifier 'bool'.
388 mutable IdentifierInfo *BoolName = nullptr;
389
390 /// The identifier 'NSObject'.
391 mutable IdentifierInfo *NSObjectName = nullptr;
392
393 /// The identifier 'NSCopying'.
394 IdentifierInfo *NSCopyingName = nullptr;
395
396 /// The identifier '__make_integer_seq'.
397 mutable IdentifierInfo *MakeIntegerSeqName = nullptr;
398
399 /// The identifier '__type_pack_element'.
400 mutable IdentifierInfo *TypePackElementName = nullptr;
401
402 QualType ObjCConstantStringType;
403 mutable RecordDecl *CFConstantStringTagDecl = nullptr;
404 mutable TypedefDecl *CFConstantStringTypeDecl = nullptr;
405
406 mutable QualType ObjCSuperType;
407
408 QualType ObjCNSStringType;
409
410 /// The typedef declaration for the Objective-C "instancetype" type.
411 TypedefDecl *ObjCInstanceTypeDecl = nullptr;
412
413 /// The type for the C FILE type.
414 TypeDecl *FILEDecl = nullptr;
415
416 /// The type for the C jmp_buf type.
417 TypeDecl *jmp_bufDecl = nullptr;
418
419 /// The type for the C sigjmp_buf type.
420 TypeDecl *sigjmp_bufDecl = nullptr;
421
422 /// The type for the C ucontext_t type.
423 TypeDecl *ucontext_tDecl = nullptr;
424
425 /// Type for the Block descriptor for Blocks CodeGen.
426 ///
427 /// Since this is only used for generation of debug info, it is not
428 /// serialized.
429 mutable RecordDecl *BlockDescriptorType = nullptr;
430
431 /// Type for the Block descriptor for Blocks CodeGen.
432 ///
433 /// Since this is only used for generation of debug info, it is not
434 /// serialized.
435 mutable RecordDecl *BlockDescriptorExtendedType = nullptr;
436
437 /// Declaration for the CUDA cudaConfigureCall function.
438 FunctionDecl *cudaConfigureCallDecl = nullptr;
439
440 /// Keeps track of all declaration attributes.
441 ///
442 /// Since so few decls have attrs, we keep them in a hash map instead of
443 /// wasting space in the Decl class.
444 llvm::DenseMap<const Decl*, AttrVec*> DeclAttrs;
445
446 /// A mapping from non-redeclarable declarations in modules that were
447 /// merged with other declarations to the canonical declaration that they were
448 /// merged into.
449 llvm::DenseMap<Decl*, Decl*> MergedDecls;
450
451 /// A mapping from a defining declaration to a list of modules (other
452 /// than the owning module of the declaration) that contain merged
453 /// definitions of that entity.
454 llvm::DenseMap<NamedDecl*, llvm::TinyPtrVector<Module*>> MergedDefModules;
455
456 /// Initializers for a module, in order. Each Decl will be either
457 /// something that has a semantic effect on startup (such as a variable with
458 /// a non-constant initializer), or an ImportDecl (which recursively triggers
459 /// initialization of another module).
460 struct PerModuleInitializers {
461 llvm::SmallVector<Decl*, 4> Initializers;
462 llvm::SmallVector<GlobalDeclID, 4> LazyInitializers;
463
464 void resolve(ASTContext &Ctx);
465 };
466 llvm::DenseMap<Module*, PerModuleInitializers*> ModuleInitializers;
467
468 /// This is the top-level (C++20) Named module we are building.
469 Module *CurrentCXXNamedModule = nullptr;
470
471 /// Help structures to decide whether two `const Module *` belongs
472 /// to the same conceptual module to avoid the expensive to string comparison
473 /// if possible.
474 ///
475 /// Not serialized intentionally.
476 llvm::StringMap<const Module *> PrimaryModuleNameMap;
477 llvm::DenseMap<const Module *, const Module *> SameModuleLookupSet;
478
479 static constexpr unsigned ConstantArrayTypesLog2InitSize = 8;
480 static constexpr unsigned GeneralTypesLog2InitSize = 9;
481 static constexpr unsigned FunctionProtoTypesLog2InitSize = 12;
482
483 ASTContext &this_() { return *this; }
484
485public:
486 /// A type synonym for the TemplateOrInstantiation mapping.
488 llvm::PointerUnion<VarTemplateDecl *, MemberSpecializationInfo *>;
489
490private:
491 friend class ASTDeclReader;
492 friend class ASTReader;
493 friend class ASTWriter;
494 template <class> friend class serialization::AbstractTypeReader;
495 friend class CXXRecordDecl;
496 friend class IncrementalParser;
497
498 /// A mapping to contain the template or declaration that
499 /// a variable declaration describes or was instantiated from,
500 /// respectively.
501 ///
502 /// For non-templates, this value will be NULL. For variable
503 /// declarations that describe a variable template, this will be a
504 /// pointer to a VarTemplateDecl. For static data members
505 /// of class template specializations, this will be the
506 /// MemberSpecializationInfo referring to the member variable that was
507 /// instantiated or specialized. Thus, the mapping will keep track of
508 /// the static data member templates from which static data members of
509 /// class template specializations were instantiated.
510 ///
511 /// Given the following example:
512 ///
513 /// \code
514 /// template<typename T>
515 /// struct X {
516 /// static T value;
517 /// };
518 ///
519 /// template<typename T>
520 /// T X<T>::value = T(17);
521 ///
522 /// int *x = &X<int>::value;
523 /// \endcode
524 ///
525 /// This mapping will contain an entry that maps from the VarDecl for
526 /// X<int>::value to the corresponding VarDecl for X<T>::value (within the
527 /// class template X) and will be marked TSK_ImplicitInstantiation.
528 llvm::DenseMap<const VarDecl *, TemplateOrSpecializationInfo>
529 TemplateOrInstantiation;
530
531 /// Keeps track of the declaration from which a using declaration was
532 /// created during instantiation.
533 ///
534 /// The source and target declarations are always a UsingDecl, an
535 /// UnresolvedUsingValueDecl, or an UnresolvedUsingTypenameDecl.
536 ///
537 /// For example:
538 /// \code
539 /// template<typename T>
540 /// struct A {
541 /// void f();
542 /// };
543 ///
544 /// template<typename T>
545 /// struct B : A<T> {
546 /// using A<T>::f;
547 /// };
548 ///
549 /// template struct B<int>;
550 /// \endcode
551 ///
552 /// This mapping will contain an entry that maps from the UsingDecl in
553 /// B<int> to the UnresolvedUsingDecl in B<T>.
554 llvm::DenseMap<NamedDecl *, NamedDecl *> InstantiatedFromUsingDecl;
555
556 /// Like InstantiatedFromUsingDecl, but for using-enum-declarations. Maps
557 /// from the instantiated using-enum to the templated decl from whence it
558 /// came.
559 /// Note that using-enum-declarations cannot be dependent and
560 /// thus will never be instantiated from an "unresolved"
561 /// version thereof (as with using-declarations), so each mapping is from
562 /// a (resolved) UsingEnumDecl to a (resolved) UsingEnumDecl.
563 llvm::DenseMap<UsingEnumDecl *, UsingEnumDecl *>
564 InstantiatedFromUsingEnumDecl;
565
566 /// Simlarly maps instantiated UsingShadowDecls to their origin.
567 llvm::DenseMap<UsingShadowDecl*, UsingShadowDecl*>
568 InstantiatedFromUsingShadowDecl;
569
570 llvm::DenseMap<FieldDecl *, FieldDecl *> InstantiatedFromUnnamedFieldDecl;
571
572 /// Mapping that stores the methods overridden by a given C++
573 /// member function.
574 ///
575 /// Since most C++ member functions aren't virtual and therefore
576 /// don't override anything, we store the overridden functions in
577 /// this map on the side rather than within the CXXMethodDecl structure.
578 using CXXMethodVector = llvm::TinyPtrVector<const CXXMethodDecl *>;
579 llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector> OverriddenMethods;
580
581 /// Mapping from each declaration context to its corresponding
582 /// mangling numbering context (used for constructs like lambdas which
583 /// need to be consistently numbered for the mangler).
584 llvm::DenseMap<const DeclContext *, std::unique_ptr<MangleNumberingContext>>
585 MangleNumberingContexts;
586 llvm::DenseMap<const Decl *, std::unique_ptr<MangleNumberingContext>>
587 ExtraMangleNumberingContexts;
588
589 /// Side-table of mangling numbers for declarations which rarely
590 /// need them (like static local vars).
591 llvm::MapVector<const NamedDecl *, unsigned> MangleNumbers;
592 llvm::MapVector<const VarDecl *, unsigned> StaticLocalNumbers;
593 /// Mapping the associated device lambda mangling number if present.
594 mutable llvm::DenseMap<const CXXRecordDecl *, unsigned>
595 DeviceLambdaManglingNumbers;
596
597 /// Mapping that stores parameterIndex values for ParmVarDecls when
598 /// that value exceeds the bitfield size of ParmVarDeclBits.ParameterIndex.
599 using ParameterIndexTable = llvm::DenseMap<const VarDecl *, unsigned>;
600 ParameterIndexTable ParamIndices;
601
602 ImportDecl *FirstLocalImport = nullptr;
603 ImportDecl *LastLocalImport = nullptr;
604
605 TranslationUnitDecl *TUDecl = nullptr;
606 mutable ExternCContextDecl *ExternCContext = nullptr;
607 mutable BuiltinTemplateDecl *MakeIntegerSeqDecl = nullptr;
608 mutable BuiltinTemplateDecl *TypePackElementDecl = nullptr;
609
610 /// The associated SourceManager object.
611 SourceManager &SourceMgr;
612
613 /// The language options used to create the AST associated with
614 /// this ASTContext object.
615 LangOptions &LangOpts;
616
617 /// NoSanitizeList object that is used by sanitizers to decide which
618 /// entities should not be instrumented.
619 std::unique_ptr<NoSanitizeList> NoSanitizeL;
620
621 /// Function filtering mechanism to determine whether a given function
622 /// should be imbued with the XRay "always" or "never" attributes.
623 std::unique_ptr<XRayFunctionFilter> XRayFilter;
624
625 /// ProfileList object that is used by the profile instrumentation
626 /// to decide which entities should be instrumented.
627 std::unique_ptr<ProfileList> ProfList;
628
629 /// The allocator used to create AST objects.
630 ///
631 /// AST objects are never destructed; rather, all memory associated with the
632 /// AST objects will be released when the ASTContext itself is destroyed.
633 mutable llvm::BumpPtrAllocator BumpAlloc;
634
635 /// Allocator for partial diagnostics.
637
638 /// The current C++ ABI.
639 std::unique_ptr<CXXABI> ABI;
641
642 /// Address space map mangling must be used with language specific
643 /// address spaces (e.g. OpenCL/CUDA)
644 bool AddrSpaceMapMangling;
645
646 const TargetInfo *Target = nullptr;
647 const TargetInfo *AuxTarget = nullptr;
649 std::unique_ptr<interp::Context> InterpContext;
650 std::unique_ptr<ParentMapContext> ParentMapCtx;
651
652 /// Keeps track of the deallocated DeclListNodes for future reuse.
653 DeclListNode *ListNodeFreeList = nullptr;
654
655public:
663
664 /// Returns the clang bytecode interpreter context.
666
668 /// Do not allow wrong-sided variables in constant expressions.
669 bool NoWrongSidedVars = false;
674 CUDAConstantEvalContextRAII(ASTContext &Ctx_, bool NoWrongSidedVars)
675 : Ctx(Ctx_), SavedCtx(Ctx_.CUDAConstantEvalCtx) {
676 Ctx_.CUDAConstantEvalCtx.NoWrongSidedVars = NoWrongSidedVars;
677 }
679 };
680
681 /// Returns the dynamic AST node parent map context.
683
684 // A traversal scope limits the parts of the AST visible to certain analyses.
685 // RecursiveASTVisitor only visits specified children of TranslationUnitDecl.
686 // getParents() will only observe reachable parent edges.
687 //
688 // The scope is defined by a set of "top-level" declarations which will be
689 // visible under the TranslationUnitDecl.
690 // Initially, it is the entire TU, represented by {getTranslationUnitDecl()}.
691 //
692 // After setTraversalScope({foo, bar}), the exposed AST looks like:
693 // TranslationUnitDecl
694 // - foo
695 // - ...
696 // - bar
697 // - ...
698 // All other siblings of foo and bar are pruned from the tree.
699 // (However they are still accessible via TranslationUnitDecl->decls())
700 //
701 // Changing the scope clears the parent cache, which is expensive to rebuild.
702 std::vector<Decl *> getTraversalScope() const { return TraversalScope; }
703 void setTraversalScope(const std::vector<Decl *> &);
704
705 /// Forwards to get node parents from the ParentMapContext. New callers should
706 /// use ParentMapContext::getParents() directly.
707 template <typename NodeT> DynTypedNodeList getParents(const NodeT &Node);
708
710 return PrintingPolicy;
711 }
712
714 PrintingPolicy = Policy;
715 }
716
717 SourceManager& getSourceManager() { return SourceMgr; }
718 const SourceManager& getSourceManager() const { return SourceMgr; }
719
720 // Cleans up some of the data structures. This allows us to do cleanup
721 // normally done in the destructor earlier. Renders much of the ASTContext
722 // unusable, mostly the actual AST nodes, so should be called when we no
723 // longer need access to the AST.
724 void cleanup();
725
726 llvm::BumpPtrAllocator &getAllocator() const {
727 return BumpAlloc;
728 }
729
730 void *Allocate(size_t Size, unsigned Align = 8) const {
731 return BumpAlloc.Allocate(Size, Align);
732 }
733 template <typename T> T *Allocate(size_t Num = 1) const {
734 return static_cast<T *>(Allocate(Num * sizeof(T), alignof(T)));
735 }
736 void Deallocate(void *Ptr) const {}
737
738 /// Allocates a \c DeclListNode or returns one from the \c ListNodeFreeList
739 /// pool.
741 if (DeclListNode *Alloc = ListNodeFreeList) {
742 ListNodeFreeList = Alloc->Rest.dyn_cast<DeclListNode*>();
743 Alloc->D = ND;
744 Alloc->Rest = nullptr;
745 return Alloc;
746 }
747 return new (*this) DeclListNode(ND);
748 }
749 /// Deallcates a \c DeclListNode by returning it to the \c ListNodeFreeList
750 /// pool.
752 N->Rest = ListNodeFreeList;
753 ListNodeFreeList = N;
754 }
755
756 /// Return the total amount of physical memory allocated for representing
757 /// AST nodes and type information.
758 size_t getASTAllocatedMemory() const {
759 return BumpAlloc.getTotalMemory();
760 }
761
762 /// Return the total memory used for various side tables.
763 size_t getSideTableAllocatedMemory() const;
764
766 return DiagAllocator;
767 }
768
769 const TargetInfo &getTargetInfo() const { return *Target; }
770 const TargetInfo *getAuxTargetInfo() const { return AuxTarget; }
771
772 /// getIntTypeForBitwidth -
773 /// sets integer QualTy according to specified details:
774 /// bitwidth, signed/unsigned.
775 /// Returns empty type if there is no appropriate target types.
776 QualType getIntTypeForBitwidth(unsigned DestWidth,
777 unsigned Signed) const;
778
779 /// getRealTypeForBitwidth -
780 /// sets floating point QualTy according to specified bitwidth.
781 /// Returns empty type if there is no appropriate target types.
782 QualType getRealTypeForBitwidth(unsigned DestWidth,
783 FloatModeKind ExplicitType) const;
784
785 bool AtomicUsesUnsupportedLibcall(const AtomicExpr *E) const;
786
787 const LangOptions& getLangOpts() const { return LangOpts; }
788
789 // If this condition is false, typo correction must be performed eagerly
790 // rather than delayed in many places, as it makes use of dependent types.
791 // the condition is false for clang's C-only codepath, as it doesn't support
792 // dependent types yet.
793 bool isDependenceAllowed() const {
794 return LangOpts.CPlusPlus || LangOpts.RecoveryAST;
795 }
796
797 const NoSanitizeList &getNoSanitizeList() const { return *NoSanitizeL; }
798
800 return *XRayFilter;
801 }
802
803 const ProfileList &getProfileList() const { return *ProfList; }
804
806
808 return FullSourceLoc(Loc,SourceMgr);
809 }
810
811 /// Return the C++ ABI kind that should be used. The C++ ABI can be overriden
812 /// at compile time with `-fc++-abi=`. If this is not provided, we instead use
813 /// the default ABI set by the target.
815
816 /// All comments in this translation unit.
818
819 /// True if comments are already loaded from ExternalASTSource.
820 mutable bool CommentsLoaded = false;
821
822 /// Mapping from declaration to directly attached comment.
823 ///
824 /// Raw comments are owned by Comments list. This mapping is populated
825 /// lazily.
826 mutable llvm::DenseMap<const Decl *, const RawComment *> DeclRawComments;
827
828 /// Mapping from canonical declaration to the first redeclaration in chain
829 /// that has a comment attached.
830 ///
831 /// Raw comments are owned by Comments list. This mapping is populated
832 /// lazily.
833 mutable llvm::DenseMap<const Decl *, const Decl *> RedeclChainComments;
834
835 /// Keeps track of redeclaration chains that don't have any comment attached.
836 /// Mapping from canonical declaration to redeclaration chain that has no
837 /// comments attached to any redeclaration. Specifically it's mapping to
838 /// the last redeclaration we've checked.
839 ///
840 /// Shall not contain declarations that have comments attached to any
841 /// redeclaration in their chain.
842 mutable llvm::DenseMap<const Decl *, const Decl *> CommentlessRedeclChains;
843
844 /// Mapping from declarations to parsed comments attached to any
845 /// redeclaration.
846 mutable llvm::DenseMap<const Decl *, comments::FullComment *> ParsedComments;
847
848 /// Attaches \p Comment to \p OriginalD and to its redeclaration chain
849 /// and removes the redeclaration chain from the set of commentless chains.
850 ///
851 /// Don't do anything if a comment has already been attached to \p OriginalD
852 /// or its redeclaration chain.
853 void cacheRawCommentForDecl(const Decl &OriginalD,
854 const RawComment &Comment) const;
855
856 /// \returns searches \p CommentsInFile for doc comment for \p D.
857 ///
858 /// \p RepresentativeLocForDecl is used as a location for searching doc
859 /// comments. \p CommentsInFile is a mapping offset -> comment of files in the
860 /// same file where \p RepresentativeLocForDecl is.
862 const Decl *D, const SourceLocation RepresentativeLocForDecl,
863 const std::map<unsigned, RawComment *> &CommentsInFile) const;
864
865 /// Return the documentation comment attached to a given declaration,
866 /// without looking into cache.
868
869public:
870 void addComment(const RawComment &RC);
871
872 /// Return the documentation comment attached to a given declaration.
873 /// Returns nullptr if no comment is attached.
874 ///
875 /// \param OriginalDecl if not nullptr, is set to declaration AST node that
876 /// had the comment, if the comment we found comes from a redeclaration.
877 const RawComment *
879 const Decl **OriginalDecl = nullptr) const;
880
881 /// Searches existing comments for doc comments that should be attached to \p
882 /// Decls. If any doc comment is found, it is parsed.
883 ///
884 /// Requirement: All \p Decls are in the same file.
885 ///
886 /// If the last comment in the file is already attached we assume
887 /// there are not comments left to be attached to \p Decls.
889 const Preprocessor *PP);
890
891 /// Return parsed documentation comment attached to a given declaration.
892 /// Returns nullptr if no comment is attached.
893 ///
894 /// \param PP the Preprocessor used with this TU. Could be nullptr if
895 /// preprocessor is not available.
897 const Preprocessor *PP) const;
898
899 /// Return parsed documentation comment attached to a given declaration.
900 /// Returns nullptr if no comment is attached. Does not look at any
901 /// redeclarations of the declaration.
903
905 const Decl *D) const;
906
907private:
908 mutable comments::CommandTraits CommentCommandTraits;
909
910 /// Iterator that visits import declarations.
911 class import_iterator {
912 ImportDecl *Import = nullptr;
913
914 public:
915 using value_type = ImportDecl *;
916 using reference = ImportDecl *;
917 using pointer = ImportDecl *;
918 using difference_type = int;
919 using iterator_category = std::forward_iterator_tag;
920
921 import_iterator() = default;
922 explicit import_iterator(ImportDecl *Import) : Import(Import) {}
923
924 reference operator*() const { return Import; }
925 pointer operator->() const { return Import; }
926
927 import_iterator &operator++() {
929 return *this;
930 }
931
932 import_iterator operator++(int) {
933 import_iterator Other(*this);
934 ++(*this);
935 return Other;
936 }
937
938 friend bool operator==(import_iterator X, import_iterator Y) {
939 return X.Import == Y.Import;
940 }
941
942 friend bool operator!=(import_iterator X, import_iterator Y) {
943 return X.Import != Y.Import;
944 }
945 };
946
947public:
949 return CommentCommandTraits;
950 }
951
952 /// Retrieve the attributes for the given declaration.
953 AttrVec& getDeclAttrs(const Decl *D);
954
955 /// Erase the attributes corresponding to the given declaration.
956 void eraseDeclAttrs(const Decl *D);
957
958 /// If this variable is an instantiated static data member of a
959 /// class template specialization, returns the templated static data member
960 /// from which it was instantiated.
961 // FIXME: Remove ?
963 const VarDecl *Var);
964
965 /// Note that the static data member \p Inst is an instantiation of
966 /// the static data member template \p Tmpl of a class template.
969 SourceLocation PointOfInstantiation = SourceLocation());
970
973
976
977 /// If the given using decl \p Inst is an instantiation of
978 /// another (possibly unresolved) using decl, return it.
980
981 /// Remember that the using decl \p Inst is an instantiation
982 /// of the using decl \p Pattern of a class template.
984
985 /// If the given using-enum decl \p Inst is an instantiation of
986 /// another using-enum decl, return it.
988
989 /// Remember that the using enum decl \p Inst is an instantiation
990 /// of the using enum decl \p Pattern of a class template.
992 UsingEnumDecl *Pattern);
993
996 UsingShadowDecl *Pattern);
997
999
1001
1002 // Access to the set of methods overridden by the given C++ method.
1003 using overridden_cxx_method_iterator = CXXMethodVector::const_iterator;
1005 overridden_methods_begin(const CXXMethodDecl *Method) const;
1006
1008 overridden_methods_end(const CXXMethodDecl *Method) const;
1009
1010 unsigned overridden_methods_size(const CXXMethodDecl *Method) const;
1011
1013 llvm::iterator_range<overridden_cxx_method_iterator>;
1014
1016
1017 /// Note that the given C++ \p Method overrides the given \p
1018 /// Overridden method.
1019 void addOverriddenMethod(const CXXMethodDecl *Method,
1020 const CXXMethodDecl *Overridden);
1021
1022 /// Return C++ or ObjC overridden methods for the given \p Method.
1023 ///
1024 /// An ObjC method is considered to override any method in the class's
1025 /// base classes, its protocols, or its categories' protocols, that has
1026 /// the same selector and is of the same kind (class or instance).
1027 /// A method in an implementation is not considered as overriding the same
1028 /// method in the interface or its categories.
1030 const NamedDecl *Method,
1031 SmallVectorImpl<const NamedDecl *> &Overridden) const;
1032
1033 /// Notify the AST context that a new import declaration has been
1034 /// parsed or implicitly created within this translation unit.
1035 void addedLocalImportDecl(ImportDecl *Import);
1036
1038 return Import->getNextLocalImport();
1039 }
1040
1041 using import_range = llvm::iterator_range<import_iterator>;
1042
1044 return import_range(import_iterator(FirstLocalImport), import_iterator());
1045 }
1046
1048 Decl *Result = MergedDecls.lookup(D);
1049 return Result ? Result : D;
1050 }
1051 void setPrimaryMergedDecl(Decl *D, Decl *Primary) {
1052 MergedDecls[D] = Primary;
1053 }
1054
1055 /// Note that the definition \p ND has been merged into module \p M,
1056 /// and should be visible whenever \p M is visible.
1058 bool NotifyListeners = true);
1059
1060 /// Clean up the merged definition list. Call this if you might have
1061 /// added duplicates into the list.
1063
1064 /// Get the additional modules in which the definition \p Def has
1065 /// been merged.
1067
1068 /// Add a declaration to the list of declarations that are initialized
1069 /// for a module. This will typically be a global variable (with internal
1070 /// linkage) that runs module initializers, such as the iostream initializer,
1071 /// or an ImportDecl nominating another module that has initializers.
1073
1075
1076 /// Get the initializations to perform when importing a module, if any.
1078
1079 /// Set the (C++20) module we are building.
1081
1082 /// Get module under construction, nullptr if this is not a C++20 module.
1083 Module *getCurrentNamedModule() const { return CurrentCXXNamedModule; }
1084
1085 /// If the two module \p M1 and \p M2 are in the same module.
1086 ///
1087 /// FIXME: The signature may be confusing since `clang::Module` means to
1088 /// a module fragment or a module unit but not a C++20 module.
1089 bool isInSameModule(const Module *M1, const Module *M2);
1090
1092 return TUDecl->getMostRecentDecl();
1093 }
1095 assert(!TUDecl || TUKind == TU_Incremental);
1097 if (TraversalScope.empty() || TraversalScope.back() == TUDecl)
1098 TraversalScope = {NewTUDecl};
1099 if (TUDecl)
1100 NewTUDecl->setPreviousDecl(TUDecl);
1101 TUDecl = NewTUDecl;
1102 }
1103
1107
1108 // Builtin Types.
1112 CanQualType WCharTy; // [C++ 3.9.1p5].
1113 CanQualType WideCharTy; // Same as WCharTy in C++, integer type in C99.
1114 CanQualType WIntTy; // [C99 7.24.1], integer type unchanged by default promotions.
1115 CanQualType Char8Ty; // [C++20 proposal]
1116 CanQualType Char16Ty; // [C++0x 3.9.1p5], integer type in C99.
1117 CanQualType Char32Ty; // [C++0x 3.9.1p5], integer type in C99.
1123 LongAccumTy; // ISO/IEC JTC1 SC22 WG14 N1169 Extension
1133 CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
1135 CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
1143#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1144 CanQualType SingletonId;
1145#include "clang/Basic/OpenCLImageTypes.def"
1151#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1152 CanQualType Id##Ty;
1153#include "clang/Basic/OpenCLExtensionTypes.def"
1154#define SVE_TYPE(Name, Id, SingletonId) \
1155 CanQualType SingletonId;
1156#include "clang/Basic/AArch64SVEACLETypes.def"
1157#define PPC_VECTOR_TYPE(Name, Id, Size) \
1158 CanQualType Id##Ty;
1159#include "clang/Basic/PPCTypes.def"
1160#define RVV_TYPE(Name, Id, SingletonId) \
1161 CanQualType SingletonId;
1162#include "clang/Basic/RISCVVTypes.def"
1163#define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
1164#include "clang/Basic/WebAssemblyReferenceTypes.def"
1165#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
1166#include "clang/Basic/AMDGPUTypes.def"
1167
1168 // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand.
1169 mutable QualType AutoDeductTy; // Deduction against 'auto'.
1170 mutable QualType AutoRRefDeductTy; // Deduction against 'auto &&'.
1171
1172 // Decl used to help define __builtin_va_list for some targets.
1173 // The decl is built when constructing 'BuiltinVaListDecl'.
1174 mutable Decl *VaListTagDecl = nullptr;
1175
1176 // Implicitly-declared type 'struct _GUID'.
1177 mutable TagDecl *MSGuidTagDecl = nullptr;
1178
1179 /// Keep track of CUDA/HIP device-side variables ODR-used by host code.
1180 /// This does not include extern shared variables used by device host
1181 /// functions as addresses of shared variables are per warp, therefore
1182 /// cannot be accessed by host code.
1184
1185 /// Keep track of CUDA/HIP external kernels or device variables ODR-used by
1186 /// host code.
1188
1189 /// Keep track of CUDA/HIP implicit host device functions used on device side
1190 /// in device compilation.
1192
1193 /// For capturing lambdas with an explicit object parameter whose type is
1194 /// derived from the lambda type, we need to perform derived-to-base
1195 /// conversion so we can access the captures; the cast paths for that
1196 /// are stored here.
1197 llvm::DenseMap<const CXXMethodDecl *, CXXCastPath> LambdaCastPaths;
1198
1200 SelectorTable &sels, Builtin::Context &builtins,
1202 ASTContext(const ASTContext &) = delete;
1203 ASTContext &operator=(const ASTContext &) = delete;
1204 ~ASTContext();
1205
1206 /// Attach an external AST source to the AST context.
1207 ///
1208 /// The external AST source provides the ability to load parts of
1209 /// the abstract syntax tree as needed from some external storage,
1210 /// e.g., a precompiled header.
1212
1213 /// Retrieve a pointer to the external AST source associated
1214 /// with this AST context, if any.
1216 return ExternalSource.get();
1217 }
1218
1219 /// Attach an AST mutation listener to the AST context.
1220 ///
1221 /// The AST mutation listener provides the ability to track modifications to
1222 /// the abstract syntax tree entities committed after they were initially
1223 /// created.
1225 this->Listener = Listener;
1226 }
1227
1228 /// Retrieve a pointer to the AST mutation listener associated
1229 /// with this AST context, if any.
1231
1232 void PrintStats() const;
1233 const SmallVectorImpl<Type *>& getTypes() const { return Types; }
1234
1236 const IdentifierInfo *II) const;
1237
1238 /// Create a new implicit TU-level CXXRecordDecl or RecordDecl
1239 /// declaration.
1241 StringRef Name,
1242 RecordDecl::TagKind TK = RecordDecl::TagKind::Struct) const;
1243
1244 /// Create a new implicit TU-level typedef declaration.
1245 TypedefDecl *buildImplicitTypedef(QualType T, StringRef Name) const;
1246
1247 /// Retrieve the declaration for the 128-bit signed integer type.
1248 TypedefDecl *getInt128Decl() const;
1249
1250 /// Retrieve the declaration for the 128-bit unsigned integer type.
1251 TypedefDecl *getUInt128Decl() const;
1252
1253 //===--------------------------------------------------------------------===//
1254 // Type Constructors
1255 //===--------------------------------------------------------------------===//
1256
1257private:
1258 /// Return a type with extended qualifiers.
1259 QualType getExtQualType(const Type *Base, Qualifiers Quals) const;
1260
1261 QualType getTypeDeclTypeSlow(const TypeDecl *Decl) const;
1262
1263 QualType getPipeType(QualType T, bool ReadOnly) const;
1264
1265public:
1266 /// Return the uniqued reference to the type for an address space
1267 /// qualified type with the specified type and address space.
1268 ///
1269 /// The resulting type has a union of the qualifiers from T and the address
1270 /// space. If T already has an address space specifier, it is silently
1271 /// replaced.
1272 QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const;
1273
1274 /// Remove any existing address space on the type and returns the type
1275 /// with qualifiers intact (or that's the idea anyway)
1276 ///
1277 /// The return type should be T with all prior qualifiers minus the address
1278 /// space.
1280
1281 /// Return the "other" discriminator used for the pointer auth schema used for
1282 /// vtable pointers in instances of the requested type.
1283 uint16_t
1285
1286 /// Return the "other" type-specific discriminator for the given type.
1288
1289 /// Apply Objective-C protocol qualifiers to the given type.
1290 /// \param allowOnPointerType specifies if we can apply protocol
1291 /// qualifiers on ObjCObjectPointerType. It can be set to true when
1292 /// constructing the canonical type of a Objective-C type parameter.
1294 ArrayRef<ObjCProtocolDecl *> protocols, bool &hasError,
1295 bool allowOnPointerType = false) const;
1296
1297 /// Return the uniqued reference to the type for an Objective-C
1298 /// gc-qualified type.
1299 ///
1300 /// The resulting type has a union of the qualifiers from T and the gc
1301 /// attribute.
1303
1304 /// Remove the existing address space on the type if it is a pointer size
1305 /// address space and return the type with qualifiers intact.
1307
1308 /// Return the uniqued reference to the type for a \c restrict
1309 /// qualified type.
1310 ///
1311 /// The resulting type has a union of the qualifiers from \p T and
1312 /// \c restrict.
1314 return T.withFastQualifiers(Qualifiers::Restrict);
1315 }
1316
1317 /// Return the uniqued reference to the type for a \c volatile
1318 /// qualified type.
1319 ///
1320 /// The resulting type has a union of the qualifiers from \p T and
1321 /// \c volatile.
1323 return T.withFastQualifiers(Qualifiers::Volatile);
1324 }
1325
1326 /// Return the uniqued reference to the type for a \c const
1327 /// qualified type.
1328 ///
1329 /// The resulting type has a union of the qualifiers from \p T and \c const.
1330 ///
1331 /// It can be reasonably expected that this will always be equivalent to
1332 /// calling T.withConst().
1333 QualType getConstType(QualType T) const { return T.withConst(); }
1334
1335 /// Change the ExtInfo on a function type.
1337 FunctionType::ExtInfo EInfo);
1338
1339 /// Adjust the given function result type.
1341
1342 /// Change the result type of a function type once it is deduced.
1344
1345 /// Get a function type and produce the equivalent function type with the
1346 /// specified exception specification. Type sugar that can be present on a
1347 /// declaration of a function with an exception specification is permitted
1348 /// and preserved. Other type sugar (for instance, typedefs) is not.
1350 QualType Orig, const FunctionProtoType::ExceptionSpecInfo &ESI) const;
1351
1352 /// Determine whether two function types are the same, ignoring
1353 /// exception specifications in cases where they're part of the type.
1355
1356 /// Change the exception specification on a function once it is
1357 /// delay-parsed, instantiated, or computed.
1360 bool AsWritten = false);
1361
1362 /// Get a function type and produce the equivalent function type where
1363 /// pointer size address spaces in the return type and parameter tyeps are
1364 /// replaced with the default address space.
1366
1367 /// Determine whether two function types are the same, ignoring pointer sizes
1368 /// in the return type and parameter types.
1370
1371 /// Return the uniqued reference to the type for a complex
1372 /// number with the specified element type.
1376 }
1377
1378 /// Return the uniqued reference to the type for a pointer to
1379 /// the specified type.
1383 }
1384
1385 QualType
1386 getCountAttributedType(QualType T, Expr *CountExpr, bool CountInBytes,
1387 bool OrNull,
1388 ArrayRef<TypeCoupledDeclRefInfo> DependentDecls) const;
1389
1390 /// Return the uniqued reference to a type adjusted from the original
1391 /// type to a new type.
1392 QualType getAdjustedType(QualType Orig, QualType New) const;
1395 getAdjustedType((QualType)Orig, (QualType)New));
1396 }
1397
1398 /// Return the uniqued reference to the decayed version of the given
1399 /// type. Can only be called on array and function types which decay to
1400 /// pointer types.
1404 }
1405 /// Return the uniqued reference to a specified decay from the original
1406 /// type to the decayed type.
1407 QualType getDecayedType(QualType Orig, QualType Decayed) const;
1408
1409 /// Return the uniqued reference to a specified array parameter type from the
1410 /// original array type.
1412
1413 /// Return the uniqued reference to the atomic type for the specified
1414 /// type.
1416
1417 /// Return the uniqued reference to the type for a block of the
1418 /// specified type.
1420
1421 /// Gets the struct used to keep track of the descriptor for pointer to
1422 /// blocks.
1424
1425 /// Return a read_only pipe type for the specified type.
1427
1428 /// Return a write_only pipe type for the specified type.
1430
1431 /// Return a bit-precise integer type with the specified signedness and bit
1432 /// count.
1433 QualType getBitIntType(bool Unsigned, unsigned NumBits) const;
1434
1435 /// Return a dependent bit-precise integer type with the specified signedness
1436 /// and bit count.
1437 QualType getDependentBitIntType(bool Unsigned, Expr *BitsExpr) const;
1438
1439 /// Gets the struct used to keep track of the extended descriptor for
1440 /// pointer to blocks.
1442
1443 /// Map an AST Type to an OpenCLTypeKind enum value.
1444 OpenCLTypeKind getOpenCLTypeKind(const Type *T) const;
1445
1446 /// Get address space for OpenCL type.
1447 LangAS getOpenCLTypeAddrSpace(const Type *T) const;
1448
1449 /// Returns default address space based on OpenCL version and enabled features
1451 return LangOpts.OpenCLGenericAddressSpace ? LangAS::opencl_generic
1453 }
1454
1456 cudaConfigureCallDecl = FD;
1457 }
1458
1460 return cudaConfigureCallDecl;
1461 }
1462
1463 /// Returns true iff we need copy/dispose helpers for the given type.
1464 bool BlockRequiresCopying(QualType Ty, const VarDecl *D);
1465
1466 /// Returns true, if given type has a known lifetime. HasByrefExtendedLayout
1467 /// is set to false in this case. If HasByrefExtendedLayout returns true,
1468 /// byref variable has extended lifetime.
1469 bool getByrefLifetime(QualType Ty,
1470 Qualifiers::ObjCLifetime &Lifetime,
1471 bool &HasByrefExtendedLayout) const;
1472
1473 /// Return the uniqued reference to the type for an lvalue reference
1474 /// to the specified type.
1475 QualType getLValueReferenceType(QualType T, bool SpelledAsLValue = true)
1476 const;
1477
1478 /// Return the uniqued reference to the type for an rvalue reference
1479 /// to the specified type.
1481
1482 /// Return the uniqued reference to the type for a member pointer to
1483 /// the specified type in the specified class.
1484 ///
1485 /// The class \p Cls is a \c Type because it could be a dependent name.
1486 QualType getMemberPointerType(QualType T, const Type *Cls) const;
1487
1488 /// Return a non-unique reference to the type for a variable array of
1489 /// the specified element type.
1491 ArraySizeModifier ASM, unsigned IndexTypeQuals,
1492 SourceRange Brackets) const;
1493
1494 /// Return a non-unique reference to the type for a dependently-sized
1495 /// array of the specified element type.
1496 ///
1497 /// FIXME: We will need these to be uniqued, or at least comparable, at some
1498 /// point.
1501 unsigned IndexTypeQuals,
1502 SourceRange Brackets) const;
1503
1504 /// Return a unique reference to the type for an incomplete array of
1505 /// the specified element type.
1507 unsigned IndexTypeQuals) const;
1508
1509 /// Return the unique reference to the type for a constant array of
1510 /// the specified element type.
1511 QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize,
1512 const Expr *SizeExpr, ArraySizeModifier ASM,
1513 unsigned IndexTypeQuals) const;
1514
1515 /// Return a type for a constant array for a string literal of the
1516 /// specified element type and length.
1517 QualType getStringLiteralArrayType(QualType EltTy, unsigned Length) const;
1518
1519 /// Returns a vla type where known sizes are replaced with [*].
1521
1522 // Convenience struct to return information about a builtin vector type.
1525 llvm::ElementCount EC;
1526 unsigned NumVectors;
1528 unsigned NumVectors)
1530 };
1531
1532 /// Returns the element type, element count and number of vectors
1533 /// (in case of tuple) for a builtin vector type.
1534 BuiltinVectorTypeInfo
1535 getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const;
1536
1537 /// Return the unique reference to a scalable vector type of the specified
1538 /// element type and scalable number of elements.
1539 /// For RISC-V, number of fields is also provided when it fetching for
1540 /// tuple type.
1541 ///
1542 /// \pre \p EltTy must be a built-in type.
1543 QualType getScalableVectorType(QualType EltTy, unsigned NumElts,
1544 unsigned NumFields = 1) const;
1545
1546 /// Return a WebAssembly externref type.
1548
1549 /// Return the unique reference to a vector type of the specified
1550 /// element type and size.
1551 ///
1552 /// \pre \p VectorType must be a built-in type.
1553 QualType getVectorType(QualType VectorType, unsigned NumElts,
1554 VectorKind VecKind) const;
1555 /// Return the unique reference to the type for a dependently sized vector of
1556 /// the specified element type.
1558 SourceLocation AttrLoc,
1559 VectorKind VecKind) const;
1560
1561 /// Return the unique reference to an extended vector type
1562 /// of the specified element type and size.
1563 ///
1564 /// \pre \p VectorType must be a built-in type.
1565 QualType getExtVectorType(QualType VectorType, unsigned NumElts) const;
1566
1567 /// \pre Return a non-unique reference to the type for a dependently-sized
1568 /// vector of the specified element type.
1569 ///
1570 /// FIXME: We will need these to be uniqued, or at least comparable, at some
1571 /// point.
1573 Expr *SizeExpr,
1574 SourceLocation AttrLoc) const;
1575
1576 /// Return the unique reference to the matrix type of the specified element
1577 /// type and size
1578 ///
1579 /// \pre \p ElementType must be a valid matrix element type (see
1580 /// MatrixType::isValidElementType).
1581 QualType getConstantMatrixType(QualType ElementType, unsigned NumRows,
1582 unsigned NumColumns) const;
1583
1584 /// Return the unique reference to the matrix type of the specified element
1585 /// type and size
1586 QualType getDependentSizedMatrixType(QualType ElementType, Expr *RowExpr,
1587 Expr *ColumnExpr,
1588 SourceLocation AttrLoc) const;
1589
1591 Expr *AddrSpaceExpr,
1592 SourceLocation AttrLoc) const;
1593
1594 /// Return a K&R style C function type like 'int()'.
1596 const FunctionType::ExtInfo &Info) const;
1597
1600 }
1601
1602 /// Return a normal function type with a typed argument list.
1604 const FunctionProtoType::ExtProtoInfo &EPI) const {
1605 return getFunctionTypeInternal(ResultTy, Args, EPI, false);
1606 }
1607
1609
1610private:
1611 /// Return a normal function type with a typed argument list.
1612 QualType getFunctionTypeInternal(QualType ResultTy, ArrayRef<QualType> Args,
1614 bool OnlyWantCanonical) const;
1615 QualType
1616 getAutoTypeInternal(QualType DeducedType, AutoTypeKeyword Keyword,
1617 bool IsDependent, bool IsPack = false,
1618 ConceptDecl *TypeConstraintConcept = nullptr,
1619 ArrayRef<TemplateArgument> TypeConstraintArgs = {},
1620 bool IsCanon = false) const;
1621
1622public:
1623 /// Return the unique reference to the type for the specified type
1624 /// declaration.
1626 const TypeDecl *PrevDecl = nullptr) const {
1627 assert(Decl && "Passed null for Decl param");
1628 if (Decl->TypeForDecl) return QualType(Decl->TypeForDecl, 0);
1629
1630 if (PrevDecl) {
1631 assert(PrevDecl->TypeForDecl && "previous decl has no TypeForDecl");
1632 Decl->TypeForDecl = PrevDecl->TypeForDecl;
1633 return QualType(PrevDecl->TypeForDecl, 0);
1634 }
1635
1636 return getTypeDeclTypeSlow(Decl);
1637 }
1638
1640 QualType Underlying) const;
1641
1642 /// Return the unique reference to the type for the specified
1643 /// typedef-name decl.
1645 QualType Underlying = QualType()) const;
1646
1647 QualType getRecordType(const RecordDecl *Decl) const;
1648
1649 QualType getEnumType(const EnumDecl *Decl) const;
1650
1651 QualType
1653
1655
1656 QualType getAttributedType(attr::Kind attrKind, QualType modifiedType,
1657 QualType equivalentType) const;
1658
1659 QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr,
1660 QualType Wrapped);
1661
1662 QualType
1663 getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl,
1664 unsigned Index,
1665 std::optional<unsigned> PackIndex) const;
1667 unsigned Index, bool Final,
1668 const TemplateArgument &ArgPack);
1669
1670 QualType
1671 getTemplateTypeParmType(unsigned Depth, unsigned Index,
1672 bool ParameterPack,
1673 TemplateTypeParmDecl *ParmDecl = nullptr) const;
1674
1677 QualType Canon = QualType()) const;
1678
1679 QualType
1681 ArrayRef<TemplateArgument> Args) const;
1682
1685 QualType Canon = QualType()) const;
1686
1689 const TemplateArgumentListInfo &Args,
1690 QualType Canon = QualType()) const;
1691
1692 QualType getParenType(QualType NamedType) const;
1693
1695 const IdentifierInfo *MacroII) const;
1696
1698 NestedNameSpecifier *NNS, QualType NamedType,
1699 TagDecl *OwnedTagDecl = nullptr) const;
1702 const IdentifierInfo *Name,
1703 QualType Canon = QualType()) const;
1704
1707 const IdentifierInfo *Name, ArrayRef<TemplateArgumentLoc> Args) const;
1710 const IdentifierInfo *Name, ArrayRef<TemplateArgument> Args) const;
1711
1713
1714 /// Get a template argument list with one argument per template parameter
1715 /// in a template parameter list, such as for the injected class name of
1716 /// a class template.
1719
1720 /// Form a pack expansion type with the given pattern.
1721 /// \param NumExpansions The number of expansions for the pack, if known.
1722 /// \param ExpectPackInType If \c false, we should not expect \p Pattern to
1723 /// contain an unexpanded pack. This only makes sense if the pack
1724 /// expansion is used in a context where the arity is inferred from
1725 /// elsewhere, such as if the pattern contains a placeholder type or
1726 /// if this is the canonical type of another pack expansion type.
1728 std::optional<unsigned> NumExpansions,
1729 bool ExpectPackInType = true);
1730
1732 ObjCInterfaceDecl *PrevDecl = nullptr) const;
1733
1734 /// Legacy interface: cannot provide type arguments or __kindof.
1736 ObjCProtocolDecl * const *Protocols,
1737 unsigned NumProtocols) const;
1738
1740 ArrayRef<QualType> typeArgs,
1742 bool isKindOf) const;
1743
1745 ArrayRef<ObjCProtocolDecl *> protocols) const;
1747 ObjCTypeParamDecl *New) const;
1748
1750
1751 /// QIdProtocolsAdoptObjCObjectProtocols - Checks that protocols in
1752 /// QT's qualified-id protocol list adopt all protocols in IDecl's list
1753 /// of protocols.
1755 ObjCInterfaceDecl *IDecl);
1756
1757 /// Return a ObjCObjectPointerType type for the given ObjCObjectType.
1759
1760 /// C23 feature and GCC extension.
1763
1764 QualType getReferenceQualifiedType(const Expr *e) const;
1765
1766 /// C++11 decltype.
1767 QualType getDecltypeType(Expr *e, QualType UnderlyingType) const;
1768
1769 QualType getPackIndexingType(QualType Pattern, Expr *IndexExpr,
1770 bool FullySubstituted = false,
1771 ArrayRef<QualType> Expansions = {},
1772 int Index = -1) const;
1773
1774 /// Unary type transforms
1775 QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType,
1776 UnaryTransformType::UTTKind UKind) const;
1777
1778 /// C++11 deduced auto type.
1779 QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword,
1780 bool IsDependent, bool IsPack = false,
1781 ConceptDecl *TypeConstraintConcept = nullptr,
1782 ArrayRef<TemplateArgument> TypeConstraintArgs ={}) const;
1783
1784 /// C++11 deduction pattern for 'auto' type.
1785 QualType getAutoDeductType() const;
1786
1787 /// C++11 deduction pattern for 'auto &&' type.
1788 QualType getAutoRRefDeductType() const;
1789
1790 /// Remove any type constraints from a template parameter type, for
1791 /// equivalence comparison of template parameters.
1792 QualType getUnconstrainedType(QualType T) const;
1793
1794 /// C++17 deduced class template specialization type.
1795 QualType getDeducedTemplateSpecializationType(TemplateName Template,
1796 QualType DeducedType,
1797 bool IsDependent) const;
1798
1799private:
1800 QualType getDeducedTemplateSpecializationTypeInternal(TemplateName Template,
1801 QualType DeducedType,
1802 bool IsDependent,
1803 QualType Canon) const;
1804
1805public:
1806 /// Return the unique reference to the type for the specified TagDecl
1807 /// (struct/union/class/enum) decl.
1808 QualType getTagDeclType(const TagDecl *Decl) const;
1809
1810 /// Return the unique type for "size_t" (C99 7.17), defined in
1811 /// <stddef.h>.
1812 ///
1813 /// The sizeof operator requires this (C99 6.5.3.4p4).
1814 CanQualType getSizeType() const;
1815
1816 /// Return the unique signed counterpart of
1817 /// the integer type corresponding to size_t.
1819
1820 /// Return the unique type for "intmax_t" (C99 7.18.1.5), defined in
1821 /// <stdint.h>.
1822 CanQualType getIntMaxType() const;
1823
1824 /// Return the unique type for "uintmax_t" (C99 7.18.1.5), defined in
1825 /// <stdint.h>.
1827
1828 /// Return the unique wchar_t type available in C++ (and available as
1829 /// __wchar_t as a Microsoft extension).
1830 QualType getWCharType() const { return WCharTy; }
1831
1832 /// Return the type of wide characters. In C++, this returns the
1833 /// unique wchar_t type. In C99, this returns a type compatible with the type
1834 /// defined in <stddef.h> as defined by the target.
1836
1837 /// Return the type of "signed wchar_t".
1838 ///
1839 /// Used when in C++, as a GCC extension.
1841
1842 /// Return the type of "unsigned wchar_t".
1843 ///
1844 /// Used when in C++, as a GCC extension.
1846
1847 /// In C99, this returns a type compatible with the type
1848 /// defined in <stddef.h> as defined by the target.
1849 QualType getWIntType() const { return WIntTy; }
1850
1851 /// Return a type compatible with "intptr_t" (C99 7.18.1.4),
1852 /// as defined by the target.
1853 QualType getIntPtrType() const;
1854
1855 /// Return a type compatible with "uintptr_t" (C99 7.18.1.4),
1856 /// as defined by the target.
1857 QualType getUIntPtrType() const;
1858
1859 /// Return the unique type for "ptrdiff_t" (C99 7.17) defined in
1860 /// <stddef.h>. Pointer - pointer requires this (C99 6.5.6p9).
1862
1863 /// Return the unique unsigned counterpart of "ptrdiff_t"
1864 /// integer type. The standard (C11 7.21.6.1p7) refers to this type
1865 /// in the definition of %tu format specifier.
1867
1868 /// Return the unique type for "pid_t" defined in
1869 /// <sys/types.h>. We need this to compute the correct type for vfork().
1870 QualType getProcessIDType() const;
1871
1872 /// Return the C structure type used to represent constant CFStrings.
1874
1875 /// Returns the C struct type for objc_super
1876 QualType getObjCSuperType() const;
1877 void setObjCSuperType(QualType ST) { ObjCSuperType = ST; }
1878
1879 /// Get the structure type used to representation CFStrings, or NULL
1880 /// if it hasn't yet been built.
1882 if (CFConstantStringTypeDecl)
1883 return getTypedefType(CFConstantStringTypeDecl);
1884 return QualType();
1885 }
1889
1890 // This setter/getter represents the ObjC type for an NSConstantString.
1893 return ObjCConstantStringType;
1894 }
1895
1897 return ObjCNSStringType;
1898 }
1899
1901 ObjCNSStringType = T;
1902 }
1903
1904 /// Retrieve the type that \c id has been defined to, which may be
1905 /// different from the built-in \c id if \c id has been typedef'd.
1907 if (ObjCIdRedefinitionType.isNull())
1908 return getObjCIdType();
1909 return ObjCIdRedefinitionType;
1910 }
1911
1912 /// Set the user-written type that redefines \c id.
1914 ObjCIdRedefinitionType = RedefType;
1915 }
1916
1917 /// Retrieve the type that \c Class has been defined to, which may be
1918 /// different from the built-in \c Class if \c Class has been typedef'd.
1920 if (ObjCClassRedefinitionType.isNull())
1921 return getObjCClassType();
1922 return ObjCClassRedefinitionType;
1923 }
1924
1925 /// Set the user-written type that redefines 'SEL'.
1927 ObjCClassRedefinitionType = RedefType;
1928 }
1929
1930 /// Retrieve the type that 'SEL' has been defined to, which may be
1931 /// different from the built-in 'SEL' if 'SEL' has been typedef'd.
1933 if (ObjCSelRedefinitionType.isNull())
1934 return getObjCSelType();
1935 return ObjCSelRedefinitionType;
1936 }
1937
1938 /// Set the user-written type that redefines 'SEL'.
1940 ObjCSelRedefinitionType = RedefType;
1941 }
1942
1943 /// Retrieve the identifier 'NSObject'.
1945 if (!NSObjectName) {
1946 NSObjectName = &Idents.get("NSObject");
1947 }
1948
1949 return NSObjectName;
1950 }
1951
1952 /// Retrieve the identifier 'NSCopying'.
1954 if (!NSCopyingName) {
1955 NSCopyingName = &Idents.get("NSCopying");
1956 }
1957
1958 return NSCopyingName;
1959 }
1960
1962
1964
1965 /// Retrieve the identifier 'bool'.
1967 if (!BoolName)
1968 BoolName = &Idents.get("bool");
1969 return BoolName;
1970 }
1971
1973 if (!MakeIntegerSeqName)
1974 MakeIntegerSeqName = &Idents.get("__make_integer_seq");
1975 return MakeIntegerSeqName;
1976 }
1977
1979 if (!TypePackElementName)
1980 TypePackElementName = &Idents.get("__type_pack_element");
1981 return TypePackElementName;
1982 }
1983
1984 /// Retrieve the Objective-C "instancetype" type, if already known;
1985 /// otherwise, returns a NULL type;
1988 }
1989
1990 /// Retrieve the typedef declaration corresponding to the Objective-C
1991 /// "instancetype" type.
1993
1994 /// Set the type for the C FILE type.
1995 void setFILEDecl(TypeDecl *FILEDecl) { this->FILEDecl = FILEDecl; }
1996
1997 /// Retrieve the C FILE type.
1999 if (FILEDecl)
2000 return getTypeDeclType(FILEDecl);
2001 return QualType();
2002 }
2003
2004 /// Set the type for the C jmp_buf type.
2005 void setjmp_bufDecl(TypeDecl *jmp_bufDecl) {
2006 this->jmp_bufDecl = jmp_bufDecl;
2007 }
2008
2009 /// Retrieve the C jmp_buf type.
2011 if (jmp_bufDecl)
2012 return getTypeDeclType(jmp_bufDecl);
2013 return QualType();
2014 }
2015
2016 /// Set the type for the C sigjmp_buf type.
2017 void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl) {
2018 this->sigjmp_bufDecl = sigjmp_bufDecl;
2019 }
2020
2021 /// Retrieve the C sigjmp_buf type.
2023 if (sigjmp_bufDecl)
2024 return getTypeDeclType(sigjmp_bufDecl);
2025 return QualType();
2026 }
2027
2028 /// Set the type for the C ucontext_t type.
2029 void setucontext_tDecl(TypeDecl *ucontext_tDecl) {
2030 this->ucontext_tDecl = ucontext_tDecl;
2031 }
2032
2033 /// Retrieve the C ucontext_t type.
2035 if (ucontext_tDecl)
2036 return getTypeDeclType(ucontext_tDecl);
2037 return QualType();
2038 }
2039
2040 /// The result type of logical operations, '<', '>', '!=', etc.
2042 return getLangOpts().CPlusPlus ? BoolTy : IntTy;
2043 }
2044
2045 /// Emit the Objective-CC type encoding for the given type \p T into
2046 /// \p S.
2047 ///
2048 /// If \p Field is specified then record field names are also encoded.
2049 void getObjCEncodingForType(QualType T, std::string &S,
2050 const FieldDecl *Field=nullptr,
2051 QualType *NotEncodedT=nullptr) const;
2052
2053 /// Emit the Objective-C property type encoding for the given
2054 /// type \p T into \p S.
2055 void getObjCEncodingForPropertyType(QualType T, std::string &S) const;
2056
2058
2059 /// Put the string version of the type qualifiers \p QT into \p S.
2061 std::string &S) const;
2062
2063 /// Emit the encoded type for the function \p Decl into \p S.
2064 ///
2065 /// This is in the same format as Objective-C method encodings.
2066 ///
2067 /// \returns true if an error occurred (e.g., because one of the parameter
2068 /// types is incomplete), false otherwise.
2069 std::string getObjCEncodingForFunctionDecl(const FunctionDecl *Decl) const;
2070
2071 /// Emit the encoded type for the method declaration \p Decl into
2072 /// \p S.
2074 bool Extended = false) const;
2075
2076 /// Return the encoded type for this block declaration.
2077 std::string getObjCEncodingForBlock(const BlockExpr *blockExpr) const;
2078
2079 /// getObjCEncodingForPropertyDecl - Return the encoded type for
2080 /// this method declaration. If non-NULL, Container must be either
2081 /// an ObjCCategoryImplDecl or ObjCImplementationDecl; it should
2082 /// only be NULL when getting encodings for protocol properties.
2084 const Decl *Container) const;
2085
2087 ObjCProtocolDecl *rProto) const;
2088
2090 const ObjCPropertyDecl *PD,
2091 const Decl *Container) const;
2092
2093 /// Return the size of type \p T for Objective-C encoding purpose,
2094 /// in characters.
2096
2097 /// Retrieve the typedef corresponding to the predefined \c id type
2098 /// in Objective-C.
2099 TypedefDecl *getObjCIdDecl() const;
2100
2101 /// Represents the Objective-CC \c id type.
2102 ///
2103 /// This is set up lazily, by Sema. \c id is always a (typedef for a)
2104 /// pointer type, a pointer to a struct.
2107 }
2108
2109 /// Retrieve the typedef corresponding to the predefined 'SEL' type
2110 /// in Objective-C.
2111 TypedefDecl *getObjCSelDecl() const;
2112
2113 /// Retrieve the type that corresponds to the predefined Objective-C
2114 /// 'SEL' type.
2117 }
2118
2119 /// Retrieve the typedef declaration corresponding to the predefined
2120 /// Objective-C 'Class' type.
2122
2123 /// Represents the Objective-C \c Class type.
2124 ///
2125 /// This is set up lazily, by Sema. \c Class is always a (typedef for a)
2126 /// pointer type, a pointer to a struct.
2129 }
2130
2131 /// Retrieve the Objective-C class declaration corresponding to
2132 /// the predefined \c Protocol class.
2134
2135 /// Retrieve declaration of 'BOOL' typedef
2137 return BOOLDecl;
2138 }
2139
2140 /// Save declaration of 'BOOL' typedef
2142 BOOLDecl = TD;
2143 }
2144
2145 /// type of 'BOOL' type.
2147 return getTypeDeclType(getBOOLDecl());
2148 }
2149
2150 /// Retrieve the type of the Objective-C \c Protocol class.
2153 }
2154
2155 /// Retrieve the C type declaration corresponding to the predefined
2156 /// \c __builtin_va_list type.
2158
2159 /// Retrieve the type of the \c __builtin_va_list type.
2162 }
2163
2164 /// Retrieve the C type declaration corresponding to the predefined
2165 /// \c __va_list_tag type used to help define the \c __builtin_va_list type
2166 /// for some targets.
2167 Decl *getVaListTagDecl() const;
2168
2169 /// Retrieve the C type declaration corresponding to the predefined
2170 /// \c __builtin_ms_va_list type.
2172
2173 /// Retrieve the type of the \c __builtin_ms_va_list type.
2176 }
2177
2178 /// Retrieve the implicitly-predeclared 'struct _GUID' declaration.
2180
2181 /// Retrieve the implicitly-predeclared 'struct _GUID' type.
2183 assert(MSGuidTagDecl && "asked for GUID type but MS extensions disabled");
2185 }
2186
2187 /// Return whether a declaration to a builtin is allowed to be
2188 /// overloaded/redeclared.
2189 bool canBuiltinBeRedeclared(const FunctionDecl *) const;
2190
2191 /// Return a type with additional \c const, \c volatile, or
2192 /// \c restrict qualifiers.
2195 }
2196
2197 /// Un-split a SplitQualType.
2199 return getQualifiedType(split.Ty, split.Quals);
2200 }
2201
2202 /// Return a type with additional qualifiers.
2204 if (!Qs.hasNonFastQualifiers())
2205 return T.withFastQualifiers(Qs.getFastQualifiers());
2206 QualifierCollector Qc(Qs);
2207 const Type *Ptr = Qc.strip(T);
2208 return getExtQualType(Ptr, Qc);
2209 }
2210
2211 /// Return a type with additional qualifiers.
2213 if (!Qs.hasNonFastQualifiers())
2214 return QualType(T, Qs.getFastQualifiers());
2215 return getExtQualType(T, Qs);
2216 }
2217
2218 /// Return a type with the given lifetime qualifier.
2219 ///
2220 /// \pre Neither type.ObjCLifetime() nor \p lifetime may be \c OCL_None.
2222 Qualifiers::ObjCLifetime lifetime) {
2223 assert(type.getObjCLifetime() == Qualifiers::OCL_None);
2224 assert(lifetime != Qualifiers::OCL_None);
2225
2226 Qualifiers qs;
2227 qs.addObjCLifetime(lifetime);
2228 return getQualifiedType(type, qs);
2229 }
2230
2231 /// getUnqualifiedObjCPointerType - Returns version of
2232 /// Objective-C pointer type with lifetime qualifier removed.
2234 if (!type.getTypePtr()->isObjCObjectPointerType() ||
2235 !type.getQualifiers().hasObjCLifetime())
2236 return type;
2237 Qualifiers Qs = type.getQualifiers();
2238 Qs.removeObjCLifetime();
2239 return getQualifiedType(type.getUnqualifiedType(), Qs);
2240 }
2241
2242 /// \brief Return a type with the given __ptrauth qualifier.
2244 assert(!Ty.getPointerAuth());
2245 assert(PointerAuth);
2246
2247 Qualifiers Qs;
2248 Qs.setPointerAuth(PointerAuth);
2249 return getQualifiedType(Ty, Qs);
2250 }
2251
2252 unsigned char getFixedPointScale(QualType Ty) const;
2253 unsigned char getFixedPointIBits(QualType Ty) const;
2254 llvm::FixedPointSemantics getFixedPointSemantics(QualType Ty) const;
2255 llvm::APFixedPoint getFixedPointMax(QualType Ty) const;
2256 llvm::APFixedPoint getFixedPointMin(QualType Ty) const;
2257
2259 SourceLocation NameLoc) const;
2260
2262 UnresolvedSetIterator End) const;
2264
2266 bool TemplateKeyword,
2267 TemplateName Template) const;
2268
2270 const IdentifierInfo *Name) const;
2272 OverloadedOperatorKind Operator) const;
2274 getSubstTemplateTemplateParm(TemplateName replacement, Decl *AssociatedDecl,
2275 unsigned Index,
2276 std::optional<unsigned> PackIndex) const;
2278 Decl *AssociatedDecl,
2279 unsigned Index,
2280 bool Final) const;
2281
2283 /// No error
2285
2286 /// Missing a type
2288
2289 /// Missing a type from <stdio.h>
2291
2292 /// Missing a type from <setjmp.h>
2294
2295 /// Missing a type from <ucontext.h>
2298
2299 QualType DecodeTypeStr(const char *&Str, const ASTContext &Context,
2301 bool &RequireICE, bool AllowTypeModifiers) const;
2302
2303 /// Return the type for the specified builtin.
2304 ///
2305 /// If \p IntegerConstantArgs is non-null, it is filled in with a bitmask of
2306 /// arguments to the builtin that are required to be integer constant
2307 /// expressions.
2309 unsigned *IntegerConstantArgs = nullptr) const;
2310
2311 /// Types and expressions required to build C++2a three-way comparisons
2312 /// using operator<=>, including the values return by builtin <=> operators.
2314
2315private:
2316 CanQualType getFromTargetType(unsigned Type) const;
2317 TypeInfo getTypeInfoImpl(const Type *T) const;
2318
2319 //===--------------------------------------------------------------------===//
2320 // Type Predicates.
2321 //===--------------------------------------------------------------------===//
2322
2323public:
2324 /// Return one of the GCNone, Weak or Strong Objective-C garbage
2325 /// collection attributes.
2327
2328 /// Return true if the given vector types are of the same unqualified
2329 /// type or if they are equivalent to the same GCC vector type.
2330 ///
2331 /// \note This ignores whether they are target-specific (AltiVec or Neon)
2332 /// types.
2333 bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec);
2334
2335 /// Return true if the given types are an SVE builtin and a VectorType that
2336 /// is a fixed-length representation of the SVE builtin for a specific
2337 /// vector-length.
2338 bool areCompatibleSveTypes(QualType FirstType, QualType SecondType);
2339
2340 /// Return true if the given vector types are lax-compatible SVE vector types,
2341 /// false otherwise.
2342 bool areLaxCompatibleSveTypes(QualType FirstType, QualType SecondType);
2343
2344 /// Return true if the given types are an RISC-V vector builtin type and a
2345 /// VectorType that is a fixed-length representation of the RISC-V vector
2346 /// builtin type for a specific vector-length.
2347 bool areCompatibleRVVTypes(QualType FirstType, QualType SecondType);
2348
2349 /// Return true if the given vector types are lax-compatible RISC-V vector
2350 /// types as defined by -flax-vector-conversions=, which permits implicit
2351 /// conversions between vectors with different number of elements and/or
2352 /// incompatible element types, false otherwise.
2353 bool areLaxCompatibleRVVTypes(QualType FirstType, QualType SecondType);
2354
2355 /// Return true if the type has been explicitly qualified with ObjC ownership.
2356 /// A type may be implicitly qualified with ownership under ObjC ARC, and in
2357 /// some cases the compiler treats these differently.
2359
2360 /// Return true if this is an \c NSObject object with its \c NSObject
2361 /// attribute set.
2363 return Ty->isObjCNSObjectType();
2364 }
2365
2366 //===--------------------------------------------------------------------===//
2367 // Type Sizing and Analysis
2368 //===--------------------------------------------------------------------===//
2369
2370 /// Return the APFloat 'semantics' for the specified scalar floating
2371 /// point type.
2372 const llvm::fltSemantics &getFloatTypeSemantics(QualType T) const;
2373
2374 /// Get the size and alignment of the specified complete type in bits.
2375 TypeInfo getTypeInfo(const Type *T) const;
2376 TypeInfo getTypeInfo(QualType T) const { return getTypeInfo(T.getTypePtr()); }
2377
2378 /// Get default simd alignment of the specified complete type in bits.
2379 unsigned getOpenMPDefaultSimdAlign(QualType T) const;
2380
2381 /// Return the size of the specified (complete) type \p T, in bits.
2382 uint64_t getTypeSize(QualType T) const { return getTypeInfo(T).Width; }
2383 uint64_t getTypeSize(const Type *T) const { return getTypeInfo(T).Width; }
2384
2385 /// Return the size of the character type, in bits.
2386 uint64_t getCharWidth() const {
2387 return getTypeSize(CharTy);
2388 }
2389
2390 /// Convert a size in bits to a size in characters.
2391 CharUnits toCharUnitsFromBits(int64_t BitSize) const;
2392
2393 /// Convert a size in characters to a size in bits.
2394 int64_t toBits(CharUnits CharSize) const;
2395
2396 /// Return the size of the specified (complete) type \p T, in
2397 /// characters.
2399 CharUnits getTypeSizeInChars(const Type *T) const;
2400
2401 std::optional<CharUnits> getTypeSizeInCharsIfKnown(QualType Ty) const {
2402 if (Ty->isIncompleteType() || Ty->isDependentType())
2403 return std::nullopt;
2404 return getTypeSizeInChars(Ty);
2405 }
2406
2407 std::optional<CharUnits> getTypeSizeInCharsIfKnown(const Type *Ty) const {
2408 return getTypeSizeInCharsIfKnown(QualType(Ty, 0));
2409 }
2410
2411 /// Return the ABI-specified alignment of a (complete) type \p T, in
2412 /// bits.
2413 unsigned getTypeAlign(QualType T) const { return getTypeInfo(T).Align; }
2414 unsigned getTypeAlign(const Type *T) const { return getTypeInfo(T).Align; }
2415
2416 /// Return the ABI-specified natural alignment of a (complete) type \p T,
2417 /// before alignment adjustments, in bits.
2418 ///
2419 /// This alignment is curently used only by ARM and AArch64 when passing
2420 /// arguments of a composite type.
2422 return getTypeUnadjustedAlign(T.getTypePtr());
2423 }
2424 unsigned getTypeUnadjustedAlign(const Type *T) const;
2425
2426 /// Return the alignment of a type, in bits, or 0 if
2427 /// the type is incomplete and we cannot determine the alignment (for
2428 /// example, from alignment attributes). The returned alignment is the
2429 /// Preferred alignment if NeedsPreferredAlignment is true, otherwise is the
2430 /// ABI alignment.
2432 bool NeedsPreferredAlignment = false) const;
2433
2434 /// Return the ABI-specified alignment of a (complete) type \p T, in
2435 /// characters.
2437 CharUnits getTypeAlignInChars(const Type *T) const;
2438
2439 /// Return the PreferredAlignment of a (complete) type \p T, in
2440 /// characters.
2443 }
2444
2445 /// getTypeUnadjustedAlignInChars - Return the ABI-specified alignment of a type,
2446 /// in characters, before alignment adjustments. This method does not work on
2447 /// incomplete types.
2450
2451 // getTypeInfoDataSizeInChars - Return the size of a type, in chars. If the
2452 // type is a record, its data size is returned.
2454
2455 TypeInfoChars getTypeInfoInChars(const Type *T) const;
2457
2458 /// Determine if the alignment the type has was required using an
2459 /// alignment attribute.
2460 bool isAlignmentRequired(const Type *T) const;
2461 bool isAlignmentRequired(QualType T) const;
2462
2463 /// More type predicates useful for type checking/promotion
2464 bool isPromotableIntegerType(QualType T) const; // C99 6.3.1.1p2
2465
2466 /// Return the "preferred" alignment of the specified type \p T for
2467 /// the current target, in bits.
2468 ///
2469 /// This can be different than the ABI alignment in cases where it is
2470 /// beneficial for performance or backwards compatibility preserving to
2471 /// overalign a data type. (Note: despite the name, the preferred alignment
2472 /// is ABI-impacting, and not an optimization.)
2474 return getPreferredTypeAlign(T.getTypePtr());
2475 }
2476 unsigned getPreferredTypeAlign(const Type *T) const;
2477
2478 /// Return the default alignment for __attribute__((aligned)) on
2479 /// this target, to be used if no alignment value is specified.
2481
2482 /// Return the alignment in bits that should be given to a
2483 /// global variable with type \p T. If \p VD is non-null it will be
2484 /// considered specifically for the query.
2485 unsigned getAlignOfGlobalVar(QualType T, const VarDecl *VD) const;
2486
2487 /// Return the alignment in characters that should be given to a
2488 /// global variable with type \p T. If \p VD is non-null it will be
2489 /// considered specifically for the query.
2491
2492 /// Return the minimum alignement as specified by the target. If \p VD is
2493 /// non-null it may be used to identify external or weak variables.
2494 unsigned getMinGlobalAlignOfVar(uint64_t Size, const VarDecl *VD) const;
2495
2496 /// Return a conservative estimate of the alignment of the specified
2497 /// decl \p D.
2498 ///
2499 /// \pre \p D must not be a bitfield type, as bitfields do not have a valid
2500 /// alignment.
2501 ///
2502 /// If \p ForAlignof, references are treated like their underlying type
2503 /// and large arrays don't get any special treatment. If not \p ForAlignof
2504 /// it computes the value expected by CodeGen: references are treated like
2505 /// pointers and large arrays get extra alignment.
2506 CharUnits getDeclAlign(const Decl *D, bool ForAlignof = false) const;
2507
2508 /// Return the alignment (in bytes) of the thrown exception object. This is
2509 /// only meaningful for targets that allocate C++ exceptions in a system
2510 /// runtime, such as those using the Itanium C++ ABI.
2512
2513 /// Get or compute information about the layout of the specified
2514 /// record (struct/union/class) \p D, which indicates its size and field
2515 /// position information.
2516 const ASTRecordLayout &getASTRecordLayout(const RecordDecl *D) const;
2517
2518 /// Get or compute information about the layout of the specified
2519 /// Objective-C interface.
2521 const;
2522
2523 void DumpRecordLayout(const RecordDecl *RD, raw_ostream &OS,
2524 bool Simple = false) const;
2525
2526 /// Get or compute information about the layout of the specified
2527 /// Objective-C implementation.
2528 ///
2529 /// This may differ from the interface if synthesized ivars are present.
2530 const ASTRecordLayout &
2532
2533 /// Get our current best idea for the key function of the
2534 /// given record decl, or nullptr if there isn't one.
2535 ///
2536 /// The key function is, according to the Itanium C++ ABI section 5.2.3:
2537 /// ...the first non-pure virtual function that is not inline at the
2538 /// point of class definition.
2539 ///
2540 /// Other ABIs use the same idea. However, the ARM C++ ABI ignores
2541 /// virtual functions that are defined 'inline', which means that
2542 /// the result of this computation can change.
2544
2545 /// Observe that the given method cannot be a key function.
2546 /// Checks the key-function cache for the method's class and clears it
2547 /// if matches the given declaration.
2548 ///
2549 /// This is used in ABIs where out-of-line definitions marked
2550 /// inline are not considered to be key functions.
2551 ///
2552 /// \param method should be the declaration from the class definition
2553 void setNonKeyFunction(const CXXMethodDecl *method);
2554
2555 /// Loading virtual member pointers using the virtual inheritance model
2556 /// always results in an adjustment using the vbtable even if the index is
2557 /// zero.
2558 ///
2559 /// This is usually OK because the first slot in the vbtable points
2560 /// backwards to the top of the MDC. However, the MDC might be reusing a
2561 /// vbptr from an nv-base. In this case, the first slot in the vbtable
2562 /// points to the start of the nv-base which introduced the vbptr and *not*
2563 /// the MDC. Modify the NonVirtualBaseAdjustment to account for this.
2565
2566 /// Get the offset of a FieldDecl or IndirectFieldDecl, in bits.
2567 uint64_t getFieldOffset(const ValueDecl *FD) const;
2568
2569 /// Get the offset of an ObjCIvarDecl in bits.
2570 uint64_t lookupFieldBitOffset(const ObjCInterfaceDecl *OID,
2572 const ObjCIvarDecl *Ivar) const;
2573
2574 /// Find the 'this' offset for the member path in a pointer-to-member
2575 /// APValue.
2577
2578 bool isNearlyEmpty(const CXXRecordDecl *RD) const;
2579
2581
2582 /// If \p T is null pointer, assume the target in ASTContext.
2583 MangleContext *createMangleContext(const TargetInfo *T = nullptr);
2584
2585 /// Creates a device mangle context to correctly mangle lambdas in a mixed
2586 /// architecture compile by setting the lambda mangling number source to the
2587 /// DeviceLambdaManglingNumber. Currently this asserts that the TargetInfo
2588 /// (from the AuxTargetInfo) is a an itanium target.
2590
2591 void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass,
2593
2594 unsigned CountNonClassIvars(const ObjCInterfaceDecl *OI) const;
2595 void CollectInheritedProtocols(const Decl *CDecl,
2597
2598 /// Return true if the specified type has unique object representations
2599 /// according to (C++17 [meta.unary.prop]p9)
2600 bool
2602 bool CheckIfTriviallyCopyable = true) const;
2603
2604 //===--------------------------------------------------------------------===//
2605 // Type Operators
2606 //===--------------------------------------------------------------------===//
2607
2608 /// Return the canonical (structural) type corresponding to the
2609 /// specified potentially non-canonical type \p T.
2610 ///
2611 /// The non-canonical version of a type may have many "decorated" versions of
2612 /// types. Decorators can include typedefs, 'typeof' operators, etc. The
2613 /// returned type is guaranteed to be free of any of these, allowing two
2614 /// canonical types to be compared for exact equality with a simple pointer
2615 /// comparison.
2617 return CanQualType::CreateUnsafe(T.getCanonicalType());
2618 }
2619
2620 const Type *getCanonicalType(const Type *T) const {
2622 }
2623
2624 /// Return the canonical parameter type corresponding to the specific
2625 /// potentially non-canonical one.
2626 ///
2627 /// Qualifiers are stripped off, functions are turned into function
2628 /// pointers, and arrays decay one level into pointers.
2630
2631 /// Determine whether the given types \p T1 and \p T2 are equivalent.
2632 bool hasSameType(QualType T1, QualType T2) const {
2633 return getCanonicalType(T1) == getCanonicalType(T2);
2634 }
2635 bool hasSameType(const Type *T1, const Type *T2) const {
2636 return getCanonicalType(T1) == getCanonicalType(T2);
2637 }
2638
2639 /// Determine whether the given expressions \p X and \p Y are equivalent.
2640 bool hasSameExpr(const Expr *X, const Expr *Y) const;
2641
2642 /// Return this type as a completely-unqualified array type,
2643 /// capturing the qualifiers in \p Quals.
2644 ///
2645 /// This will remove the minimal amount of sugaring from the types, similar
2646 /// to the behavior of QualType::getUnqualifiedType().
2647 ///
2648 /// \param T is the qualified type, which may be an ArrayType
2649 ///
2650 /// \param Quals will receive the full set of qualifiers that were
2651 /// applied to the array.
2652 ///
2653 /// \returns if this is an array type, the completely unqualified array type
2654 /// that corresponds to it. Otherwise, returns T.getUnqualifiedType().
2656
2657 /// Determine whether the given types are equivalent after
2658 /// cvr-qualifiers have been removed.
2660 return getCanonicalType(T1).getTypePtr() ==
2662 }
2663
2665 bool IsParam) const {
2666 auto SubTnullability = SubT->getNullability();
2667 auto SuperTnullability = SuperT->getNullability();
2668 if (SubTnullability.has_value() == SuperTnullability.has_value()) {
2669 // Neither has nullability; return true
2670 if (!SubTnullability)
2671 return true;
2672 // Both have nullability qualifier.
2673 if (*SubTnullability == *SuperTnullability ||
2674 *SubTnullability == NullabilityKind::Unspecified ||
2675 *SuperTnullability == NullabilityKind::Unspecified)
2676 return true;
2677
2678 if (IsParam) {
2679 // Ok for the superclass method parameter to be "nonnull" and the subclass
2680 // method parameter to be "nullable"
2681 return (*SuperTnullability == NullabilityKind::NonNull &&
2682 *SubTnullability == NullabilityKind::Nullable);
2683 }
2684 // For the return type, it's okay for the superclass method to specify
2685 // "nullable" and the subclass method specify "nonnull"
2686 return (*SuperTnullability == NullabilityKind::Nullable &&
2687 *SubTnullability == NullabilityKind::NonNull);
2688 }
2689 return true;
2690 }
2691
2692 bool ObjCMethodsAreEqual(const ObjCMethodDecl *MethodDecl,
2693 const ObjCMethodDecl *MethodImp);
2694
2695 bool UnwrapSimilarTypes(QualType &T1, QualType &T2,
2696 bool AllowPiMismatch = true);
2698 bool AllowPiMismatch = true);
2699
2700 /// Determine if two types are similar, according to the C++ rules. That is,
2701 /// determine if they are the same other than qualifiers on the initial
2702 /// sequence of pointer / pointer-to-member / array (and in Clang, object
2703 /// pointer) types and their element types.
2704 ///
2705 /// Clang offers a number of qualifiers in addition to the C++ qualifiers;
2706 /// those qualifiers are also ignored in the 'similarity' check.
2707 bool hasSimilarType(QualType T1, QualType T2);
2708
2709 /// Determine if two types are similar, ignoring only CVR qualifiers.
2710 bool hasCvrSimilarType(QualType T1, QualType T2);
2711
2712 /// Retrieves the "canonical" nested name specifier for a
2713 /// given nested name specifier.
2714 ///
2715 /// The canonical nested name specifier is a nested name specifier
2716 /// that uniquely identifies a type or namespace within the type
2717 /// system. For example, given:
2718 ///
2719 /// \code
2720 /// namespace N {
2721 /// struct S {
2722 /// template<typename T> struct X { typename T* type; };
2723 /// };
2724 /// }
2725 ///
2726 /// template<typename T> struct Y {
2727 /// typename N::S::X<T>::type member;
2728 /// };
2729 /// \endcode
2730 ///
2731 /// Here, the nested-name-specifier for N::S::X<T>:: will be
2732 /// S::X<template-param-0-0>, since 'S' and 'X' are uniquely defined
2733 /// by declarations in the type system and the canonical type for
2734 /// the template type parameter 'T' is template-param-0-0.
2737
2738 /// Retrieves the default calling convention for the current target.
2740 bool IsCXXMethod,
2741 bool IsBuiltin = false) const;
2742
2743 /// Retrieves the "canonical" template name that refers to a
2744 /// given template.
2745 ///
2746 /// The canonical template name is the simplest expression that can
2747 /// be used to refer to a given template. For most templates, this
2748 /// expression is just the template declaration itself. For example,
2749 /// the template std::vector can be referred to via a variety of
2750 /// names---std::vector, \::std::vector, vector (if vector is in
2751 /// scope), etc.---but all of these names map down to the same
2752 /// TemplateDecl, which is used to form the canonical template name.
2753 ///
2754 /// Dependent template names are more interesting. Here, the
2755 /// template name could be something like T::template apply or
2756 /// std::allocator<T>::template rebind, where the nested name
2757 /// specifier itself is dependent. In this case, the canonical
2758 /// template name uses the shortest form of the dependent
2759 /// nested-name-specifier, which itself contains all canonical
2760 /// types, values, and templates.
2762
2763 /// Determine whether the given template names refer to the same
2764 /// template.
2765 bool hasSameTemplateName(const TemplateName &X, const TemplateName &Y) const;
2766
2767 /// Determine whether the two declarations refer to the same entity.
2768 bool isSameEntity(const NamedDecl *X, const NamedDecl *Y) const;
2769
2770 /// Determine whether two template parameter lists are similar enough
2771 /// that they may be used in declarations of the same template.
2773 const TemplateParameterList *Y) const;
2774
2775 /// Determine whether two template parameters are similar enough
2776 /// that they may be used in declarations of the same template.
2777 bool isSameTemplateParameter(const NamedDecl *X, const NamedDecl *Y) const;
2778
2779 /// Determine whether two 'requires' expressions are similar enough that they
2780 /// may be used in re-declarations.
2781 ///
2782 /// Use of 'requires' isn't mandatory, works with constraints expressed in
2783 /// other ways too.
2784 bool isSameConstraintExpr(const Expr *XCE, const Expr *YCE) const;
2785
2786 /// Determine whether two type contraint are similar enough that they could
2787 /// used in declarations of the same template.
2788 bool isSameTypeConstraint(const TypeConstraint *XTC,
2789 const TypeConstraint *YTC) const;
2790
2791 /// Determine whether two default template arguments are similar enough
2792 /// that they may be used in declarations of the same template.
2794 const NamedDecl *Y) const;
2795
2796 /// Retrieve the "canonical" template argument.
2797 ///
2798 /// The canonical template argument is the simplest template argument
2799 /// (which may be a type, value, expression, or declaration) that
2800 /// expresses the value of the argument.
2802 const;
2803
2804 /// Type Query functions. If the type is an instance of the specified class,
2805 /// return the Type pointer for the underlying maximally pretty type. This
2806 /// is a member of ASTContext because this may need to do some amount of
2807 /// canonicalization, e.g. to move type qualifiers into the element type.
2808 const ArrayType *getAsArrayType(QualType T) const;
2810 return dyn_cast_or_null<ConstantArrayType>(getAsArrayType(T));
2811 }
2813 return dyn_cast_or_null<VariableArrayType>(getAsArrayType(T));
2814 }
2816 return dyn_cast_or_null<IncompleteArrayType>(getAsArrayType(T));
2817 }
2819 const {
2820 return dyn_cast_or_null<DependentSizedArrayType>(getAsArrayType(T));
2821 }
2822
2823 /// Return the innermost element type of an array type.
2824 ///
2825 /// For example, will return "int" for int[m][n]
2826 QualType getBaseElementType(const ArrayType *VAT) const;
2827
2828 /// Return the innermost element type of a type (which needn't
2829 /// actually be an array type).
2831
2832 /// Return number of constant array elements.
2833 uint64_t getConstantArrayElementCount(const ConstantArrayType *CA) const;
2834
2835 /// Return number of elements initialized in an ArrayInitLoopExpr.
2836 uint64_t
2838
2839 /// Perform adjustment on the parameter type of a function.
2840 ///
2841 /// This routine adjusts the given parameter type @p T to the actual
2842 /// parameter type used by semantic analysis (C99 6.7.5.3p[7,8],
2843 /// C++ [dcl.fct]p3). The adjusted parameter type is returned.
2845
2846 /// Retrieve the parameter type as adjusted for use in the signature
2847 /// of a function, decaying array and function types and removing top-level
2848 /// cv-qualifiers.
2850
2852
2853 /// Return the properly qualified result of decaying the specified
2854 /// array type to a pointer.
2855 ///
2856 /// This operation is non-trivial when handling typedefs etc. The canonical
2857 /// type of \p T must be an array type, this returns a pointer to a properly
2858 /// qualified element of the array.
2859 ///
2860 /// See C99 6.7.5.3p7 and C99 6.3.2.1p3.
2862
2863 /// Return the type that \p PromotableType will promote to: C99
2864 /// 6.3.1.1p2, assuming that \p PromotableType is a promotable integer type.
2865 QualType getPromotedIntegerType(QualType PromotableType) const;
2866
2867 /// Recurses in pointer/array types until it finds an Objective-C
2868 /// retainable type and returns its ownership.
2870
2871 /// Whether this is a promotable bitfield reference according
2872 /// to C99 6.3.1.1p2, bullet 2 (and GCC extensions).
2873 ///
2874 /// \returns the type this bit-field will promote to, or NULL if no
2875 /// promotion occurs.
2877
2878 /// Return the highest ranked integer type, see C99 6.3.1.8p1.
2879 ///
2880 /// If \p LHS > \p RHS, returns 1. If \p LHS == \p RHS, returns 0. If
2881 /// \p LHS < \p RHS, return -1.
2882 int getIntegerTypeOrder(QualType LHS, QualType RHS) const;
2883
2884 /// Compare the rank of the two specified floating point types,
2885 /// ignoring the domain of the type (i.e. 'double' == '_Complex double').
2886 ///
2887 /// If \p LHS > \p RHS, returns 1. If \p LHS == \p RHS, returns 0. If
2888 /// \p LHS < \p RHS, return -1.
2889 int getFloatingTypeOrder(QualType LHS, QualType RHS) const;
2890
2891 /// Compare the rank of two floating point types as above, but compare equal
2892 /// if both types have the same floating-point semantics on the target (i.e.
2893 /// long double and double on AArch64 will return 0).
2895
2896 unsigned getTargetAddressSpace(LangAS AS) const;
2897
2898 LangAS getLangASForBuiltinAddressSpace(unsigned AS) const;
2899
2900 /// Get target-dependent integer value for null pointer which is used for
2901 /// constant folding.
2902 uint64_t getTargetNullPointerValue(QualType QT) const;
2903
2905 return AddrSpaceMapMangling || isTargetAddressSpace(AS);
2906 }
2907
2908 // Merges two exception specifications, such that the resulting
2909 // exception spec is the union of both. For example, if either
2910 // of them can throw something, the result can throw it as well.
2914 SmallVectorImpl<QualType> &ExceptionTypeStorage,
2915 bool AcceptDependent);
2916
2917 // For two "same" types, return a type which has
2918 // the common sugar between them. If Unqualified is true,
2919 // both types need only be the same unqualified type.
2920 // The result will drop the qualifiers which do not occur
2921 // in both types.
2923 bool Unqualified = false);
2924
2925private:
2926 // Helper for integer ordering
2927 unsigned getIntegerRank(const Type *T) const;
2928
2929public:
2930 //===--------------------------------------------------------------------===//
2931 // Type Compatibility Predicates
2932 //===--------------------------------------------------------------------===//
2933
2934 /// Compatibility predicates used to check assignment expressions.
2936 bool CompareUnqualified = false); // C99 6.2.7p1
2937
2940
2942 if (const auto *ET = dyn_cast<ElaboratedType>(T))
2943 T = ET->getNamedType();
2944 return T == getObjCIdType();
2945 }
2946
2948 if (const auto *ET = dyn_cast<ElaboratedType>(T))
2949 T = ET->getNamedType();
2950 return T == getObjCClassType();
2951 }
2952
2954 if (const auto *ET = dyn_cast<ElaboratedType>(T))
2955 T = ET->getNamedType();
2956 return T == getObjCSelType();
2957 }
2958
2960 const ObjCObjectPointerType *RHS,
2961 bool ForCompare);
2962
2964 const ObjCObjectPointerType *RHS);
2965
2966 // Check the safety of assignment from LHS to RHS
2968 const ObjCObjectPointerType *RHSOPT);
2970 const ObjCObjectType *RHS);
2972 const ObjCObjectPointerType *LHSOPT,
2973 const ObjCObjectPointerType *RHSOPT,
2974 bool BlockReturnType);
2977 const ObjCObjectPointerType *RHSOPT);
2979
2980 // Functions for calculating composite types
2981 QualType mergeTypes(QualType, QualType, bool OfBlockPointer = false,
2982 bool Unqualified = false, bool BlockReturnType = false,
2983 bool IsConditionalOperator = false);
2984 QualType mergeFunctionTypes(QualType, QualType, bool OfBlockPointer = false,
2985 bool Unqualified = false, bool AllowCXX = false,
2986 bool IsConditionalOperator = false);
2988 bool OfBlockPointer = false,
2989 bool Unqualified = false);
2991 bool OfBlockPointer=false,
2992 bool Unqualified = false);
2993
2995
2996 /// This function merges the ExtParameterInfo lists of two functions. It
2997 /// returns true if the lists are compatible. The merged list is returned in
2998 /// NewParamInfos.
2999 ///
3000 /// \param FirstFnType The type of the first function.
3001 ///
3002 /// \param SecondFnType The type of the second function.
3003 ///
3004 /// \param CanUseFirst This flag is set to true if the first function's
3005 /// ExtParameterInfo list can be used as the composite list of
3006 /// ExtParameterInfo.
3007 ///
3008 /// \param CanUseSecond This flag is set to true if the second function's
3009 /// ExtParameterInfo list can be used as the composite list of
3010 /// ExtParameterInfo.
3011 ///
3012 /// \param NewParamInfos The composite list of ExtParameterInfo. The list is
3013 /// empty if none of the flags are set.
3014 ///
3016 const FunctionProtoType *FirstFnType,
3017 const FunctionProtoType *SecondFnType,
3018 bool &CanUseFirst, bool &CanUseSecond,
3020
3021 void ResetObjCLayout(const ObjCContainerDecl *CD);
3022
3023 //===--------------------------------------------------------------------===//
3024 // Integer Predicates
3025 //===--------------------------------------------------------------------===//
3026
3027 // The width of an integer, as defined in C99 6.2.6.2. This is the number
3028 // of bits in an integer type excluding any padding bits.
3029 unsigned getIntWidth(QualType T) const;
3030
3031 // Per C99 6.2.5p6, for every signed integer type, there is a corresponding
3032 // unsigned integer type. This method takes a signed type, and returns the
3033 // corresponding unsigned integer type.
3034 // With the introduction of fixed point types in ISO N1169, this method also
3035 // accepts fixed point types and returns the corresponding unsigned type for
3036 // a given fixed point type.
3038
3039 // Per C99 6.2.5p6, for every signed integer type, there is a corresponding
3040 // unsigned integer type. This method takes an unsigned type, and returns the
3041 // corresponding signed integer type.
3042 // With the introduction of fixed point types in ISO N1169, this method also
3043 // accepts fixed point types and returns the corresponding signed type for
3044 // a given fixed point type.
3046
3047 // Per ISO N1169, this method accepts fixed point types and returns the
3048 // corresponding saturated type for a given fixed point type.
3050
3051 // Per ISO N1169, this method accepts fixed point types and returns the
3052 // corresponding non-saturated type for a given fixed point type.
3054
3055 // This method accepts fixed point types and returns the corresponding signed
3056 // type. Unlike getCorrespondingUnsignedType(), this only accepts unsigned
3057 // fixed point types because there are unsigned integer types like bool and
3058 // char8_t that don't have signed equivalents.
3060
3061 //===--------------------------------------------------------------------===//
3062 // Integer Values
3063 //===--------------------------------------------------------------------===//
3064
3065 /// Make an APSInt of the appropriate width and signedness for the
3066 /// given \p Value and integer \p Type.
3067 llvm::APSInt MakeIntValue(uint64_t Value, QualType Type) const {
3068 // If Type is a signed integer type larger than 64 bits, we need to be sure
3069 // to sign extend Res appropriately.
3070 llvm::APSInt Res(64, !Type->isSignedIntegerOrEnumerationType());
3071 Res = Value;
3072 unsigned Width = getIntWidth(Type);
3073 if (Width != Res.getBitWidth())
3074 return Res.extOrTrunc(Width);
3075 return Res;
3076 }
3077
3078 bool isSentinelNullExpr(const Expr *E);
3079
3080 /// Get the implementation of the ObjCInterfaceDecl \p D, or nullptr if
3081 /// none exists.
3083
3084 /// Get the implementation of the ObjCCategoryDecl \p D, or nullptr if
3085 /// none exists.
3087
3088 /// Return true if there is at least one \@implementation in the TU.
3090 return !ObjCImpls.empty();
3091 }
3092
3093 /// Set the implementation of ObjCInterfaceDecl.
3095 ObjCImplementationDecl *ImplD);
3096
3097 /// Set the implementation of ObjCCategoryDecl.
3099 ObjCCategoryImplDecl *ImplD);
3100
3101 /// Get the duplicate declaration of a ObjCMethod in the same
3102 /// interface, or null if none exists.
3103 const ObjCMethodDecl *
3105
3107 const ObjCMethodDecl *Redecl);
3108
3109 /// Returns the Objective-C interface that \p ND belongs to if it is
3110 /// an Objective-C method/property/ivar etc. that is part of an interface,
3111 /// otherwise returns null.
3113
3114 /// Set the copy initialization expression of a block var decl. \p CanThrow
3115 /// indicates whether the copy expression can throw or not.
3116 void setBlockVarCopyInit(const VarDecl* VD, Expr *CopyExpr, bool CanThrow);
3117
3118 /// Get the copy initialization expression of the VarDecl \p VD, or
3119 /// nullptr if none exists.
3121
3122 /// Allocate an uninitialized TypeSourceInfo.
3123 ///
3124 /// The caller should initialize the memory held by TypeSourceInfo using
3125 /// the TypeLoc wrappers.
3126 ///
3127 /// \param T the type that will be the basis for type source info. This type
3128 /// should refer to how the declarator was written in source code, not to
3129 /// what type semantic analysis resolved the declarator to.
3130 ///
3131 /// \param Size the size of the type info to create, or 0 if the size
3132 /// should be calculated based on the type.
3133 TypeSourceInfo *CreateTypeSourceInfo(QualType T, unsigned Size = 0) const;
3134
3135 /// Allocate a TypeSourceInfo where all locations have been
3136 /// initialized to a given location, which defaults to the empty
3137 /// location.
3141
3142 /// Add a deallocation callback that will be invoked when the
3143 /// ASTContext is destroyed.
3144 ///
3145 /// \param Callback A callback function that will be invoked on destruction.
3146 ///
3147 /// \param Data Pointer data that will be provided to the callback function
3148 /// when it is called.
3149 void AddDeallocation(void (*Callback)(void *), void *Data) const;
3150
3151 /// If T isn't trivially destructible, calls AddDeallocation to register it
3152 /// for destruction.
3153 template <typename T> void addDestruction(T *Ptr) const {
3154 if (!std::is_trivially_destructible<T>::value) {
3155 auto DestroyPtr = [](void *V) { static_cast<T *>(V)->~T(); };
3156 AddDeallocation(DestroyPtr, Ptr);
3157 }
3158 }
3159
3162
3163 /// Determines if the decl can be CodeGen'ed or deserialized from PCH
3164 /// lazily, only when used; this is only relevant for function or file scoped
3165 /// var definitions.
3166 ///
3167 /// \returns true if the function/var must be CodeGen'ed/deserialized even if
3168 /// it is not used.
3169 bool DeclMustBeEmitted(const Decl *D);
3170
3171 /// Visits all versions of a multiversioned function with the passed
3172 /// predicate.
3174 const FunctionDecl *FD,
3175 llvm::function_ref<void(FunctionDecl *)> Pred) const;
3176
3177 const CXXConstructorDecl *
3179
3181 CXXConstructorDecl *CD);
3182
3184
3186
3188
3190
3191 void setManglingNumber(const NamedDecl *ND, unsigned Number);
3192 unsigned getManglingNumber(const NamedDecl *ND,
3193 bool ForAuxTarget = false) const;
3194
3195 void setStaticLocalNumber(const VarDecl *VD, unsigned Number);
3196 unsigned getStaticLocalNumber(const VarDecl *VD) const;
3197
3198 /// Retrieve the context for computing mangling numbers in the given
3199 /// DeclContext.
3203 const Decl *D);
3204
3205 std::unique_ptr<MangleNumberingContext> createMangleNumberingContext() const;
3206
3207 /// Used by ParmVarDecl to store on the side the
3208 /// index of the parameter when it exceeds the size of the normal bitfield.
3209 void setParameterIndex(const ParmVarDecl *D, unsigned index);
3210
3211 /// Used by ParmVarDecl to retrieve on the side the
3212 /// index of the parameter when it exceeds the size of the normal bitfield.
3213 unsigned getParameterIndex(const ParmVarDecl *D) const;
3214
3215 /// Return a string representing the human readable name for the specified
3216 /// function declaration or file name. Used by SourceLocExpr and
3217 /// PredefinedExpr to cache evaluated results.
3219
3220 /// Return a declaration for the global GUID object representing the given
3221 /// GUID value.
3223
3224 /// Return a declaration for a uniquified anonymous global constant
3225 /// corresponding to a given APValue.
3228
3229 /// Return the template parameter object of the given type with the given
3230 /// value.
3232 const APValue &V) const;
3233
3234 /// Parses the target attributes passed in, and returns only the ones that are
3235 /// valid feature names.
3236 ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD) const;
3237
3238 void getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap,
3239 const FunctionDecl *) const;
3240 void getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap,
3241 GlobalDecl GD) const;
3242
3243 //===--------------------------------------------------------------------===//
3244 // Statistics
3245 //===--------------------------------------------------------------------===//
3246
3247 /// The number of implicitly-declared default constructors.
3249
3250 /// The number of implicitly-declared default constructors for
3251 /// which declarations were built.
3253
3254 /// The number of implicitly-declared copy constructors.
3256
3257 /// The number of implicitly-declared copy constructors for
3258 /// which declarations were built.
3260
3261 /// The number of implicitly-declared move constructors.
3263
3264 /// The number of implicitly-declared move constructors for
3265 /// which declarations were built.
3267
3268 /// The number of implicitly-declared copy assignment operators.
3270
3271 /// The number of implicitly-declared copy assignment operators for
3272 /// which declarations were built.
3274
3275 /// The number of implicitly-declared move assignment operators.
3277
3278 /// The number of implicitly-declared move assignment operators for
3279 /// which declarations were built.
3281
3282 /// The number of implicitly-declared destructors.
3284
3285 /// The number of implicitly-declared destructors for which
3286 /// declarations were built.
3288
3289public:
3290 /// Initialize built-in types.
3291 ///
3292 /// This routine may only be invoked once for a given ASTContext object.
3293 /// It is normally invoked after ASTContext construction.
3294 ///
3295 /// \param Target The target
3297 const TargetInfo *AuxTarget = nullptr);
3298
3299private:
3300 void InitBuiltinType(CanQualType &R, BuiltinType::Kind K);
3301
3302 class ObjCEncOptions {
3303 unsigned Bits;
3304
3305 ObjCEncOptions(unsigned Bits) : Bits(Bits) {}
3306
3307 public:
3308 ObjCEncOptions() : Bits(0) {}
3309
3310#define OPT_LIST(V) \
3311 V(ExpandPointedToStructures, 0) \
3312 V(ExpandStructures, 1) \
3313 V(IsOutermostType, 2) \
3314 V(EncodingProperty, 3) \
3315 V(IsStructField, 4) \
3316 V(EncodeBlockParameters, 5) \
3317 V(EncodeClassNames, 6) \
3318
3319#define V(N,I) ObjCEncOptions& set##N() { Bits |= 1 << I; return *this; }
3320OPT_LIST(V)
3321#undef V
3322
3323#define V(N,I) bool N() const { return Bits & 1 << I; }
3324OPT_LIST(V)
3325#undef V
3326
3327#undef OPT_LIST
3328
3329 [[nodiscard]] ObjCEncOptions keepingOnly(ObjCEncOptions Mask) const {
3330 return Bits & Mask.Bits;
3331 }
3332
3333 [[nodiscard]] ObjCEncOptions forComponentType() const {
3334 ObjCEncOptions Mask = ObjCEncOptions()
3335 .setIsOutermostType()
3336 .setIsStructField();
3337 return Bits & ~Mask.Bits;
3338 }
3339 };
3340
3341 // Return the Objective-C type encoding for a given type.
3342 void getObjCEncodingForTypeImpl(QualType t, std::string &S,
3343 ObjCEncOptions Options,
3344 const FieldDecl *Field,
3345 QualType *NotEncodedT = nullptr) const;
3346
3347 // Adds the encoding of the structure's members.
3348 void getObjCEncodingForStructureImpl(RecordDecl *RD, std::string &S,
3349 const FieldDecl *Field,
3350 bool includeVBases = true,
3351 QualType *NotEncodedT=nullptr) const;
3352
3353public:
3354 // Adds the encoding of a method parameter or return type.
3356 QualType T, std::string& S,
3357 bool Extended) const;
3358
3359 /// Returns true if this is an inline-initialized static data member
3360 /// which is treated as a definition for MSVC compatibility.
3361 bool isMSStaticDataMemberInlineDefinition(const VarDecl *VD) const;
3362
3364 /// Not an inline variable.
3365 None,
3366
3367 /// Weak definition of inline variable.
3368 Weak,
3369
3370 /// Weak for now, might become strong later in this TU.
3372
3373 /// Strong definition.
3374 Strong
3375 };
3376
3377 /// Determine whether a definition of this inline variable should
3378 /// be treated as a weak or strong definition. For compatibility with
3379 /// C++14 and before, for a constexpr static data member, if there is an
3380 /// out-of-line declaration of the member, we may promote it from weak to
3381 /// strong.
3384
3385private:
3387 friend class DeclContext;
3388
3389 const ASTRecordLayout &
3390 getObjCLayout(const ObjCInterfaceDecl *D,
3391 const ObjCImplementationDecl *Impl) const;
3392
3393 /// A set of deallocations that should be performed when the
3394 /// ASTContext is destroyed.
3395 // FIXME: We really should have a better mechanism in the ASTContext to
3396 // manage running destructors for types which do variable sized allocation
3397 // within the AST. In some places we thread the AST bump pointer allocator
3398 // into the datastructures which avoids this mess during deallocation but is
3399 // wasteful of memory, and here we require a lot of error prone book keeping
3400 // in order to track and run destructors while we're tearing things down.
3402 llvm::SmallVector<std::pair<void (*)(void *), void *>, 16>;
3403 mutable DeallocationFunctionsAndArguments Deallocations;
3404
3405 // FIXME: This currently contains the set of StoredDeclMaps used
3406 // by DeclContext objects. This probably should not be in ASTContext,
3407 // but we include it here so that ASTContext can quickly deallocate them.
3408 llvm::PointerIntPair<StoredDeclsMap *, 1> LastSDM;
3409
3410 std::vector<Decl *> TraversalScope;
3411
3412 std::unique_ptr<VTableContextBase> VTContext;
3413
3414 void ReleaseDeclContextMaps();
3415
3416public:
3417 enum PragmaSectionFlag : unsigned {
3424 PSF_Invalid = 0x80000000U,
3425 };
3426
3431
3432 SectionInfo() = default;
3434 int SectionFlags)
3437 };
3438
3439 llvm::StringMap<SectionInfo> SectionInfos;
3440
3441 /// Return a new OMPTraitInfo object owned by this context.
3443
3444 /// Whether a C++ static variable or CUDA/HIP kernel may be externalized.
3445 bool mayExternalize(const Decl *D) const;
3446
3447 /// Whether a C++ static variable or CUDA/HIP kernel should be externalized.
3448 bool shouldExternalize(const Decl *D) const;
3449
3450 /// Resolve the root record to be used to derive the vtable pointer
3451 /// authentication policy for the specified record.
3452 const CXXRecordDecl *
3454 bool useAbbreviatedThunkName(GlobalDecl VirtualMethodDecl,
3455 StringRef MangledName);
3456
3457 StringRef getCUIDHash() const;
3458
3459private:
3460 /// All OMPTraitInfo objects live in this collection, one per
3461 /// `pragma omp [begin] declare variant` directive.
3462 SmallVector<std::unique_ptr<OMPTraitInfo>, 4> OMPTraitInfoVector;
3463
3464 llvm::DenseMap<GlobalDecl, llvm::StringSet<>> ThunksToBeAbbreviated;
3465};
3466
3467/// Insertion operator for diagnostics.
3469 const ASTContext::SectionInfo &Section);
3470
3471/// Utility function for constructing a nullary selector.
3472inline Selector GetNullarySelector(StringRef name, ASTContext &Ctx) {
3473 const IdentifierInfo *II = &Ctx.Idents.get(name);
3474 return Ctx.Selectors.getSelector(0, &II);
3475}
3476
3477/// Utility function for constructing an unary selector.
3478inline Selector GetUnarySelector(StringRef name, ASTContext &Ctx) {
3479 const IdentifierInfo *II = &Ctx.Idents.get(name);
3480 return Ctx.Selectors.getSelector(1, &II);
3481}
3482
3483} // namespace clang
3484
3485// operator new and delete aren't allowed inside namespaces.
3486
3487/// Placement new for using the ASTContext's allocator.
3488///
3489/// This placement form of operator new uses the ASTContext's allocator for
3490/// obtaining memory.
3491///
3492/// IMPORTANT: These are also declared in clang/AST/ASTContextAllocate.h!
3493/// Any changes here need to also be made there.
3494///
3495/// We intentionally avoid using a nothrow specification here so that the calls
3496/// to this operator will not perform a null check on the result -- the
3497/// underlying allocator never returns null pointers.
3498///
3499/// Usage looks like this (assuming there's an ASTContext 'Context' in scope):
3500/// @code
3501/// // Default alignment (8)
3502/// IntegerLiteral *Ex = new (Context) IntegerLiteral(arguments);
3503/// // Specific alignment
3504/// IntegerLiteral *Ex2 = new (Context, 4) IntegerLiteral(arguments);
3505/// @endcode
3506/// Memory allocated through this placement new operator does not need to be
3507/// explicitly freed, as ASTContext will free all of this memory when it gets
3508/// destroyed. Please note that you cannot use delete on the pointer.
3509///
3510/// @param Bytes The number of bytes to allocate. Calculated by the compiler.
3511/// @param C The ASTContext that provides the allocator.
3512/// @param Alignment The alignment of the allocated memory (if the underlying
3513/// allocator supports it).
3514/// @return The allocated memory. Could be nullptr.
3515inline void *operator new(size_t Bytes, const clang::ASTContext &C,
3516 size_t Alignment /* = 8 */) {
3517 return C.Allocate(Bytes, Alignment);
3518}
3519
3520/// Placement delete companion to the new above.
3521///
3522/// This operator is just a companion to the new above. There is no way of
3523/// invoking it directly; see the new operator for more details. This operator
3524/// is called implicitly by the compiler if a placement new expression using
3525/// the ASTContext throws in the object constructor.
3526inline void operator delete(void *Ptr, const clang::ASTContext &C, size_t) {
3527 C.Deallocate(Ptr);
3528}
3529
3530/// This placement form of operator new[] uses the ASTContext's allocator for
3531/// obtaining memory.
3532///
3533/// We intentionally avoid using a nothrow specification here so that the calls
3534/// to this operator will not perform a null check on the result -- the
3535/// underlying allocator never returns null pointers.
3536///
3537/// Usage looks like this (assuming there's an ASTContext 'Context' in scope):
3538/// @code
3539/// // Default alignment (8)
3540/// char *data = new (Context) char[10];
3541/// // Specific alignment
3542/// char *data = new (Context, 4) char[10];
3543/// @endcode
3544/// Memory allocated through this placement new[] operator does not need to be
3545/// explicitly freed, as ASTContext will free all of this memory when it gets
3546/// destroyed. Please note that you cannot use delete on the pointer.
3547///
3548/// @param Bytes The number of bytes to allocate. Calculated by the compiler.
3549/// @param C The ASTContext that provides the allocator.
3550/// @param Alignment The alignment of the allocated memory (if the underlying
3551/// allocator supports it).
3552/// @return The allocated memory. Could be nullptr.
3553inline void *operator new[](size_t Bytes, const clang::ASTContext& C,
3554 size_t Alignment /* = 8 */) {
3555 return C.Allocate(Bytes, Alignment);
3556}
3557
3558/// Placement delete[] companion to the new[] above.
3559///
3560/// This operator is just a companion to the new[] above. There is no way of
3561/// invoking it directly; see the new[] operator for more details. This operator
3562/// is called implicitly by the compiler if a placement new[] expression using
3563/// the ASTContext throws in the object constructor.
3564inline void operator delete[](void *Ptr, const clang::ASTContext &C, size_t) {
3565 C.Deallocate(Ptr);
3566}
3567
3568/// Create the representation of a LazyGenerationalUpdatePtr.
3569template <typename Owner, typename T,
3570 void (clang::ExternalASTSource::*Update)(Owner)>
3573 const clang::ASTContext &Ctx, T Value) {
3574 // Note, this is implemented here so that ExternalASTSource.h doesn't need to
3575 // include ASTContext.h. We explicitly instantiate it for all relevant types
3576 // in ASTContext.cpp.
3577 if (auto *Source = Ctx.getExternalSource())
3578 return new (Ctx) LazyData(Source, Value);
3579 return Value;
3580}
3581
3582#endif // LLVM_CLANG_AST_ASTCONTEXT_H
#define OPT_LIST(V)
Definition: ASTContext.h:3310
#define V(N, I)
Definition: ASTContext.h:3323
Forward declaration of all AST node types.
DynTypedNode Node
static char ID
Definition: Arena.cpp:183
#define SM(sm)
Definition: Cuda.cpp:83
static bool CanThrow(Expr *E, ASTContext &Ctx)
Definition: CFG.cpp:2679
clang::CharUnits operator*(clang::CharUnits::QuantityType Scale, const clang::CharUnits &CU)
Definition: CharUnits.h:225
const Decl * D
enum clang::sema::@1646::IndirectLocalPathEntry::EntryKind Kind
Expr * E
static CGCXXABI * createCXXABI(CodeGenModule &CGM)
#define X(type, name)
Definition: Value.h:143
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
llvm::MachO::Target Target
Definition: MachO.h:51
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
SourceLocation Loc
Definition: SemaObjC.cpp:758
Defines the clang::SourceLocation class and associated facilities.
#define CXXABI(Name, Str)
Definition: TargetCXXABI.h:32
SourceLocation Begin
__device__ int
__SIZE_TYPE__ size_t
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Definition: APValue.h:122
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:186
bool getByrefLifetime(QualType Ty, Qualifiers::ObjCLifetime &Lifetime, bool &HasByrefExtendedLayout) const
Returns true, if given type has a known lifetime.
MSGuidDecl * getMSGuidDecl(MSGuidDeclParts Parts) const
Return a declaration for the global GUID object representing the given GUID value.
QualType getUsingType(const UsingShadowDecl *Found, QualType Underlying) const
CanQualType AccumTy
Definition: ASTContext.h:1122
BuiltinVectorTypeInfo getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const
Returns the element type, element count and number of vectors (in case of tuple) for a builtin vector...
bool ObjCMethodsAreEqual(const ObjCMethodDecl *MethodDecl, const ObjCMethodDecl *MethodImp)
CanQualType ObjCBuiltinSelTy
Definition: ASTContext.h:1141
SourceManager & getSourceManager()
Definition: ASTContext.h:717
TranslationUnitDecl * getTranslationUnitDecl() const
Definition: ASTContext.h:1091
const ConstantArrayType * getAsConstantArrayType(QualType T) const
Definition: ASTContext.h:2809
CanQualType getCanonicalFunctionResultType(QualType ResultType) const
Adjust the given function result type.
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
bool areLaxCompatibleSveTypes(QualType FirstType, QualType SecondType)
Return true if the given vector types are lax-compatible SVE vector types, false otherwise.
llvm::PointerUnion< VarTemplateDecl *, MemberSpecializationInfo * > TemplateOrSpecializationInfo
A type synonym for the TemplateOrInstantiation mapping.
Definition: ASTContext.h:488
LangAS getOpenCLTypeAddrSpace(const Type *T) const
Get address space for OpenCL type.
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
void InitBuiltinTypes(const TargetInfo &Target, const TargetInfo *AuxTarget=nullptr)
Initialize built-in types.
ParentMapContext & getParentMapContext()
Returns the dynamic AST node parent map context.
Definition: ASTContext.cpp:853
QualType getParenType(QualType NamedType) const
size_t getSideTableAllocatedMemory() const
Return the total memory used for various side tables.
MemberSpecializationInfo * getInstantiatedFromStaticDataMember(const VarDecl *Var)
If this variable is an instantiated static data member of a class template specialization,...
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
CanQualType ARCUnbridgedCastTy
Definition: ASTContext.h:1140
uint64_t getTypeSize(const Type *T) const
Definition: ASTContext.h:2383
QualType getDependentSizedMatrixType(QualType ElementType, Expr *RowExpr, Expr *ColumnExpr, SourceLocation AttrLoc) const
Return the unique reference to the matrix type of the specified element type and size.
llvm::DenseMap< const Decl *, comments::FullComment * > ParsedComments
Mapping from declarations to parsed comments attached to any redeclaration.
Definition: ASTContext.h:846
unsigned getManglingNumber(const NamedDecl *ND, bool ForAuxTarget=false) const
CanQualType LongTy
Definition: ASTContext.h:1118
void UnwrapSimilarArrayTypes(QualType &T1, QualType &T2, bool AllowPiMismatch=true)
Attempt to unwrap two types that may both be array types with the same bound (or both be array types ...
const SmallVectorImpl< Type * > & getTypes() const
Definition: ASTContext.h:1233
unsigned getIntWidth(QualType T) const
CanQualType getCanonicalParamType(QualType T) const
Return the canonical parameter type corresponding to the specific potentially non-canonical one.
QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr, QualType Wrapped)
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
TemplateOrSpecializationInfo getTemplateOrSpecializationInfo(const VarDecl *Var)
CanQualType WIntTy
Definition: ASTContext.h:1114
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType) const
@ Weak
Weak definition of inline variable.
@ WeakUnknown
Weak for now, might become strong later in this TU.
const ProfileList & getProfileList() const
Definition: ASTContext.h:803
void setObjCConstantStringInterface(ObjCInterfaceDecl *Decl)
TypedefDecl * getObjCClassDecl() const
Retrieve the typedef declaration corresponding to the predefined Objective-C 'Class' type.
TypedefNameDecl * getTypedefNameForUnnamedTagDecl(const TagDecl *TD)
TypedefDecl * getCFConstantStringDecl() const
CanQualType Int128Ty
Definition: ASTContext.h:1118
CanQualType SatUnsignedFractTy
Definition: ASTContext.h:1131
CanQualType getAdjustedType(CanQualType Orig, CanQualType New) const
Definition: ASTContext.h:1393
BuiltinTemplateDecl * getMakeIntegerSeqDecl() const
void setInstantiatedFromUsingDecl(NamedDecl *Inst, NamedDecl *Pattern)
Remember that the using decl Inst is an instantiation of the using decl Pattern of a class template.
bool areCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given types are an RISC-V vector builtin type and a VectorType that is a fixed-len...
ExternCContextDecl * getExternCContextDecl() const
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD) const
Parses the target attributes passed in, and returns only the ones that are valid feature names.
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent, bool IsPack=false, ConceptDecl *TypeConstraintConcept=nullptr, ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
QualType areCommonBaseCompatible(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
TypedefDecl * getObjCSelDecl() const
Retrieve the typedef corresponding to the predefined 'SEL' type in Objective-C.
llvm::iterator_range< import_iterator > import_range
Definition: ASTContext.h:1041
bool AnyObjCImplementation()
Return true if there is at least one @implementation in the TU.
Definition: ASTContext.h:3089
CanQualType UnsignedShortAccumTy
Definition: ASTContext.h:1124
TypedefDecl * getObjCInstanceTypeDecl()
Retrieve the typedef declaration corresponding to the Objective-C "instancetype" type.
uint64_t getFieldOffset(const ValueDecl *FD) const
Get the offset of a FieldDecl or IndirectFieldDecl, in bits.
void DeallocateDeclListNode(DeclListNode *N)
Deallcates a DeclListNode by returning it to the ListNodeFreeList pool.
Definition: ASTContext.h:751
DeclListNode * AllocateDeclListNode(clang::NamedDecl *ND)
Allocates a DeclListNode or returns one from the ListNodeFreeList pool.
Definition: ASTContext.h:740
QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, ArrayRef< TemplateArgumentLoc > Args) const
void setTemplateOrSpecializationInfo(VarDecl *Inst, TemplateOrSpecializationInfo TSI)
bool ProtocolCompatibleWithProtocol(ObjCProtocolDecl *lProto, ObjCProtocolDecl *rProto) const
ProtocolCompatibleWithProtocol - return 'true' if 'lProto' is in the inheritance hierarchy of 'rProto...
bool hasSimilarType(QualType T1, QualType T2)
Determine if two types are similar, according to the C++ rules.
TypedefDecl * buildImplicitTypedef(QualType T, StringRef Name) const
Create a new implicit TU-level typedef declaration.
unsigned getTypeAlign(const Type *T) const
Definition: ASTContext.h:2414
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
void adjustObjCTypeParamBoundType(const ObjCTypeParamDecl *Orig, ObjCTypeParamDecl *New) const
llvm::StringMap< SectionInfo > SectionInfos
Definition: ASTContext.h:3439
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
QualType getAutoRRefDeductType() const
C++11 deduction pattern for 'auto &&' type.
TypedefDecl * getBuiltinMSVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_ms_va_list type.
bool ObjCQualifiedIdTypesAreCompatible(const ObjCObjectPointerType *LHS, const ObjCObjectPointerType *RHS, bool ForCompare)
ObjCQualifiedIdTypesAreCompatible - We know that one of lhs/rhs is an ObjCQualifiedIDType.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl.
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
QualType getBuiltinVaListType() const
Retrieve the type of the __builtin_va_list type.
Definition: ASTContext.h:2160
QualType mergeFunctionTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool AllowCXX=false, bool IsConditionalOperator=false)
NamedDecl * getInstantiatedFromUsingDecl(NamedDecl *Inst)
If the given using decl Inst is an instantiation of another (possibly unresolved) using decl,...
DeclarationNameTable DeclarationNames
Definition: ASTContext.h:660
comments::FullComment * cloneFullComment(comments::FullComment *FC, const Decl *D) const
Definition: ASTContext.cpp:560
TemplateName getCanonicalTemplateName(const TemplateName &Name) const
Retrieves the "canonical" template name that refers to a given template.
QualType getUnresolvedUsingType(const UnresolvedUsingTypenameDecl *Decl) const
CharUnits getObjCEncodingTypeSize(QualType T) const
Return the size of type T for Objective-C encoding purpose, in characters.
int getIntegerTypeOrder(QualType LHS, QualType RHS) const
Return the highest ranked integer type, see C99 6.3.1.8p1.
QualType getObjCClassType() const
Represents the Objective-C Class type.
Definition: ASTContext.h:2127
TypedefDecl * getObjCIdDecl() const
Retrieve the typedef corresponding to the predefined id type in Objective-C.
void setCurrentNamedModule(Module *M)
Set the (C++20) module we are building.
QualType getRawCFConstantStringType() const
Get the structure type used to representation CFStrings, or NULL if it hasn't yet been built.
Definition: ASTContext.h:1881
QualType getProcessIDType() const
Return the unique type for "pid_t" defined in <sys/types.h>.
CharUnits getMemberPointerPathAdjustment(const APValue &MP) const
Find the 'this' offset for the member path in a pointer-to-member APValue.
bool mayExternalize(const Decl *D) const
Whether a C++ static variable or CUDA/HIP kernel may be externalized.
QualType getTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon=QualType()) const
std::unique_ptr< MangleNumberingContext > createMangleNumberingContext() const
CanQualType SatAccumTy
Definition: ASTContext.h:1127
QualType getUnsignedPointerDiffType() const
Return the unique unsigned counterpart of "ptrdiff_t" integer type.
QualType getucontext_tType() const
Retrieve the C ucontext_t type.
Definition: ASTContext.h:2034
QualType getRecordType(const RecordDecl *Decl) const
std::optional< CharUnits > getTypeSizeInCharsIfKnown(const Type *Ty) const
Definition: ASTContext.h:2407
QualType getScalableVectorType(QualType EltTy, unsigned NumElts, unsigned NumFields=1) const
Return the unique reference to a scalable vector type of the specified element type and scalable numb...
bool hasSameExpr(const Expr *X, const Expr *Y) const
Determine whether the given expressions X and Y are equivalent.
void getObjCEncodingForType(QualType T, std::string &S, const FieldDecl *Field=nullptr, QualType *NotEncodedT=nullptr) const
Emit the Objective-CC type encoding for the given type T into S.
QualType getBuiltinMSVaListType() const
Retrieve the type of the __builtin_ms_va_list type.
Definition: ASTContext.h:2174
MangleContext * createMangleContext(const TargetInfo *T=nullptr)
If T is null pointer, assume the target in ASTContext.
QualType getRealTypeForBitwidth(unsigned DestWidth, FloatModeKind ExplicitType) const
getRealTypeForBitwidth - sets floating point QualTy according to specified bitwidth.
QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const
getInjectedClassNameType - Return the unique reference to the injected class name type for the specif...
QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a variable array of the specified element type.
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
CanQualType ShortAccumTy
Definition: ASTContext.h:1122
ASTMutationListener * getASTMutationListener() const
Retrieve a pointer to the AST mutation listener associated with this AST context, if any.
Definition: ASTContext.h:1230
unsigned NumImplicitCopyAssignmentOperatorsDeclared
The number of implicitly-declared copy assignment operators for which declarations were built.
Definition: ASTContext.h:3273
uint64_t getTargetNullPointerValue(QualType QT) const
Get target-dependent integer value for null pointer which is used for constant folding.
unsigned getTypeUnadjustedAlign(QualType T) const
Return the ABI-specified natural alignment of a (complete) type T, before alignment adjustments,...
Definition: ASTContext.h:2421
unsigned char getFixedPointIBits(QualType Ty) const
QualType getCorrespondingSignedFixedPointType(QualType Ty) const
IntrusiveRefCntPtr< ExternalASTSource > ExternalSource
Definition: ASTContext.h:661
CanQualType FloatTy
Definition: ASTContext.h:1121
QualType getArrayParameterType(QualType Ty) const
Return the uniqued reference to a specified array parameter type from the original array type.
QualType getCountAttributedType(QualType T, Expr *CountExpr, bool CountInBytes, bool OrNull, ArrayRef< TypeCoupledDeclRefInfo > DependentDecls) const
void setObjCIdRedefinitionType(QualType RedefType)
Set the user-written type that redefines id.
Definition: ASTContext.h:1913
bool isObjCIdType(QualType T) const
Definition: ASTContext.h:2941
QualType getPackExpansionType(QualType Pattern, std::optional< unsigned > NumExpansions, bool ExpectPackInType=true)
Form a pack expansion type with the given pattern.
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D,...
DynTypedNodeList getParents(const NodeT &Node)
Forwards to get node parents from the ParentMapContext.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Definition: ASTContext.h:2616
unsigned NumImplicitDestructorsDeclared
The number of implicitly-declared destructors for which declarations were built.
Definition: ASTContext.h:3287
bool isObjCClassType(QualType T) const
Definition: ASTContext.h:2947
void setObjCNSStringType(QualType T)
Definition: ASTContext.h:1900
bool mergeExtParameterInfo(const FunctionProtoType *FirstFnType, const FunctionProtoType *SecondFnType, bool &CanUseFirst, bool &CanUseSecond, SmallVectorImpl< FunctionProtoType::ExtParameterInfo > &NewParamInfos)
This function merges the ExtParameterInfo lists of two functions.
bool ObjCQualifiedClassTypesAreCompatible(const ObjCObjectPointerType *LHS, const ObjCObjectPointerType *RHS)
ObjCQualifiedClassTypesAreCompatible - compare Class<pr,...> and Class<pr1, ...>.
bool shouldExternalize(const Decl *D) const
Whether a C++ static variable or CUDA/HIP kernel should be externalized.
FullSourceLoc getFullLoc(SourceLocation Loc) const
Definition: ASTContext.h:807
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
Definition: ASTContext.h:2632
bool propertyTypesAreCompatible(QualType, QualType)
void setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst, UsingShadowDecl *Pattern)
CanQualType DoubleTy
Definition: ASTContext.h:1121
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateName Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
QualType getDependentVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc, VectorKind VecKind) const
Return the unique reference to the type for a dependently sized vector of the specified element type.
comments::CommandTraits & getCommentCommandTraits() const
Definition: ASTContext.h:948
CanQualType SatLongAccumTy
Definition: ASTContext.h:1127
const XRayFunctionFilter & getXRayFilter() const
Definition: ASTContext.h:799
CanQualType getIntMaxType() const
Return the unique type for "intmax_t" (C99 7.18.1.5), defined in <stdint.h>.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
OpenCLTypeKind getOpenCLTypeKind(const Type *T) const
Map an AST Type to an OpenCLTypeKind enum value.
QualType getFILEType() const
Retrieve the C FILE type.
Definition: ASTContext.h:1998
ArrayRef< Decl * > getModuleInitializers(Module *M)
Get the initializations to perform when importing a module, if any.
void getObjCEncodingForTypeQualifier(Decl::ObjCDeclQualifier QT, std::string &S) const
Put the string version of the type qualifiers QT into S.
unsigned getPreferredTypeAlign(QualType T) const
Return the "preferred" alignment of the specified type T for the current target, in bits.
Definition: ASTContext.h:2473
void getInjectedTemplateArgs(const TemplateParameterList *Params, SmallVectorImpl< TemplateArgument > &Args)
Get a template argument list with one argument per template parameter in a template parameter list,...
void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl)
Set the type for the C sigjmp_buf type.
Definition: ASTContext.h:2017
std::string getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl, bool Extended=false) const
Emit the encoded type for the method declaration Decl into S.
void DumpRecordLayout(const RecordDecl *RD, raw_ostream &OS, bool Simple=false) const
bool DeclMustBeEmitted(const Decl *D)
Determines if the decl can be CodeGen'ed or deserialized from PCH lazily, only when used; this is onl...
CanQualType LongDoubleTy
Definition: ASTContext.h:1121
CanQualType OMPArrayShapingTy
Definition: ASTContext.h:1150
ASTContext(LangOptions &LOpts, SourceManager &SM, IdentifierTable &idents, SelectorTable &sels, Builtin::Context &builtins, TranslationUnitKind TUKind)
Definition: ASTContext.cpp:872
QualType getReadPipeType(QualType T) const
Return a read_only pipe type for the specified type.
std::string getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD, const Decl *Container) const
getObjCEncodingForPropertyDecl - Return the encoded type for this method declaration.
CanQualType Char16Ty
Definition: ASTContext.h:1116
unsigned getStaticLocalNumber(const VarDecl *VD) const
QualType getObjCSelRedefinitionType() const
Retrieve the type that 'SEL' has been defined to, which may be different from the built-in 'SEL' if '...
Definition: ASTContext.h:1932
void addComment(const RawComment &RC)
Definition: ASTContext.cpp:328
void getLegacyIntegralTypeEncoding(QualType &t) const
getLegacyIntegralTypeEncoding - Another legacy compatibility encoding: 32-bit longs are encoded as 'l...
bool isSameTypeConstraint(const TypeConstraint *XTC, const TypeConstraint *YTC) const
Determine whether two type contraint are similar enough that they could used in declarations of the s...
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod, bool IsBuiltin=false) const
Retrieves the default calling convention for the current target.
RecordDecl * buildImplicitRecord(StringRef Name, RecordDecl::TagKind TK=RecordDecl::TagKind::Struct) const
Create a new implicit TU-level CXXRecordDecl or RecordDecl declaration.
void setObjCSelRedefinitionType(QualType RedefType)
Set the user-written type that redefines 'SEL'.
Definition: ASTContext.h:1939
void setFILEDecl(TypeDecl *FILEDecl)
Set the type for the C FILE type.
Definition: ASTContext.h:1995
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const IncompleteArrayType * getAsIncompleteArrayType(QualType T) const
Definition: ASTContext.h:2815
QualType getMSGuidType() const
Retrieve the implicitly-predeclared 'struct _GUID' type.
Definition: ASTContext.h:2182
const CXXMethodDecl * getCurrentKeyFunction(const CXXRecordDecl *RD)
Get our current best idea for the key function of the given record decl, or nullptr if there isn't on...
const ASTRecordLayout & getASTObjCImplementationLayout(const ObjCImplementationDecl *D) const
Get or compute information about the layout of the specified Objective-C implementation.
CanQualType UnsignedLongFractTy
Definition: ASTContext.h:1126
QualType getEnumType(const EnumDecl *Decl) const
overridden_method_range overridden_methods(const CXXMethodDecl *Method) const
QualType getDependentBitIntType(bool Unsigned, Expr *BitsExpr) const
Return a dependent bit-precise integer type with the specified signedness and bit count.
void setObjCImplementation(ObjCInterfaceDecl *IFaceD, ObjCImplementationDecl *ImplD)
Set the implementation of ObjCInterfaceDecl.
StringRef getCUIDHash() const
bool isMSStaticDataMemberInlineDefinition(const VarDecl *VD) const
Returns true if this is an inline-initialized static data member which is treated as a definition for...
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
CanQualType VoidPtrTy
Definition: ASTContext.h:1136
QualType getReferenceQualifiedType(const Expr *e) const
getReferenceQualifiedType - Given an expr, will return the type for that expression,...
bool hasSameFunctionTypeIgnoringExceptionSpec(QualType T, QualType U) const
Determine whether two function types are the same, ignoring exception specifications in cases where t...
bool isObjCSelType(QualType T) const
Definition: ASTContext.h:2953
QualType getBlockDescriptorExtendedType() const
Gets the struct used to keep track of the extended descriptor for pointer to blocks.
void Deallocate(void *Ptr) const
Definition: ASTContext.h:736
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
CanQualType DependentTy
Definition: ASTContext.h:1137
IdentifierInfo * getMakeIntegerSeqName() const
Definition: ASTContext.h:1972
bool QIdProtocolsAdoptObjCObjectProtocols(QualType QT, ObjCInterfaceDecl *IDecl)
QIdProtocolsAdoptObjCObjectProtocols - Checks that protocols in QT's qualified-id protocol list adopt...
void addLazyModuleInitializers(Module *M, ArrayRef< GlobalDeclID > IDs)
bool isSameConstraintExpr(const Expr *XCE, const Expr *YCE) const
Determine whether two 'requires' expressions are similar enough that they may be used in re-declarati...
IdentifierInfo * getTypePackElementName() const
Definition: ASTContext.h:1978
bool BlockRequiresCopying(QualType Ty, const VarDecl *D)
Returns true iff we need copy/dispose helpers for the given type.
CanQualType NullPtrTy
Definition: ASTContext.h:1136
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:1625
CanQualType WideCharTy
Definition: ASTContext.h:1113
CanQualType OMPIteratorTy
Definition: ASTContext.h:1150
IdentifierTable & Idents
Definition: ASTContext.h:656
std::vector< Decl * > getTraversalScope() const
Definition: ASTContext.h:702
TemplateName getSubstTemplateTemplateParm(TemplateName replacement, Decl *AssociatedDecl, unsigned Index, std::optional< unsigned > PackIndex) const
Builtin::Context & BuiltinInfo
Definition: ASTContext.h:658
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
void addModuleInitializer(Module *M, Decl *Init)
Add a declaration to the list of declarations that are initialized for a module.
const LangOptions & getLangOpts() const
Definition: ASTContext.h:787
QualType getConstType(QualType T) const
Return the uniqued reference to the type for a const qualified type.
Definition: ASTContext.h:1333
TemplateArgument getInjectedTemplateArg(NamedDecl *ParamDecl)
QualType getFunctionTypeWithoutPtrSizes(QualType T)
Get a function type and produce the equivalent function type where pointer size address spaces in the...
llvm::iterator_range< overridden_cxx_method_iterator > overridden_method_range
Definition: ASTContext.h:1013
SelectorTable & Selectors
Definition: ASTContext.h:657
unsigned getMinGlobalAlignOfVar(uint64_t Size, const VarDecl *VD) const
Return the minimum alignement as specified by the target.
RawCommentList Comments
All comments in this translation unit.
Definition: ASTContext.h:817
bool isSameDefaultTemplateArgument(const NamedDecl *X, const NamedDecl *Y) const
Determine whether two default template arguments are similar enough that they may be used in declarat...
QualType applyObjCProtocolQualifiers(QualType type, ArrayRef< ObjCProtocolDecl * > protocols, bool &hasError, bool allowOnPointerType=false) const
Apply Objective-C protocol qualifiers to the given type.
QualType getMacroQualifiedType(QualType UnderlyingTy, const IdentifierInfo *MacroII) const
QualType removePtrSizeAddrSpace(QualType T) const
Remove the existing address space on the type if it is a pointer size address space and return the ty...
bool areLaxCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given vector types are lax-compatible RISC-V vector types as defined by -flax-vect...
void setObjCSuperType(QualType ST)
Definition: ASTContext.h:1877
TypedefDecl * getBOOLDecl() const
Retrieve declaration of 'BOOL' typedef.
Definition: ASTContext.h:2136
CanQualType SatShortFractTy
Definition: ASTContext.h:1130
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
bool canBindObjCObjectType(QualType To, QualType From)
int getFloatingTypeSemanticOrder(QualType LHS, QualType RHS) const
Compare the rank of two floating point types as above, but compare equal if both types have the same ...
QualType getUIntPtrType() const
Return a type compatible with "uintptr_t" (C99 7.18.1.4), as defined by the target.
void setParameterIndex(const ParmVarDecl *D, unsigned index)
Used by ParmVarDecl to store on the side the index of the parameter when it exceeds the size of the n...
QualType getFunctionTypeWithExceptionSpec(QualType Orig, const FunctionProtoType::ExceptionSpecInfo &ESI) const
Get a function type and produce the equivalent function type with the specified exception specificati...
bool hasSameType(const Type *T1, const Type *T2) const
Definition: ASTContext.h:2635
QualType getObjCInstanceType()
Retrieve the Objective-C "instancetype" type, if already known; otherwise, returns a NULL type;.
Definition: ASTContext.h:1986
Qualifiers::GC getObjCGCAttrKind(QualType Ty) const
Return one of the GCNone, Weak or Strong Objective-C garbage collection attributes.
PartialDiagnostic::DiagStorageAllocator & getDiagAllocator()
Definition: ASTContext.h:765
CanQualType Ibm128Ty
Definition: ASTContext.h:1121
void setASTMutationListener(ASTMutationListener *Listener)
Attach an AST mutation listener to the AST context.
Definition: ASTContext.h:1224
bool hasUniqueObjectRepresentations(QualType Ty, bool CheckIfTriviallyCopyable=true) const
Return true if the specified type has unique object representations according to (C++17 [meta....
bool typesAreBlockPointerCompatible(QualType, QualType)
CanQualType SatUnsignedAccumTy
Definition: ASTContext.h:1128
bool useAbbreviatedThunkName(GlobalDecl VirtualMethodDecl, StringRef MangledName)
const ASTRecordLayout & getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D) const
Get or compute information about the layout of the specified Objective-C interface.
QualType getObjCProtoType() const
Retrieve the type of the Objective-C Protocol class.
Definition: ASTContext.h:2151
void forEachMultiversionedFunctionVersion(const FunctionDecl *FD, llvm::function_ref< void(FunctionDecl *)> Pred) const
Visits all versions of a multiversioned function with the passed predicate.
void setInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst, UsingEnumDecl *Pattern)
Remember that the using enum decl Inst is an instantiation of the using enum decl Pattern of a class ...
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
Decl * getPrimaryMergedDecl(Decl *D)
Definition: ASTContext.h:1047
QualType getSignatureParameterType(QualType T) const
Retrieve the parameter type as adjusted for use in the signature of a function, decaying array and fu...
CanQualType ArraySectionTy
Definition: ASTContext.h:1149
QualType getCanonicalTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args) const
CanQualType ObjCBuiltinIdTy
Definition: ASTContext.h:1141
overridden_cxx_method_iterator overridden_methods_end(const CXXMethodDecl *Method) const
VTableContextBase * getVTableContext()
void setBOOLDecl(TypedefDecl *TD)
Save declaration of 'BOOL' typedef.
Definition: ASTContext.h:2141
ComparisonCategories CompCategories
Types and expressions required to build C++2a three-way comparisons using operator<=>,...
Definition: ASTContext.h:2313
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i....
unsigned CountNonClassIvars(const ObjCInterfaceDecl *OI) const
ASTContext(const ASTContext &)=delete
ObjCPropertyImplDecl * getObjCPropertyImplDeclForPropertyDecl(const ObjCPropertyDecl *PD, const Decl *Container) const
bool isNearlyEmpty(const CXXRecordDecl *RD) const
QualType AutoDeductTy
Definition: ASTContext.h:1169
CanQualType BoolTy
Definition: ASTContext.h:1110
void cacheRawCommentForDecl(const Decl &OriginalD, const RawComment &Comment) const
Attaches Comment to OriginalD and to its redeclaration chain and removes the redeclaration chain from...
Definition: ASTContext.cpp:472
void attachCommentsToJustParsedDecls(ArrayRef< Decl * > Decls, const Preprocessor *PP)
Searches existing comments for doc comments that should be attached to Decls.
Definition: ASTContext.cpp:498
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth,...
llvm::BumpPtrAllocator & getAllocator() const
Definition: ASTContext.h:726
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
QualType getCFConstantStringType() const
Return the C structure type used to represent constant CFStrings.
FieldDecl * getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field)
void eraseDeclAttrs(const Decl *D)
Erase the attributes corresponding to the given declaration.
const NoSanitizeList & getNoSanitizeList() const
Definition: ASTContext.h:797
struct clang::ASTContext::CUDAConstantEvalContext CUDAConstantEvalCtx
IdentifierInfo * getNSObjectName() const
Retrieve the identifier 'NSObject'.
Definition: ASTContext.h:1944
UsingEnumDecl * getInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst)
If the given using-enum decl Inst is an instantiation of another using-enum decl, return it.
RecordDecl * getCFConstantStringTagDecl() const
QualType getObjCSelType() const
Retrieve the type that corresponds to the predefined Objective-C 'SEL' type.
Definition: ASTContext.h:2115
QualType getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
std::string getObjCEncodingForFunctionDecl(const FunctionDecl *Decl) const
Emit the encoded type for the function Decl into S.
QualType getTemplateTypeParmType(unsigned Depth, unsigned Index, bool ParameterPack, TemplateTypeParmDecl *ParmDecl=nullptr) const
Retrieve the template type parameter type for a template parameter or parameter pack with the given d...
bool addressSpaceMapManglingFor(LangAS AS) const
Definition: ASTContext.h:2904
CanQualType UnsignedFractTy
Definition: ASTContext.h:1126
QualType getjmp_bufType() const
Retrieve the C jmp_buf type.
Definition: ASTContext.h:2010
GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const
QualType mergeFunctionParameterTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false)
mergeFunctionParameterTypes - merge two types which appear as function parameter types
QualType getsigjmp_bufType() const
Retrieve the C sigjmp_buf type.
Definition: ASTContext.h:2022
void addOverriddenMethod(const CXXMethodDecl *Method, const CXXMethodDecl *Overridden)
Note that the given C++ Method overrides the given Overridden method.
const TargetInfo * getAuxTargetInfo() const
Definition: ASTContext.h:770
CanQualType Float128Ty
Definition: ASTContext.h:1121
CanQualType ObjCBuiltinClassTy
Definition: ASTContext.h:1141
unsigned NumImplicitDefaultConstructorsDeclared
The number of implicitly-declared default constructors for which declarations were built.
Definition: ASTContext.h:3252
CanQualType UnresolvedTemplateTy
Definition: ASTContext.h:1137
void setucontext_tDecl(TypeDecl *ucontext_tDecl)
Set the type for the C ucontext_t type.
Definition: ASTContext.h:2029
OMPTraitInfo & getNewOMPTraitInfo()
Return a new OMPTraitInfo object owned by this context.
CanQualType UnsignedLongTy
Definition: ASTContext.h:1119
bool hasSameTemplateName(const TemplateName &X, const TemplateName &Y) const
Determine whether the given template names refer to the same template.
llvm::DenseSet< const FunctionDecl * > CUDAImplicitHostDeviceFunUsedByDevice
Keep track of CUDA/HIP implicit host device functions used on device side in device compilation.
Definition: ASTContext.h:1191
void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass, SmallVectorImpl< const ObjCIvarDecl * > &Ivars) const
DeepCollectObjCIvars - This routine first collects all declared, but not synthesized,...
llvm::APFixedPoint getFixedPointMin(QualType Ty) const
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
void addedLocalImportDecl(ImportDecl *Import)
Notify the AST context that a new import declaration has been parsed or implicitly created within thi...
const TranslationUnitKind TUKind
Definition: ASTContext.h:659
QualType getQualifiedType(const Type *T, Qualifiers Qs) const
Return a type with additional qualifiers.
Definition: ASTContext.h:2212
CanQualType UnsignedLongAccumTy
Definition: ASTContext.h:1124
QualType AutoRRefDeductTy
Definition: ASTContext.h:1170
QualType getRestrictType(QualType T) const
Return the uniqued reference to the type for a restrict qualified type.
Definition: ASTContext.h:1313
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
TypeInfo getTypeInfo(const Type *T) const
Get the size and alignment of the specified complete type in bits.
CanQualType ShortFractTy
Definition: ASTContext.h:1125
QualType getStringLiteralArrayType(QualType EltTy, unsigned Length) const
Return a type for a constant array for a string literal of the specified element type and length.
QualType getCorrespondingSaturatedType(QualType Ty) const
bool isSameEntity(const NamedDecl *X, const NamedDecl *Y) const
Determine whether the two declarations refer to the same entity.
QualType getBOOLType() const
type of 'BOOL' type.
Definition: ASTContext.h:2146
TypeSourceInfo * getTemplateSpecializationTypeInfo(TemplateName T, SourceLocation TLoc, const TemplateArgumentListInfo &Args, QualType Canon=QualType()) const
QualType getSubstTemplateTypeParmPackType(Decl *AssociatedDecl, unsigned Index, bool Final, const TemplateArgument &ArgPack)
Retrieve a.
llvm::DenseMap< const CXXMethodDecl *, CXXCastPath > LambdaCastPaths
For capturing lambdas with an explicit object parameter whose type is derived from the lambda type,...
Definition: ASTContext.h:1197
CanQualType BoundMemberTy
Definition: ASTContext.h:1137
CanQualType SatUnsignedShortFractTy
Definition: ASTContext.h:1131
CanQualType CharTy
Definition: ASTContext.h:1111
QualType removeAddrSpaceQualType(QualType T) const
Remove any existing address space on the type and returns the type with qualifiers intact (or that's ...
TypedefDecl * getInt128Decl() const
Retrieve the declaration for the 128-bit signed integer type.
unsigned getOpenMPDefaultSimdAlign(QualType T) const
Get default simd alignment of the specified complete type in bits.
QualType getObjCSuperType() const
Returns the C struct type for objc_super.
QualType getBlockDescriptorType() const
Gets the struct used to keep track of the descriptor for pointer to blocks.
bool CommentsLoaded
True if comments are already loaded from ExternalASTSource.
Definition: ASTContext.h:820
BlockVarCopyInit getBlockVarCopyInit(const VarDecl *VD) const
Get the copy initialization expression of the VarDecl VD, or nullptr if none exists.
unsigned NumImplicitMoveConstructorsDeclared
The number of implicitly-declared move constructors for which declarations were built.
Definition: ASTContext.h:3266
unsigned NumImplicitCopyConstructorsDeclared
The number of implicitly-declared copy constructors for which declarations were built.
Definition: ASTContext.h:3259
CanQualType IntTy
Definition: ASTContext.h:1118
llvm::DenseSet< const VarDecl * > CUDADeviceVarODRUsedByHost
Keep track of CUDA/HIP device-side variables ODR-used by host code.
Definition: ASTContext.h:1183
CanQualType PseudoObjectTy
Definition: ASTContext.h:1140
QualType getWebAssemblyExternrefType() const
Return a WebAssembly externref type.
void setTraversalScope(const std::vector< Decl * > &)
Definition: ASTContext.cpp:939
CharUnits getTypeUnadjustedAlignInChars(QualType T) const
getTypeUnadjustedAlignInChars - Return the ABI-specified alignment of a type, in characters,...
QualType getAdjustedType(QualType Orig, QualType New) const
Return the uniqued reference to a type adjusted from the original type to a new type.
CanQualType getComplexType(CanQualType T) const
Definition: ASTContext.h:1374
friend class NestedNameSpecifier
Definition: ASTContext.h:187
void PrintStats() const
Definition: ASTContext.cpp:953
unsigned getAlignOfGlobalVar(QualType T, const VarDecl *VD) const
Return the alignment in bits that should be given to a global variable with type T.
TypeInfoChars getTypeInfoDataSizeInChars(QualType T) const
MangleNumberingContext & getManglingNumberContext(const DeclContext *DC)
Retrieve the context for computing mangling numbers in the given DeclContext.
comments::FullComment * getLocalCommentForDeclUncached(const Decl *D) const
Return parsed documentation comment attached to a given declaration.
Definition: ASTContext.cpp:575
unsigned NumImplicitDestructors
The number of implicitly-declared destructors.
Definition: ASTContext.h:3283
CanQualType Float16Ty
Definition: ASTContext.h:1135
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
Definition: ASTContext.h:2198
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, TagDecl *OwnedTagDecl=nullptr) const
bool isAlignmentRequired(const Type *T) const
Determine if the alignment the type has was required using an alignment attribute.
TagDecl * MSGuidTagDecl
Definition: ASTContext.h:1177
bool areComparableObjCPointerTypes(QualType LHS, QualType RHS)
MangleContext * createDeviceMangleContext(const TargetInfo &T)
Creates a device mangle context to correctly mangle lambdas in a mixed architecture compile by settin...
CharUnits getExnObjectAlignment() const
Return the alignment (in bytes) of the thrown exception object.
CanQualType SignedCharTy
Definition: ASTContext.h:1118
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
ASTMutationListener * Listener
Definition: ASTContext.h:662
void setNonKeyFunction(const CXXMethodDecl *method)
Observe that the given method cannot be a key function.
CanQualType ObjCBuiltinBoolTy
Definition: ASTContext.h:1142
TypeInfoChars getTypeInfoInChars(const Type *T) const
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
LangAS getDefaultOpenCLPointeeAddrSpace()
Returns default address space based on OpenCL version and enabled features.
Definition: ASTContext.h:1450
TemplateParamObjectDecl * getTemplateParamObjectDecl(QualType T, const APValue &V) const
Return the template parameter object of the given type with the given value.
const SourceManager & getSourceManager() const
Definition: ASTContext.h:718
CanQualType OverloadTy
Definition: ASTContext.h:1137
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
int64_t toBits(CharUnits CharSize) const
Convert a size in characters to a size in bits.
CanQualType OCLClkEventTy
Definition: ASTContext.h:1146
void adjustExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI, bool AsWritten=false)
Change the exception specification on a function once it is delay-parsed, instantiated,...
TypedefDecl * getUInt128Decl() const
Retrieve the declaration for the 128-bit unsigned integer type.
CharUnits getPreferredTypeAlignInChars(QualType T) const
Return the PreferredAlignment of a (complete) type T, in characters.
Definition: ASTContext.h:2441
const clang::PrintingPolicy & getPrintingPolicy() const
Definition: ASTContext.h:709
ArrayRef< Module * > getModulesWithMergedDefinition(const NamedDecl *Def)
Get the additional modules in which the definition Def has been merged.
static ImportDecl * getNextLocalImport(ImportDecl *Import)
Definition: ASTContext.h:1037
llvm::FixedPointSemantics getFixedPointSemantics(QualType Ty) const
QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a dependently-sized array of the specified element type...
uint64_t lookupFieldBitOffset(const ObjCInterfaceDecl *OID, const ObjCImplementationDecl *ID, const ObjCIvarDecl *Ivar) const
Get the offset of an ObjCIvarDecl in bits.
CanQualType SatUnsignedShortAccumTy
Definition: ASTContext.h:1128
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false, bool IsConditionalOperator=false)
const RawComment * getRawCommentForAnyRedecl(const Decl *D, const Decl **OriginalDecl=nullptr) const
Return the documentation comment attached to a given declaration.
Definition: ASTContext.cpp:404
CharUnits getAlignOfGlobalVarInChars(QualType T, const VarDecl *VD) const
Return the alignment in characters that should be given to a global variable with type T.
const ObjCMethodDecl * getObjCMethodRedeclaration(const ObjCMethodDecl *MD) const
Get the duplicate declaration of a ObjCMethod in the same interface, or null if none exists.
static bool isObjCNSObjectType(QualType Ty)
Return true if this is an NSObject object with its NSObject attribute set.
Definition: ASTContext.h:2362
GVALinkage GetGVALinkageForVariable(const VarDecl *VD) const
UsingShadowDecl * getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst)
QualType getWCharType() const
Return the unique wchar_t type available in C++ (and available as __wchar_t as a Microsoft extension)...
Definition: ASTContext.h:1830
QualType getObjCIdType() const
Represents the Objective-CC id type.
Definition: ASTContext.h:2105
Decl * getVaListTagDecl() const
Retrieve the C type declaration corresponding to the predefined __va_list_tag type used to help defin...
QualType getUnsignedWCharType() const
Return the type of "unsigned wchar_t".
llvm::DenseSet< const ValueDecl * > CUDAExternalDeviceDeclODRUsedByHost
Keep track of CUDA/HIP external kernels or device variables ODR-used by host code.
Definition: ASTContext.h:1187
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
Definition: ASTContext.h:2659
QualType getCorrespondingUnsaturatedType(QualType Ty) const
comments::FullComment * getCommentForDecl(const Decl *D, const Preprocessor *PP) const
Return parsed documentation comment attached to a given declaration.
Definition: ASTContext.cpp:580
FunctionProtoType::ExceptionSpecInfo mergeExceptionSpecs(FunctionProtoType::ExceptionSpecInfo ESI1, FunctionProtoType::ExceptionSpecInfo ESI2, SmallVectorImpl< QualType > &ExceptionTypeStorage, bool AcceptDependent)
unsigned getTargetDefaultAlignForAttributeAligned() const
Return the default alignment for attribute((aligned)) on this target, to be used if no alignment valu...
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
bool isSameTemplateParameterList(const TemplateParameterList *X, const TemplateParameterList *Y) const
Determine whether two template parameter lists are similar enough that they may be used in declaratio...
QualType getWritePipeType(QualType T) const
Return a write_only pipe type for the specified type.
const CXXRecordDecl * baseForVTableAuthentication(const CXXRecordDecl *ThisClass)
Resolve the root record to be used to derive the vtable pointer authentication policy for the specifi...
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
Definition: ASTContext.h:2382
CanQualType UnsignedInt128Ty
Definition: ASTContext.h:1120
CanQualType BuiltinFnTy
Definition: ASTContext.h:1139
ObjCInterfaceDecl * getObjCProtocolDecl() const
Retrieve the Objective-C class declaration corresponding to the predefined Protocol class.
unsigned NumImplicitDefaultConstructors
The number of implicitly-declared default constructors.
Definition: ASTContext.h:3248
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
unsigned NumImplicitMoveAssignmentOperatorsDeclared
The number of implicitly-declared move assignment operators for which declarations were built.
Definition: ASTContext.h:3280
void setManglingNumber(const NamedDecl *ND, unsigned Number)
llvm::DenseMap< const Decl *, const RawComment * > DeclRawComments
Mapping from declaration to directly attached comment.
Definition: ASTContext.h:826
CanQualType OCLSamplerTy
Definition: ASTContext.h:1146
TypedefDecl * getBuiltinVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_va_list type.
TypeInfo getTypeInfo(QualType T) const
Definition: ASTContext.h:2376
CanQualType VoidTy
Definition: ASTContext.h:1109
CanQualType UnsignedCharTy
Definition: ASTContext.h:1119
CanQualType UnsignedShortFractTy
Definition: ASTContext.h:1126
BuiltinTemplateDecl * buildBuiltinTemplateDecl(BuiltinTemplateKind BTK, const IdentifierInfo *II) const
void * Allocate(size_t Size, unsigned Align=8) const
Definition: ASTContext.h:730
bool canBuiltinBeRedeclared(const FunctionDecl *) const
Return whether a declaration to a builtin is allowed to be overloaded/redeclared.
CanQualType UnsignedIntTy
Definition: ASTContext.h:1119
TemplateName getDependentTemplateName(NestedNameSpecifier *NNS, const IdentifierInfo *Name) const
Retrieve the template name that represents a dependent template name such as MetaFun::template apply.
unsigned NumImplicitMoveConstructors
The number of implicitly-declared move constructors.
Definition: ASTContext.h:3262
QualType getObjCTypeParamType(const ObjCTypeParamDecl *Decl, ArrayRef< ObjCProtocolDecl * > protocols) const
QualType getVolatileType(QualType T) const
Return the uniqued reference to the type for a volatile qualified type.
Definition: ASTContext.h:1322
void getObjCEncodingForMethodParameter(Decl::ObjCDeclQualifier QT, QualType T, std::string &S, bool Extended) const
getObjCEncodingForMethodParameter - Return the encoded type for a single method parameter or return t...
void addDeclaratorForUnnamedTagDecl(TagDecl *TD, DeclaratorDecl *DD)
unsigned overridden_methods_size(const CXXMethodDecl *Method) const
std::string getObjCEncodingForBlock(const BlockExpr *blockExpr) const
Return the encoded type for this block declaration.
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
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:1919
TagDecl * getMSGuidTagDecl() const
Retrieve the implicitly-predeclared 'struct _GUID' declaration.
Definition: ASTContext.h:2179
QualType getExceptionObjectType(QualType T) const
CanQualType UnknownAnyTy
Definition: ASTContext.h:1138
void setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl, TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
Note that the static data member Inst is an instantiation of the static data member template Tmpl of ...
DeclaratorDecl * getDeclaratorForUnnamedTagDecl(const TagDecl *TD)
bool ObjCObjectAdoptsQTypeProtocols(QualType QT, ObjCInterfaceDecl *Decl)
ObjCObjectAdoptsQTypeProtocols - Checks that protocols in IC's protocol list adopt all protocols in Q...
QualType getFunctionNoProtoType(QualType ResultTy) const
Definition: ASTContext.h:1598
CanQualType UnsignedLongLongTy
Definition: ASTContext.h:1120
QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error, unsigned *IntegerConstantArgs=nullptr) const
Return the type for the specified builtin.
QualType getCommonSugaredType(QualType X, QualType Y, bool Unqualified=false)
CanQualType OCLReserveIDTy
Definition: ASTContext.h:1147
bool isSameTemplateParameter(const NamedDecl *X, const NamedDecl *Y) const
Determine whether two template parameters are similar enough that they may be used in declarations of...
size_t getASTAllocatedMemory() const
Return the total amount of physical memory allocated for representing AST nodes and type information.
Definition: ASTContext.h:758
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
overridden_cxx_method_iterator overridden_methods_begin(const CXXMethodDecl *Method) const
CanQualType UnsignedShortTy
Definition: ASTContext.h:1119
unsigned getTypeAlignIfKnown(QualType T, bool NeedsPreferredAlignment=false) const
Return the alignment of a type, in bits, or 0 if the type is incomplete and we cannot determine the a...
QualType getObjCConstantStringInterface() const
Definition: ASTContext.h:1892
bool AtomicUsesUnsupportedLibcall(const AtomicExpr *E) const
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:1603
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
bool canAssignObjCInterfacesInBlockPointer(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT, bool BlockReturnType)
canAssignObjCInterfacesInBlockPointer - This routine is specifically written for providing type-safet...
CanQualType SatUnsignedLongFractTy
Definition: ASTContext.h:1132
void setcudaConfigureCallDecl(FunctionDecl *FD)
Definition: ASTContext.h:1455
CanQualType getDecayedType(CanQualType T) const
Definition: ASTContext.h:1402
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:1906
const CXXConstructorDecl * getCopyConstructorForExceptionObject(CXXRecordDecl *RD)
QualType getDependentAddressSpaceType(QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttrLoc) const
QualType getPackIndexingType(QualType Pattern, Expr *IndexExpr, bool FullySubstituted=false, ArrayRef< QualType > Expansions={}, int Index=-1) const
RawComment * getRawCommentForDeclNoCache(const Decl *D) const
Return the documentation comment attached to a given declaration, without looking into cache.
Definition: ASTContext.cpp:295
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
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:3067
const VariableArrayType * getAsVariableArrayType(QualType T) const
Definition: ASTContext.h:2812
QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType, UnaryTransformType::UTTKind UKind) const
Unary type transforms.
const Type * getCanonicalType(const Type *T) const
Definition: ASTContext.h:2620
void setExternalSource(IntrusiveRefCntPtr< ExternalASTSource > Source)
Attach an external AST source to the AST context.
Definition: ASTContext.cpp:949
const ObjCInterfaceDecl * getObjContainingInterface(const NamedDecl *ND) const
Returns the Objective-C interface that ND belongs to if it is an Objective-C method/property/ivar etc...
CanQualType ShortTy
Definition: ASTContext.h:1118
StringLiteral * getPredefinedStringLiteralFromCache(StringRef Key) const
Return a string representing the human readable name for the specified function declaration or file n...
bool UnwrapSimilarTypes(QualType &T1, QualType &T2, bool AllowPiMismatch=true)
Attempt to unwrap two types that may be similar (C++ [conv.qual]).
llvm::APFixedPoint getFixedPointMax(QualType Ty) const
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type.
bool areCompatibleSveTypes(QualType FirstType, QualType SecondType)
Return true if the given types are an SVE builtin and a VectorType that is a fixed-length representat...
void setObjCClassRedefinitionType(QualType RedefType)
Set the user-written type that redefines 'SEL'.
Definition: ASTContext.h:1926
bool hasDirectOwnershipQualifier(QualType Ty) const
Return true if the type has been explicitly qualified with ObjC ownership.
CanQualType FractTy
Definition: ASTContext.h:1125