clang 24.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"
28#include "clang/AST/Type.h"
30#include "clang/Basic/LLVM.h"
33#include "clang/Lex/MacroBase.h"
34#include "llvm/ADT/DenseMap.h"
35#include "llvm/ADT/DenseMapInfo.h"
36#include "llvm/ADT/DenseSet.h"
37#include "llvm/ADT/FoldingSet.h"
38#include "llvm/ADT/IntrusiveRefCntPtr.h"
39#include "llvm/ADT/MapVector.h"
40#include "llvm/ADT/PointerIntPair.h"
41#include "llvm/ADT/PointerUnion.h"
42#include "llvm/ADT/SetVector.h"
43#include "llvm/ADT/SmallPtrSet.h"
44#include "llvm/ADT/SmallVector.h"
45#include "llvm/ADT/StringMap.h"
46#include "llvm/ADT/StringRef.h"
47#include "llvm/ADT/StringSet.h"
48#include "llvm/ADT/TinyPtrVector.h"
49#include "llvm/Support/TypeSize.h"
50#include <functional>
51#include <optional>
52
53namespace llvm {
54
55class APFixedPoint;
57struct fltSemantics;
58template <typename T, unsigned N> class SmallPtrSet;
59
62 unsigned NumElts;
63 unsigned NumFields;
64
65 bool operator==(const ScalableVecTyKey &RHS) const {
66 return EltTy == RHS.EltTy && NumElts == RHS.NumElts &&
67 NumFields == RHS.NumFields;
68 }
69};
70
71// Provide a DenseMapInfo specialization so that ScalableVecTyKey can be used
72// as a key in DenseMap.
73template <> struct DenseMapInfo<ScalableVecTyKey> {
74 static unsigned getHashValue(const ScalableVecTyKey &Val) {
75 return hash_combine(DenseMapInfo<clang::QualType>::getHashValue(Val.EltTy),
76 Val.NumElts, Val.NumFields);
77 }
78 static bool isEqual(const ScalableVecTyKey &LHS,
79 const ScalableVecTyKey &RHS) {
80 return LHS == RHS;
81 }
82};
83
84} // namespace llvm
85
86namespace clang {
87
88class APValue;
90class ASTRecordLayout;
91class AtomicExpr;
92class BlockExpr;
93struct BlockVarCopyInit;
95class CharUnits;
96class ConceptDecl;
97class CXXABI;
99class CXXMethodDecl;
100class CXXRecordDecl;
102class DynTypedNodeList;
103class Expr;
105enum class FloatModeKind;
106class GlobalDecl;
107class IdentifierTable;
108class LangOptions;
109class MangleContext;
112class Module;
113struct MSGuidDeclParts;
115class NoSanitizeList;
116class ObjCCategoryDecl;
119class ObjCImplDecl;
122class ObjCIvarDecl;
123class ObjCMethodDecl;
124class ObjCPropertyDecl;
126class ObjCProtocolDecl;
128class OMPTraitInfo;
129class ParentMapContext;
130struct ParsedTargetAttr;
131class Preprocessor;
132class ProfileList;
133class StoredDeclsMap;
134class TargetAttr;
135class TargetInfo;
136class TemplateDecl;
140class TypeConstraint;
142class UsingShadowDecl;
143class VarTemplateDecl;
146
147/// A simple array of base specifiers.
149
150namespace Builtin {
151
152class Context;
153
154} // namespace Builtin
155
158
159namespace comments {
160
161class FullComment;
162
163} // namespace comments
164
165namespace interp {
166
167class Context;
168
169} // namespace interp
170
171namespace serialization {
172template <class> class AbstractTypeReader;
173} // namespace serialization
174
176 /// The alignment was not explicit in code.
178
179 /// The alignment comes from an alignment attribute on a typedef.
181
182 /// The alignment comes from an alignment attribute on a record type.
184
185 /// The alignment comes from an alignment attribute on a enum type.
187
188 /// The type's natural alignment is preserved under #pragma pack in MSVC
189 /// record layout (e.g., vectors, x87 fp80).
191};
192
207
222
227
228/// UniquingSet info for pools keyed on a QualType and a bool. DenseMapInfo has
229/// no bool specialization, so we cannot use the default UniquingSetInfo.
231 using KeyTy = std::pair<QualType, bool>;
232
233 template <typename T> static KeyTy getKey(const T &N) { return N.getKey(); }
234
235 static unsigned getHashValue(const KeyTy &Key) {
236 return llvm::hash_combine(Key.first.getAsOpaquePtr(), Key.second);
237 }
238
239 template <typename T> static bool isEqual(const KeyTy &Key, const T &N) {
240 return Key == N.getKey();
241 }
242};
243
244/// Holds long-lived AST nodes (such as types and decls) that can be
245/// referred to throughout the semantic analysis of a file.
246class ASTContext : public RefCountedBase<ASTContext> {
248
249 /// The number of types created so far, per type class.
250 mutable unsigned NumTypes[Type::TypeLast + 1] = {};
251 /// All RecordType and InjectedClassNameType nodes, in creation order.
252 mutable SmallVector<Type *, 0> RecordTypes;
253 mutable llvm::FoldingSet<ExtQuals> ExtQualNodes;
254 mutable llvm::UniquingSet<ComplexType> ComplexTypes;
255 mutable llvm::UniquingSet<PointerType> PointerTypes{GeneralTypesLog2InitSize};
256 mutable llvm::UniquingSet<AdjustedType> AdjustedTypes;
257 mutable llvm::UniquingSet<BlockPointerType> BlockPointerTypes;
258 mutable llvm::UniquingSet<LValueReferenceType, QualTypeBoolInfo>
259 LValueReferenceTypes;
260 mutable llvm::UniquingSet<RValueReferenceType, QualTypeBoolInfo>
261 RValueReferenceTypes;
262 mutable llvm::FoldingSet<MemberPointerType> MemberPointerTypes;
263 mutable llvm::ContextualFoldingSet<ConstantArrayType, ASTContext &>
264 ConstantArrayTypes;
265 mutable llvm::FoldingSet<IncompleteArrayType> IncompleteArrayTypes;
266 mutable std::vector<VariableArrayType*> VariableArrayTypes;
267 mutable llvm::ContextualFoldingSet<DependentSizedArrayType, ASTContext &>
268 DependentSizedArrayTypes;
269 mutable llvm::ContextualFoldingSet<DependentSizedExtVectorType, ASTContext &>
270 DependentSizedExtVectorTypes;
271 mutable llvm::ContextualFoldingSet<DependentAddressSpaceType, ASTContext &>
272 DependentAddressSpaceTypes;
273 mutable llvm::FoldingSet<VectorType> VectorTypes;
274 mutable llvm::ContextualFoldingSet<DependentVectorType, ASTContext &>
275 DependentVectorTypes;
276 mutable llvm::FoldingSet<ConstantMatrixType> MatrixTypes;
277 mutable llvm::FoldingSet<CooperativeMatrixType> CooperativeMatrixTypes;
278 mutable llvm::ContextualFoldingSet<DependentSizedMatrixType, ASTContext &>
279 DependentSizedMatrixTypes;
280 mutable llvm::FoldingSet<FunctionNoProtoType> FunctionNoProtoTypes;
281 mutable llvm::ContextualFoldingSet<FunctionProtoType, ASTContext&>
282 FunctionProtoTypes;
283 mutable llvm::ContextualFoldingSet<DependentTypeOfExprType, ASTContext &>
284 DependentTypeOfExprTypes;
285 mutable llvm::ContextualFoldingSet<DependentDecltypeType, ASTContext &>
286 DependentDecltypeTypes;
287
288 mutable llvm::ContextualFoldingSet<PackIndexingType, ASTContext &>
289 DependentPackIndexingTypes;
290
291 mutable llvm::UniquingSet<TemplateTypeParmType> TemplateTypeParmTypes;
292 mutable llvm::UniquingSet<ObjCTypeParamType> ObjCTypeParamTypes;
293 mutable llvm::UniquingSet<SubstTemplateTypeParmType>
294 SubstTemplateTypeParmTypes;
295 mutable llvm::FoldingSet<SubstTemplateTypeParmPackType>
296 SubstTemplateTypeParmPackTypes;
297 mutable llvm::FoldingSet<SubstBuiltinTemplatePackType>
298 SubstBuiltinTemplatePackTypes;
299 mutable llvm::ContextualFoldingSet<TemplateSpecializationType, ASTContext&>
300 TemplateSpecializationTypes;
301 mutable llvm::UniquingSet<ParenType> ParenTypes{GeneralTypesLog2InitSize};
302 mutable llvm::FoldingSet<TagTypeFoldingSetPlaceholder> TagTypes;
303 mutable llvm::FoldingSet<FoldingSetPlaceholder<UnresolvedUsingType>>
304 UnresolvedUsingTypes;
305 mutable llvm::FoldingSet<UsingType> UsingTypes;
306 mutable llvm::FoldingSet<FoldingSetPlaceholder<TypedefType>> TypedefTypes;
307 mutable llvm::FoldingSet<DependentNameType> DependentNameTypes;
308 mutable llvm::UniquingSet<PackExpansionType> PackExpansionTypes;
309 mutable llvm::FoldingSet<ObjCObjectTypeImpl> ObjCObjectTypes;
310 mutable llvm::UniquingSet<ObjCObjectPointerType> ObjCObjectPointerTypes;
311 mutable llvm::UniquingSet<UnaryTransformType> UnaryTransformTypes;
312 // An AutoType can have a dependency on another AutoType via its template
313 // arguments. Since both dependent and dependency are on the same set,
314 // we can end up in an infinite recursion when looking for a node if we used
315 // a `FoldingSet`, since both could end up in the same bucket.
316 // Keyed by an interned FoldingSetNodeIDRef rather than a FoldingSetNodeID to
317 // avoid its large inline SmallVector in every bucket.
318 mutable llvm::DenseMap<llvm::FoldingSetNodeIDRef, AutoType *> AutoTypes;
319 mutable llvm::FoldingSet<DeducedTemplateSpecializationType>
320 DeducedTemplateSpecializationTypes;
321 mutable llvm::UniquingSet<AtomicType> AtomicTypes;
322 mutable llvm::ContextualFoldingSet<AttributedType, ASTContext &>
323 AttributedTypes;
324 mutable llvm::UniquingSet<PipeType, QualTypeBoolInfo> PipeTypes;
325 mutable llvm::UniquingSet<BitIntType> BitIntTypes;
326 mutable llvm::ContextualFoldingSet<DependentBitIntType, ASTContext &>
327 DependentBitIntTypes;
328 mutable llvm::FoldingSet<BTFTagAttributedType> BTFTagAttributedTypes;
329 mutable llvm::UniquingSet<OverflowBehaviorType> OverflowBehaviorTypes;
330 mutable llvm::ContextualFoldingSet<HLSLAttributedResourceType, ASTContext &>
331 HLSLAttributedResourceTypes;
332 llvm::FoldingSet<HLSLInlineSpirvType> HLSLInlineSpirvTypes;
333
334 mutable llvm::FoldingSet<CountAttributedType> CountAttributedTypes;
335
336 mutable llvm::FoldingSet<QualifiedTemplateName> QualifiedTemplateNames;
337 mutable llvm::FoldingSet<DependentTemplateName> DependentTemplateNames;
338 mutable llvm::FoldingSet<SubstTemplateTemplateParmStorage>
339 SubstTemplateTemplateParms;
340 mutable llvm::ContextualFoldingSet<SubstTemplateTemplateParmPackStorage,
341 ASTContext&>
342 SubstTemplateTemplateParmPacks;
343 mutable llvm::ContextualFoldingSet<DeducedTemplateStorage, ASTContext &>
344 DeducedTemplates;
345 mutable llvm::ContextualFoldingSet<PackIndexingTemplateStorage, ASTContext &>
346 PackIndexingTemplates;
347
348 mutable llvm::ContextualFoldingSet<ArrayParameterType, ASTContext &>
349 ArrayParameterTypes;
350
351 /// Store the unique Type corresponding to each Kind.
352 mutable std::array<Type *,
353 llvm::to_underlying(PredefinedSugarType::Kind::Last) + 1>
354 PredefinedSugarTypes{};
355
356 /// Internal storage for NestedNameSpecifiers.
357 ///
358 /// This set is managed by the NestedNameSpecifier class.
359 mutable llvm::UniquingSet<NamespaceAndPrefixStorage>
360 NamespaceAndPrefixStorages;
361
362 /// A cache mapping from RecordDecls to ASTRecordLayouts.
363 ///
364 /// This is lazily created. This is intentionally not serialized.
365 mutable llvm::DenseMap<const RecordDecl*, const ASTRecordLayout*>
366 ASTRecordLayouts;
367 mutable llvm::DenseMap<const ObjCInterfaceDecl *, const ASTRecordLayout *>
368 ObjCLayouts;
369
370 /// A cache from types to size and alignment information.
371 using TypeInfoMap = llvm::DenseMap<const Type *, struct TypeInfo>;
372 mutable TypeInfoMap MemoizedTypeInfo;
373
374 /// A cache from types to unadjusted alignment information. Only ARM and
375 /// AArch64 targets need this information, keeping it separate prevents
376 /// imposing overhead on TypeInfo size.
377 using UnadjustedAlignMap = llvm::DenseMap<const Type *, unsigned>;
378 mutable UnadjustedAlignMap MemoizedUnadjustedAlign;
379
380 /// A cache mapping from CXXRecordDecls to key functions.
381 llvm::DenseMap<const CXXRecordDecl*, LazyDeclPtr> KeyFunctions;
382
383 /// Mapping from ObjCContainers to their ObjCImplementations.
384 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*> ObjCImpls;
385
386 /// Mapping from ObjCMethod to its duplicate declaration in the same
387 /// interface.
388 llvm::DenseMap<const ObjCMethodDecl*,const ObjCMethodDecl*> ObjCMethodRedecls;
389
390 /// Mapping from __block VarDecls to BlockVarCopyInit.
391 llvm::DenseMap<const VarDecl *, BlockVarCopyInit> BlockVarCopyInits;
392
393 /// Mapping from GUIDs to the corresponding MSGuidDecl.
394 mutable llvm::FoldingSet<MSGuidDecl> MSGuidDecls;
395
396 /// Mapping from APValues to the corresponding UnnamedGlobalConstantDecl.
397 mutable llvm::FoldingSet<UnnamedGlobalConstantDecl>
398 UnnamedGlobalConstantDecls;
399
400 /// Mapping from APValues to the corresponding TemplateParamObjects.
401 mutable llvm::FoldingSet<TemplateParamObjectDecl> TemplateParamObjectDecls;
402
403 /// A cache mapping a string value to a StringLiteral object with the same
404 /// value.
405 ///
406 /// This is lazily created. This is intentionally not serialized.
407 mutable llvm::StringMap<StringLiteral *> StringLiteralCache;
408
409 mutable llvm::DenseSet<const FunctionDecl *> DestroyingOperatorDeletes;
410 mutable llvm::DenseSet<const FunctionDecl *> TypeAwareOperatorNewAndDeletes;
411
412 /// Global and array operators delete are only required for MSVC deleting
413 /// destructors support. Store them here to avoid keeping 4 pointers that are
414 /// not always used in each redeclaration of the destructor.
415 mutable llvm::DenseMap<const CXXDestructorDecl *, FunctionDecl *>
416 OperatorDeletesForVirtualDtor;
417 mutable llvm::DenseMap<const CXXDestructorDecl *, FunctionDecl *>
418 GlobalOperatorDeletesForVirtualDtor;
419 mutable llvm::DenseMap<const CXXDestructorDecl *, FunctionDecl *>
420 ArrayOperatorDeletesForVirtualDtor;
421 mutable llvm::DenseMap<const CXXDestructorDecl *, FunctionDecl *>
422 GlobalArrayOperatorDeletesForVirtualDtor;
423
424 /// To remember for which types we met new[] call, these potentially require a
425 /// vector deleting dtor.
426 llvm::DenseSet<const CXXRecordDecl *> MaybeRequireVectorDeletingDtor;
427
428 /// The next string literal "version" to allocate during constant evaluation.
429 /// This is used to distinguish between repeated evaluations of the same
430 /// string literal.
431 ///
432 /// We don't need to serialize this because constants get re-evaluated in the
433 /// current file before they are compared locally.
434 unsigned NextStringLiteralVersion = 0;
435
436 /// MD5 hash of CUID. It is calculated when first used and cached by this
437 /// data member.
438 mutable std::string CUIDHash;
439
440 /// Representation of a "canonical" template template parameter that
441 /// is used in canonical template names.
442 class CanonicalTemplateTemplateParm : public llvm::FoldingSetNode {
443 TemplateTemplateParmDecl *Parm;
444
445 public:
446 CanonicalTemplateTemplateParm(TemplateTemplateParmDecl *Parm)
447 : Parm(Parm) {}
448
449 TemplateTemplateParmDecl *getParam() const { return Parm; }
450
451 void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &C) {
452 Profile(ID, C, Parm);
453 }
454
455 static void Profile(llvm::FoldingSetNodeID &ID,
456 const ASTContext &C,
457 TemplateTemplateParmDecl *Parm);
458 };
459 mutable llvm::ContextualFoldingSet<CanonicalTemplateTemplateParm,
460 const ASTContext&>
461 CanonTemplateTemplateParms;
462
463 /// The typedef for the __int128_t type.
464 mutable TypedefDecl *Int128Decl = nullptr;
465
466 /// The typedef for the __uint128_t type.
467 mutable TypedefDecl *UInt128Decl = nullptr;
468
469 /// The typedef for the target specific predefined
470 /// __builtin_va_list type.
471 mutable TypedefDecl *BuiltinVaListDecl = nullptr;
472
473 /// The typedef for the predefined \c __builtin_ms_va_list type.
474 mutable TypedefDecl *BuiltinMSVaListDecl = nullptr;
475
476 /// The typedef for the predefined \c __builtin_zos_va_list type.
477 mutable TypedefDecl *BuiltinZOSVaListDecl = nullptr;
478
479 /// The typedef for the predefined \c id type.
480 mutable TypedefDecl *ObjCIdDecl = nullptr;
481
482 /// The typedef for the predefined \c SEL type.
483 mutable TypedefDecl *ObjCSelDecl = nullptr;
484
485 /// The typedef for the predefined \c Class type.
486 mutable TypedefDecl *ObjCClassDecl = nullptr;
487
488 /// The typedef for the predefined \c Protocol class in Objective-C.
489 mutable ObjCInterfaceDecl *ObjCProtocolClassDecl = nullptr;
490
491 /// The typedef for the predefined 'BOOL' type.
492 mutable TypedefDecl *BOOLDecl = nullptr;
493
494 // Typedefs which may be provided defining the structure of Objective-C
495 // pseudo-builtins
496 QualType ObjCIdRedefinitionType;
497 QualType ObjCClassRedefinitionType;
498 QualType ObjCSelRedefinitionType;
499
500 /// The identifier 'bool'.
501 mutable IdentifierInfo *BoolName = nullptr;
502
503 /// The identifier 'NSObject'.
504 mutable IdentifierInfo *NSObjectName = nullptr;
505
506 /// The identifier 'NSCopying'.
507 IdentifierInfo *NSCopyingName = nullptr;
508
509#define BuiltinTemplate(BTName) mutable IdentifierInfo *Name##BTName = nullptr;
510#include "clang/Basic/BuiltinTemplates.inc"
511
512 QualType ObjCConstantStringType;
513 mutable RecordDecl *CFConstantStringTagDecl = nullptr;
514 mutable TypedefDecl *CFConstantStringTypeDecl = nullptr;
515
516 mutable QualType ObjCSuperType;
517
518 QualType ObjCNSStringType;
519
520 /// The typedef declaration for the Objective-C "instancetype" type.
521 TypedefDecl *ObjCInstanceTypeDecl = nullptr;
522
523 /// The type for the C FILE type.
524 TypeDecl *FILEDecl = nullptr;
525
526 /// The type for the C jmp_buf type.
527 TypeDecl *jmp_bufDecl = nullptr;
528
529 /// The type for the C sigjmp_buf type.
530 TypeDecl *sigjmp_bufDecl = nullptr;
531
532 /// The type for the C ucontext_t type.
533 TypeDecl *ucontext_tDecl = nullptr;
534
535 /// Type for the Block descriptor for Blocks CodeGen.
536 ///
537 /// Since this is only used for generation of debug info, it is not
538 /// serialized.
539 mutable RecordDecl *BlockDescriptorType = nullptr;
540
541 /// Type for the Block descriptor for Blocks CodeGen.
542 ///
543 /// Since this is only used for generation of debug info, it is not
544 /// serialized.
545 mutable RecordDecl *BlockDescriptorExtendedType = nullptr;
546
547 /// Declaration for the CUDA cudaConfigureCall function.
548 FunctionDecl *cudaConfigureCallDecl = nullptr;
549 /// Declaration for the CUDA cudaGetParameterBuffer function.
550 FunctionDecl *cudaGetParameterBufferDecl = nullptr;
551 /// Declaration for the CUDA cudaLaunchDevice function.
552 FunctionDecl *cudaLaunchDeviceDecl = nullptr;
553
554 llvm::DenseMap<const CXXConstructorDecl *, ArrayRef<CXXDefaultArgExpr *>>
555 CtorClosureDefaultArgs;
556
557 /// Storage for the AttrVecs pointed to by Decl::Attrs.
558 ///
559 /// A SpecificBumpPtrAllocator so that the vectors are destroyed when the
560 /// context dies without having to track them individually.
561 llvm::SpecificBumpPtrAllocator<AttrVec> DeclAttrAllocator;
562
563 /// A mapping from non-redeclarable declarations in modules that were
564 /// merged with other declarations to the canonical declaration that they were
565 /// merged into.
566 llvm::DenseMap<Decl*, Decl*> MergedDecls;
567
568 /// A mapping from a defining declaration to a list of modules (other
569 /// than the owning module of the declaration) that contain merged
570 /// definitions of that entity.
571 llvm::DenseMap<NamedDecl*, llvm::TinyPtrVector<Module*>> MergedDefModules;
572
573 /// Initializers for a module, in order. Each Decl will be either
574 /// something that has a semantic effect on startup (such as a variable with
575 /// a non-constant initializer), or an ImportDecl (which recursively triggers
576 /// initialization of another module).
577 struct PerModuleInitializers {
578 llvm::SmallVector<Decl*, 4> Initializers;
579 llvm::SmallVector<GlobalDeclID, 4> LazyInitializers;
580
581 void resolve(ASTContext &Ctx);
582 };
583 llvm::DenseMap<Module*, PerModuleInitializers*> ModuleInitializers;
584
585 /// This is the top-level (C++20) Named module we are building.
586 Module *CurrentCXXNamedModule = nullptr;
587
588 /// Help structures to decide whether two `const Module *` belongs
589 /// to the same conceptual module to avoid the expensive to string comparison
590 /// if possible.
591 ///
592 /// Not serialized intentionally.
593 mutable llvm::StringMap<const Module *> PrimaryModuleNameMap;
594 mutable llvm::DenseMap<const Module *, const Module *> SameModuleLookupSet;
595
596 static constexpr unsigned ConstantArrayTypesLog2InitSize = 8;
597 static constexpr unsigned GeneralTypesLog2InitSize = 9;
598 static constexpr unsigned FunctionProtoTypesLog2InitSize = 12;
599
600 /// A mapping from an ObjC class to its subclasses.
601 llvm::DenseMap<const ObjCInterfaceDecl *,
602 SmallVector<const ObjCInterfaceDecl *, 4>>
603 ObjCSubClasses;
604
605 // A mapping from Scalable Vector Type keys to their corresponding QualType.
606 mutable llvm::DenseMap<llvm::ScalableVecTyKey, QualType> ScalableVecTyMap;
607
608 ASTContext &this_() { return *this; }
609
610public:
611 /// A type synonym for the TemplateOrInstantiation mapping.
613 llvm::PointerUnion<VarTemplateDecl *, MemberSpecializationInfo *>;
614
615private:
616 friend class ASTDeclReader;
617 friend class ASTReader;
618 friend class ASTWriter;
619 template <class> friend class serialization::AbstractTypeReader;
620 friend class CXXRecordDecl;
621 friend class IncrementalParser;
622
623 /// A mapping to contain the template or declaration that
624 /// a variable declaration describes or was instantiated from,
625 /// respectively.
626 ///
627 /// For non-templates, this value will be NULL. For variable
628 /// declarations that describe a variable template, this will be a
629 /// pointer to a VarTemplateDecl. For static data members
630 /// of class template specializations, this will be the
631 /// MemberSpecializationInfo referring to the member variable that was
632 /// instantiated or specialized. Thus, the mapping will keep track of
633 /// the static data member templates from which static data members of
634 /// class template specializations were instantiated.
635 ///
636 /// Given the following example:
637 ///
638 /// \code
639 /// template<typename T>
640 /// struct X {
641 /// static T value;
642 /// };
643 ///
644 /// template<typename T>
645 /// T X<T>::value = T(17);
646 ///
647 /// int *x = &X<int>::value;
648 /// \endcode
649 ///
650 /// This mapping will contain an entry that maps from the VarDecl for
651 /// X<int>::value to the corresponding VarDecl for X<T>::value (within the
652 /// class template X) and will be marked TSK_ImplicitInstantiation.
653 llvm::DenseMap<const VarDecl *, TemplateOrSpecializationInfo>
654 TemplateOrInstantiation;
655
656 /// Keeps track of the declaration from which a using declaration was
657 /// created during instantiation.
658 ///
659 /// The source and target declarations are always a UsingDecl, an
660 /// UnresolvedUsingValueDecl, or an UnresolvedUsingTypenameDecl.
661 ///
662 /// For example:
663 /// \code
664 /// template<typename T>
665 /// struct A {
666 /// void f();
667 /// };
668 ///
669 /// template<typename T>
670 /// struct B : A<T> {
671 /// using A<T>::f;
672 /// };
673 ///
674 /// template struct B<int>;
675 /// \endcode
676 ///
677 /// This mapping will contain an entry that maps from the UsingDecl in
678 /// B<int> to the UnresolvedUsingDecl in B<T>.
679 llvm::DenseMap<NamedDecl *, NamedDecl *> InstantiatedFromUsingDecl;
680
681 /// Like InstantiatedFromUsingDecl, but for using-enum-declarations. Maps
682 /// from the instantiated using-enum to the templated decl from whence it
683 /// came.
684 /// Note that using-enum-declarations cannot be dependent and
685 /// thus will never be instantiated from an "unresolved"
686 /// version thereof (as with using-declarations), so each mapping is from
687 /// a (resolved) UsingEnumDecl to a (resolved) UsingEnumDecl.
688 llvm::DenseMap<UsingEnumDecl *, UsingEnumDecl *>
689 InstantiatedFromUsingEnumDecl;
690
691 /// Similarly maps instantiated UsingShadowDecls to their origin.
692 llvm::DenseMap<UsingShadowDecl*, UsingShadowDecl*>
693 InstantiatedFromUsingShadowDecl;
694
695 llvm::DenseMap<FieldDecl *, FieldDecl *> InstantiatedFromUnnamedFieldDecl;
696
697 /// Maps a canonical specialization Decl to all ExplicitInstantiationDecls
698 /// that reference it (declarations and definitions).
699 llvm::DenseMap<const NamedDecl *,
700 llvm::TinyPtrVector<ExplicitInstantiationDecl *>>
701 ExplicitInstantiations;
702
703 /// Mapping that stores the methods overridden by a given C++
704 /// member function.
705 ///
706 /// Since most C++ member functions aren't virtual and therefore
707 /// don't override anything, we store the overridden functions in
708 /// this map on the side rather than within the CXXMethodDecl structure.
709 using CXXMethodVector = llvm::TinyPtrVector<const CXXMethodDecl *>;
710 llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector> OverriddenMethods;
711
712 /// Mapping from each declaration context to its corresponding
713 /// mangling numbering context (used for constructs like lambdas which
714 /// need to be consistently numbered for the mangler).
715 llvm::DenseMap<const DeclContext *, std::unique_ptr<MangleNumberingContext>>
716 MangleNumberingContexts;
717 llvm::DenseMap<const Decl *, std::unique_ptr<MangleNumberingContext>>
718 ExtraMangleNumberingContexts;
719
720 /// Side-table of mangling numbers for declarations which rarely
721 /// need them (like static local vars).
722 llvm::MapVector<const NamedDecl *, unsigned> MangleNumbers;
723 llvm::MapVector<const VarDecl *, unsigned> StaticLocalNumbers;
724 /// Mapping the associated device lambda mangling number if present.
725 mutable llvm::DenseMap<const CXXRecordDecl *, unsigned>
726 DeviceLambdaManglingNumbers;
727
728 /// Mapping that stores parameterIndex values for ParmVarDecls when
729 /// that value exceeds the bitfield size of ParmVarDeclBits.ParameterIndex.
730 using ParameterIndexTable = llvm::DenseMap<const VarDecl *, unsigned>;
731 ParameterIndexTable ParamIndices;
732
733 /// Map from numbering information for lambdas to the corresponding lambdas.
734 /// This is intentionally not serialized, and is instead reconstructed as we
735 /// read each lambda.
736 llvm::DenseMap<std::pair<const Decl *, unsigned>, CXXRecordDecl *>
737 LambdaDeclarationsForMerging;
738
739public:
743 std::optional<CXXRecordDeclRelocationInfo>
747
748 // Returns a reference to the first lambda declaration with a given index in a
749 // given context. Used to merge lambdas in the case where the same lambda is
750 // redefined in multiple modules.
752 int IndexInContext) {
753 return LambdaDeclarationsForMerging[{ContextDecl->getCanonicalDecl(),
754 IndexInContext}];
755 }
756
757 /// Examines a given type, and returns whether the type itself
758 /// is address discriminated, or any transitively embedded types
759 /// contain data that is address discriminated. This includes
760 /// implicitly authenticated values like vtable pointers, as well as
761 /// explicitly qualified fields.
763 if (!isPointerAuthenticationAvailable())
764 return false;
765 return findPointerAuthContent(T) != PointerAuthContent::None;
766 }
767
768 /// Examines a given type, and returns whether the type itself
769 /// or any data it transitively contains has a pointer authentication
770 /// schema that is not safely relocatable. e.g. any data or fields
771 /// with address discrimination other than any otherwise similar
772 /// vtable pointers.
774 if (!isPointerAuthenticationAvailable())
775 return false;
776 return findPointerAuthContent(T) != PointerAuthContent::None;
777 }
778
779private:
780 llvm::DenseMap<const CXXRecordDecl *, CXXRecordDeclRelocationInfo>
781 RelocatableClasses;
782
783 // FIXME: store in RecordDeclBitfields in future?
784 enum class PointerAuthContent : uint8_t {
785 None,
786 AddressDiscriminatedVTable,
787 AddressDiscriminatedData
788 };
789
790 // A simple helper function to short circuit pointer auth checks.
791 bool isPointerAuthenticationAvailable() const {
792 return LangOpts.PointerAuthCalls || LangOpts.PointerAuthIntrinsics;
793 }
794 PointerAuthContent findPointerAuthContent(QualType T) const;
795 mutable llvm::DenseMap<const RecordDecl *, PointerAuthContent>
796 RecordContainsAddressDiscriminatedPointerAuth;
797
798 ImportDecl *FirstLocalImport = nullptr;
799 ImportDecl *LastLocalImport = nullptr;
800
801 TranslationUnitDecl *TUDecl = nullptr;
802 mutable ExternCContextDecl *ExternCContext = nullptr;
803
804#define BuiltinTemplate(BTName) \
805 mutable BuiltinTemplateDecl *Decl##BTName = nullptr;
806#include "clang/Basic/BuiltinTemplates.inc"
807
808 /// The associated SourceManager object.
809 SourceManager &SourceMgr;
810
811 /// The language options used to create the AST associated with
812 /// this ASTContext object.
813 LangOptions &LangOpts;
814
815 /// NoSanitizeList object that is used by sanitizers to decide which
816 /// entities should not be instrumented.
817 std::unique_ptr<NoSanitizeList> NoSanitizeL;
818
819 /// Function filtering mechanism to determine whether a given function
820 /// should be imbued with the XRay "always" or "never" attributes.
821 std::unique_ptr<XRayFunctionFilter> XRayFilter;
822
823 /// ProfileList object that is used by the profile instrumentation
824 /// to decide which entities should be instrumented.
825 std::unique_ptr<ProfileList> ProfList;
826
827 /// The allocator used to create AST objects.
828 ///
829 /// AST objects are never destructed; rather, all memory associated with the
830 /// AST objects will be released when the ASTContext itself is destroyed.
831 mutable llvm::BumpPtrAllocator BumpAlloc;
832
833 /// Allocator for partial diagnostics.
835
836 /// The current C++ ABI.
837 std::unique_ptr<CXXABI> ABI;
838 CXXABI *createCXXABI(const TargetInfo &T);
839
840 /// Address space map mangling must be used with language specific
841 /// address spaces (e.g. OpenCL/CUDA)
842 bool AddrSpaceMapMangling;
843
844 /// For performance, track whether any function effects are in use.
845 mutable bool AnyFunctionEffects = false;
846
847 const TargetInfo *Target = nullptr;
848 const TargetInfo *AuxTarget = nullptr;
849 mutable llvm::DenseMap<std::pair<llvm::StringRef, unsigned>,
850 std::unique_ptr<llvm::StringMap<bool>>>
851 FunctionFeatureMaps;
852 clang::PrintingPolicy PrintingPolicy;
853 mutable std::unique_ptr<interp::Context> InterpContext;
854 std::unique_ptr<ParentMapContext> ParentMapCtx;
855
856 /// Keeps track of the deallocated DeclListNodes for future reuse.
857 DeclListNode *ListNodeFreeList = nullptr;
858
859 std::function<bool(const NamedDecl *)> DeclVisibilityCallback;
860
861public:
869
870 /// Returns the clang bytecode interpreter context.
872
874 /// Do not allow wrong-sided variables in constant expressions.
875 bool NoWrongSidedVars = false;
886
887 /// Returns the dynamic AST node parent map context.
888 ParentMapContext &getParentMapContext() { return *ParentMapCtx; }
889
890 // A traversal scope limits the parts of the AST visible to certain analyses.
891 // RecursiveASTVisitor only visits specified children of TranslationUnitDecl.
892 // getParents() will only observe reachable parent edges.
893 //
894 // The scope is defined by a set of "top-level" declarations which will be
895 // visible under the TranslationUnitDecl.
896 // Initially, it is the entire TU, represented by {getTranslationUnitDecl()}.
897 //
898 // After setTraversalScope({foo, bar}), the exposed AST looks like:
899 // TranslationUnitDecl
900 // - foo
901 // - ...
902 // - bar
903 // - ...
904 // All other siblings of foo and bar are pruned from the tree.
905 // (However they are still accessible via TranslationUnitDecl->decls())
906 //
907 // Changing the scope clears the parent cache, which is expensive to rebuild.
908 ArrayRef<Decl *> getTraversalScope() const { return TraversalScope; }
909 void setTraversalScope(const std::vector<Decl *> &);
910
911 /// Forwards to get node parents from the ParentMapContext. New callers should
912 /// use ParentMapContext::getParents() directly.
913 template <typename NodeT> DynTypedNodeList getParents(const NodeT &Node);
914
916 return PrintingPolicy;
917 }
918
920 PrintingPolicy = Policy;
921 }
922
923 SourceManager& getSourceManager() { return SourceMgr; }
924 const SourceManager& getSourceManager() const { return SourceMgr; }
925
926 // Cleans up some of the data structures. This allows us to do cleanup
927 // normally done in the destructor earlier. Renders much of the ASTContext
928 // unusable, mostly the actual AST nodes, so should be called when we no
929 // longer need access to the AST.
930 void cleanup();
931
932 llvm::BumpPtrAllocator &getAllocator() const {
933 return BumpAlloc;
934 }
935
936 void *Allocate(size_t Size, unsigned Align = 8) const {
937 return BumpAlloc.Allocate(Size, Align);
938 }
939 template <typename T> T *Allocate(size_t Num = 1) const {
940 return static_cast<T *>(Allocate(Num * sizeof(T), alignof(T)));
941 }
942 void Deallocate(void *Ptr) const {}
943
944 llvm::StringRef backupStr(llvm::StringRef S) const {
945 char *Buf = new (*this) char[S.size()];
946 llvm::copy(S, Buf);
947 return llvm::StringRef(Buf, S.size());
948 }
949
950 /// Allocates a \c DeclListNode or returns one from the \c ListNodeFreeList
951 /// pool.
953 if (DeclListNode *Alloc = ListNodeFreeList) {
954 ListNodeFreeList = dyn_cast_if_present<DeclListNode *>(Alloc->Rest);
955 Alloc->D = ND;
956 Alloc->Rest = nullptr;
957 return Alloc;
958 }
959 return new (*this) DeclListNode(ND);
960 }
961 /// Deallocates a \c DeclListNode by returning it to the \c ListNodeFreeList
962 /// pool.
964 N->Rest = ListNodeFreeList;
965 ListNodeFreeList = N;
966 }
967
968 /// Return the total amount of physical memory allocated for representing
969 /// AST nodes and type information.
970 size_t getASTAllocatedMemory() const {
971 return BumpAlloc.getTotalMemory();
972 }
973
974 /// Return the total memory used for various side tables.
975 size_t getSideTableAllocatedMemory() const;
976
978 return DiagAllocator;
979 }
980
981 const TargetInfo &getTargetInfo() const { return *Target; }
982 const TargetInfo *getAuxTargetInfo() const { return AuxTarget; }
983
984 const QualType GetHigherPrecisionFPType(QualType ElementType) const {
985 const auto *CurrentBT = cast<BuiltinType>(ElementType);
986 switch (CurrentBT->getKind()) {
987 case BuiltinType::Kind::Half:
988 case BuiltinType::Kind::Float16:
989 return FloatTy;
990 case BuiltinType::Kind::Float:
991 case BuiltinType::Kind::BFloat16:
992 return DoubleTy;
993 case BuiltinType::Kind::Double:
994 return LongDoubleTy;
995 default:
996 return ElementType;
997 }
998 return ElementType;
999 }
1000
1001 /// getIntTypeForBitwidth -
1002 /// sets integer QualTy according to specified details:
1003 /// bitwidth, signed/unsigned.
1004 /// Returns empty type if there is no appropriate target types.
1005 QualType getIntTypeForBitwidth(unsigned DestWidth,
1006 unsigned Signed) const;
1007
1008 QualType getLeastIntTypeForBitwidth(unsigned DestWidth,
1009 unsigned Signed) const;
1010
1011 /// getRealTypeForBitwidth -
1012 /// sets floating point QualTy according to specified bitwidth.
1013 /// Returns empty type if there is no appropriate target types.
1014 QualType getRealTypeForBitwidth(unsigned DestWidth,
1015 FloatModeKind ExplicitType) const;
1016
1017 bool AtomicUsesUnsupportedLibcall(const AtomicExpr *E) const;
1018
1019 const LangOptions& getLangOpts() const { return LangOpts; }
1020
1021 // If this condition is false, typo correction must be performed eagerly
1022 // rather than delayed in many places, as it makes use of dependent types.
1023 // the condition is false for clang's C-only codepath, as it doesn't support
1024 // dependent types yet.
1025 bool isDependenceAllowed() const {
1026 return LangOpts.CPlusPlus || LangOpts.RecoveryAST;
1027 }
1028
1029 const NoSanitizeList &getNoSanitizeList() const { return *NoSanitizeL; }
1030
1031 bool isTypeIgnoredBySanitizer(const SanitizerMask &Mask,
1032 const QualType &Ty) const;
1033
1035
1037 return *XRayFilter;
1038 }
1039
1040 const ProfileList &getProfileList() const { return *ProfList; }
1041
1043
1045 return FullSourceLoc(Loc,SourceMgr);
1046 }
1047
1048 /// Return the C++ ABI kind that should be used. The C++ ABI can be overriden
1049 /// at compile time with `-fc++-abi=`. If this is not provided, we instead use
1050 /// the default ABI set by the target.
1052
1053 /// All comments in this translation unit.
1055
1056 /// True if comments are already loaded from ExternalASTSource.
1057 mutable bool CommentsLoaded = false;
1058
1059 /// Key used to look up the raw comment attached to a declaration or macro.
1061 llvm::PointerUnion<const Decl *, const MacroInfo *>;
1062
1063 /// Mapping from declaration or macro to directly attached comment.
1064 ///
1065 /// Raw comments are owned by Comments list. This mapping is populated
1066 /// lazily.
1067 mutable llvm::DenseMap<RawCommentLookupKey, const RawComment *> RawComments;
1068
1069 /// Mapping from canonical declaration to the first redeclaration in chain
1070 /// that has a comment attached.
1071 ///
1072 /// Raw comments are owned by Comments list. This mapping is populated
1073 /// lazily.
1074 mutable llvm::DenseMap<const Decl *, const Decl *> RedeclChainComments;
1075
1076 /// Keeps track of redeclaration chains that don't have any comment attached.
1077 /// Mapping from canonical declaration to redeclaration chain that has no
1078 /// comments attached to any redeclaration. Specifically it's mapping to
1079 /// the last redeclaration we've checked.
1080 ///
1081 /// Shall not contain declarations that have comments attached to any
1082 /// redeclaration in their chain.
1083 mutable llvm::DenseMap<const Decl *, const Decl *> CommentlessRedeclChains;
1084
1085 /// Mapping from declarations to parsed comments attached to any
1086 /// redeclaration.
1087 mutable llvm::DenseMap<const Decl *, comments::FullComment *> ParsedComments;
1088
1089 /// Attaches \p Comment to \p Original (a declaration or macro), and to its
1090 /// redeclaration chain when \p Original is a declaration. Removes the
1091 /// redeclaration chain from the set of commentless chains.
1092 ///
1093 /// Don't do anything if a comment has already been attached to \p Original
1094 /// or its redeclaration chain.
1096 const RawComment &Comment) const;
1097
1098 /// \returns searches \p CommentsInFile for doc comment for \p Key.
1099 ///
1100 /// \p RepresentativeLocForDecl is used as a location for searching doc
1101 /// comments. \p CommentsInFile is a mapping offset -> comment of files in the
1102 /// same file where \p RepresentativeLocForDecl is.
1104 RawCommentLookupKey Key, const SourceLocation RepresentativeLoc,
1105 const std::map<unsigned, RawComment *> &CommentsInFile) const;
1106
1107 /// Return the documentation comment attached to a given declaration or
1108 /// macro, without looking into cache.
1110
1111public:
1112 void addComment(const RawComment &RC);
1113
1114 /// Return the documentation comment attached to a given declaration or
1115 /// macro. Returns nullptr if no comment is attached.
1116 ///
1117 /// \param OriginalDecl if not nullptr, is set to declaration AST node that
1118 /// had the comment, if the comment we found comes from a redeclaration.
1119 /// Macros have no redeclaration chain, so this is set to nullptr when
1120 /// \p Key is a \c MacroInfo.
1121 const RawComment *
1123 const Decl **OriginalDecl = nullptr) const;
1124
1125 /// Searches existing comments for doc comments that should be attached to \p
1126 /// Decls. If any doc comment is found, it is parsed.
1127 ///
1128 /// Requirement: All \p Decls are in the same file.
1129 ///
1130 /// If the last comment in the file is already attached we assume
1131 /// there are not comments left to be attached to \p Decls.
1133 const Preprocessor *PP);
1134
1135 /// Return parsed documentation comment attached to a given declaration.
1136 /// Returns nullptr if no comment is attached.
1137 ///
1138 /// \param PP the Preprocessor used with this TU. Could be nullptr if
1139 /// preprocessor is not available.
1141 const Preprocessor *PP) const;
1142
1143 /// Attempts to merge two types that may be OverflowBehaviorTypes.
1144 ///
1145 /// \returns A QualType if the types were handled, std::nullopt otherwise.
1146 /// A null QualType indicates an incompatible merge.
1147 std::optional<QualType>
1148 tryMergeOverflowBehaviorTypes(QualType LHS, QualType RHS, bool OfBlockPointer,
1149 bool Unqualified, bool BlockReturnType,
1150 bool IsConditionalOperator);
1151
1152 /// Return parsed documentation comment attached to a given declaration.
1153 /// Returns nullptr if no comment is attached. Does not look at any
1154 /// redeclarations of the declaration.
1156
1158 const Decl *D) const;
1159
1160private:
1161 mutable comments::CommandTraits CommentCommandTraits;
1162
1163 /// Iterator that visits import declarations.
1164 class import_iterator {
1165 ImportDecl *Import = nullptr;
1166
1167 public:
1168 using value_type = ImportDecl *;
1169 using reference = ImportDecl *;
1170 using pointer = ImportDecl *;
1171 using difference_type = int;
1172 using iterator_category = std::forward_iterator_tag;
1173
1174 import_iterator() = default;
1175 explicit import_iterator(ImportDecl *Import) : Import(Import) {}
1176
1177 reference operator*() const { return Import; }
1178 pointer operator->() const { return Import; }
1179
1180 import_iterator &operator++() {
1181 Import = ASTContext::getNextLocalImport(Import);
1182 return *this;
1183 }
1184
1185 import_iterator operator++(int) {
1186 import_iterator Other(*this);
1187 ++(*this);
1188 return Other;
1189 }
1190
1191 friend bool operator==(import_iterator X, import_iterator Y) {
1192 return X.Import == Y.Import;
1193 }
1194
1195 friend bool operator!=(import_iterator X, import_iterator Y) {
1196 return X.Import != Y.Import;
1197 }
1198 };
1199
1200public:
1202 return CommentCommandTraits;
1203 }
1204
1205 /// Allocate an empty attribute vector with the lifetime of this context.
1207
1212
1213 /// Get all ExplicitInstantiationDecls for a given specialization.
1215 getExplicitInstantiationDecls(const NamedDecl *Spec) const;
1216
1217 /// Add an ExplicitInstantiationDecl for a given specialization.
1218 void addExplicitInstantiationDecl(const NamedDecl *Spec,
1220
1221 /// Note that the static data member \p Inst is an instantiation of
1222 /// the static data member template \p Tmpl of a class template.
1225 SourceLocation PointOfInstantiation = SourceLocation());
1226
1229
1232
1233 /// If the given using decl \p Inst is an instantiation of
1234 /// another (possibly unresolved) using decl, return it.
1236
1237 /// Remember that the using decl \p Inst is an instantiation
1238 /// of the using decl \p Pattern of a class template.
1239 void setInstantiatedFromUsingDecl(NamedDecl *Inst, NamedDecl *Pattern);
1240
1241 /// If the given using-enum decl \p Inst is an instantiation of
1242 /// another using-enum decl, return it.
1244
1245 /// Remember that the using enum decl \p Inst is an instantiation
1246 /// of the using enum decl \p Pattern of a class template.
1248 UsingEnumDecl *Pattern);
1249
1252 UsingShadowDecl *Pattern);
1253
1255
1257
1258 // Access to the set of methods overridden by the given C++ method.
1259 using overridden_cxx_method_iterator = CXXMethodVector::const_iterator;
1262
1265
1266 unsigned overridden_methods_size(const CXXMethodDecl *Method) const;
1267
1269 llvm::iterator_range<overridden_cxx_method_iterator>;
1270
1272
1273 /// Note that the given C++ \p Method overrides the given \p
1274 /// Overridden method.
1276 const CXXMethodDecl *Overridden);
1277
1278 /// Return C++ or ObjC overridden methods for the given \p Method.
1279 ///
1280 /// An ObjC method is considered to override any method in the class's
1281 /// base classes, its protocols, or its categories' protocols, that has
1282 /// the same selector and is of the same kind (class or instance).
1283 /// A method in an implementation is not considered as overriding the same
1284 /// method in the interface or its categories.
1286 const NamedDecl *Method,
1287 SmallVectorImpl<const NamedDecl *> &Overridden) const;
1288
1289 /// Notify the AST context that a new import declaration has been
1290 /// parsed or implicitly created within this translation unit.
1291 void addedLocalImportDecl(ImportDecl *Import);
1292
1294 return Import->getNextLocalImport();
1295 }
1296
1297 using import_range = llvm::iterator_range<import_iterator>;
1298
1300 return import_range(import_iterator(FirstLocalImport), import_iterator());
1301 }
1302
1304 Decl *Result = MergedDecls.lookup(D);
1305 return Result ? Result : D;
1306 }
1307 void setPrimaryMergedDecl(Decl *D, Decl *Primary) {
1308 MergedDecls[D] = Primary;
1309 }
1310
1311 /// Note that the definition \p ND has been merged into module \p M,
1312 /// and should be visible whenever \p M is visible.
1314 bool NotifyListeners = true);
1315
1316 /// Clean up the merged definition list. Call this if you might have
1317 /// added duplicates into the list.
1319
1320 /// Get the additional modules in which the definition \p Def has
1321 /// been merged.
1323
1324 /// Add a declaration to the list of declarations that are initialized
1325 /// for a module. This will typically be a global variable (with internal
1326 /// linkage) that runs module initializers, such as the iostream initializer,
1327 /// or an ImportDecl nominating another module that has initializers.
1329
1331
1332 /// Get the initializations to perform when importing a module, if any.
1334
1335 /// Set the (C++20) module we are building.
1337
1338 /// Get module under construction, nullptr if this is not a C++20 module.
1339 Module *getCurrentNamedModule() const { return CurrentCXXNamedModule; }
1340
1341 /// If the two module \p M1 and \p M2 are in the same module.
1342 ///
1343 /// FIXME: The signature may be confusing since `clang::Module` means to
1344 /// a module fragment or a module unit but not a C++20 module.
1345 bool isInSameModule(const Module *M1, const Module *M2) const;
1346
1348 assert(TUDecl && "TUDecl might have been reset by 'cleanup' likely because "
1349 "'CodeGenOpts.ClearASTBeforeBackend' was set.");
1350 assert(TUDecl->getMostRecentDecl() == TUDecl &&
1351 "The active TU is not current one!");
1352 return TUDecl->getMostRecentDecl();
1353 }
1355 assert(!TUDecl || TUKind == TU_Incremental);
1357 if (TraversalScope.empty() || TraversalScope.back() == TUDecl)
1358 TraversalScope = {NewTUDecl};
1359 if (TUDecl)
1360 NewTUDecl->setPreviousDecl(TUDecl);
1361 TUDecl = NewTUDecl;
1362 }
1363
1365
1366#define BuiltinTemplate(BTName) BuiltinTemplateDecl *get##BTName##Decl() const;
1367#include "clang/Basic/BuiltinTemplates.inc"
1368
1369 // Builtin Types.
1373 CanQualType WCharTy; // [C++ 3.9.1p5].
1374 CanQualType WideCharTy; // Same as WCharTy in C++, integer type in C99.
1375 CanQualType WIntTy; // [C99 7.24.1], integer type unchanged by default promotions.
1376 CanQualType Char8Ty; // [C++20 proposal]
1377 CanQualType Char16Ty; // [C++0x 3.9.1p5], integer type in C99.
1378 CanQualType Char32Ty; // [C++0x 3.9.1p5], integer type in C99.
1384 LongAccumTy; // ISO/IEC JTC1 SC22 WG14 N1169 Extension
1394 CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
1396 CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
1405#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1406 CanQualType SingletonId;
1407#include "clang/Basic/OpenCLImageTypes.def"
1413#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1414 CanQualType Id##Ty;
1415#include "clang/Basic/OpenCLExtensionTypes.def"
1416#define SVE_TYPE(Name, Id, SingletonId) \
1417 CanQualType SingletonId;
1418#include "clang/Basic/AArch64ACLETypes.def"
1419#define PPC_VECTOR_TYPE(Name, Id, Size) \
1420 CanQualType Id##Ty;
1421#include "clang/Basic/PPCTypes.def"
1422#define RVV_TYPE(Name, Id, SingletonId) \
1423 CanQualType SingletonId;
1424#include "clang/Basic/RISCVVTypes.def"
1425#define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
1426#include "clang/Basic/WebAssemblyReferenceTypes.def"
1427#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
1428 CanQualType SingletonId;
1429#include "clang/Basic/AMDGPUTypes.def"
1430#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
1431#include "clang/Basic/HLSLIntangibleTypes.def"
1432#define HLSL_PACKED_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
1433#include "clang/Basic/HLSLPackedTypes.def"
1434#define SPIRV_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
1435#include "clang/Basic/SPIRVTypes.def"
1436
1437 // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand.
1438 mutable QualType AutoDeductTy; // Deduction against 'auto'.
1439 mutable QualType AutoRRefDeductTy; // Deduction against 'auto &&'.
1440
1441 // Decl used to help define __builtin_va_list for some targets.
1442 // The decl is built when constructing 'BuiltinVaListDecl'.
1443 mutable Decl *VaListTagDecl = nullptr;
1444
1445 // Implicitly-declared type 'struct _GUID'.
1446 mutable TagDecl *MSGuidTagDecl = nullptr;
1447
1448 // Implicitly-declared type 'struct type_info'.
1449 mutable TagDecl *MSTypeInfoTagDecl = nullptr;
1450
1451 /// Keep track of CUDA/HIP device-side variables ODR-used by host code.
1452 /// This does not include extern shared variables used by device host
1453 /// functions as addresses of shared variables are per warp, therefore
1454 /// cannot be accessed by host code.
1455 llvm::SetVector<const VarDecl *> CUDADeviceVarODRUsedByHost;
1456
1457 /// Keep track of CUDA/HIP external kernels or device variables ODR-used by
1458 /// host code. SetVector is used to maintain the order.
1459 llvm::SetVector<const ValueDecl *> CUDAExternalDeviceDeclODRUsedByHost;
1460
1461 /// Keep track of CUDA/HIP implicit host device functions used on device side
1462 /// in device compilation.
1463 llvm::DenseSet<const FunctionDecl *> CUDAImplicitHostDeviceFunUsedByDevice;
1464
1465 /// Functions whose device body should be replaced with a trap stub.
1467
1468 /// Map of SYCL kernels indexed by the unique type used to name the kernel.
1469 /// Entries are not serialized but are recreated on deserialization of a
1470 /// sycl_kernel_entry_point attributed function declaration.
1471 llvm::DenseMap<CanQualType, SYCLKernelInfo> SYCLKernels;
1472
1473 /// For capturing lambdas with an explicit object parameter whose type is
1474 /// derived from the lambda type, we need to perform derived-to-base
1475 /// conversion so we can access the captures; the cast paths for that
1476 /// are stored here.
1477 llvm::DenseMap<const CXXMethodDecl *, CXXCastPath> LambdaCastPaths;
1478
1480 SelectorTable &sels, Builtin::Context &builtins,
1482 ASTContext(const ASTContext &) = delete;
1483 ASTContext &operator=(const ASTContext &) = delete;
1484 ~ASTContext();
1485
1486 /// Attach an external AST source to the AST context.
1487 ///
1488 /// The external AST source provides the ability to load parts of
1489 /// the abstract syntax tree as needed from some external storage,
1490 /// e.g., a precompiled header.
1492
1493 /// Retrieve a pointer to the external AST source associated
1494 /// with this AST context, if any.
1496 return ExternalSource.get();
1497 }
1498
1499 /// Retrieve a pointer to the external AST source associated
1500 /// with this AST context, if any. Returns as an IntrusiveRefCntPtr.
1504
1505 /// Set the callback that isDeclVisible() uses for declarations that are not
1506 /// unconditionally visible.
1507 void
1509 DeclVisibilityCallback = std::move(Callback);
1510 }
1511
1512 bool isDeclVisible(const NamedDecl *D) const;
1513
1514 /// Attach an AST mutation listener to the AST context.
1515 ///
1516 /// The AST mutation listener provides the ability to track modifications to
1517 /// the abstract syntax tree entities committed after they were initially
1518 /// created.
1520 this->Listener = Listener;
1521 }
1522
1523 /// Retrieve a pointer to the AST mutation listener associated
1524 /// with this AST context, if any.
1526
1527 void PrintStats() const;
1528
1529 /// Retrieve all RecordType and InjectedClassNameType nodes created so far,
1530 /// in creation order. Every other type whose canonical type is one of these
1531 /// is created after it.
1532 const SmallVectorImpl<Type *> &getRecordTypes() const { return RecordTypes; }
1533
1535 const IdentifierInfo *II) const;
1536
1537 /// Create a new implicit TU-level CXXRecordDecl or RecordDecl
1538 /// declaration.
1540 StringRef Name,
1541 RecordDecl::TagKind TK = RecordDecl::TagKind::Struct) const;
1542
1543 /// Create a new implicit TU-level typedef declaration.
1544 TypedefDecl *buildImplicitTypedef(QualType T, StringRef Name) const;
1545
1546 /// Retrieve the declaration for the 128-bit signed integer type.
1547 TypedefDecl *getInt128Decl() const;
1548
1549 /// Retrieve the declaration for the 128-bit unsigned integer type.
1550 TypedefDecl *getUInt128Decl() const;
1551
1552 //===--------------------------------------------------------------------===//
1553 // Type Constructors
1554 //===--------------------------------------------------------------------===//
1555
1556private:
1557 /// Return a type with extended qualifiers.
1558 QualType getExtQualType(const Type *Base, Qualifiers Quals) const;
1559
1560 QualType getPipeType(QualType T, bool ReadOnly) const;
1561
1562public:
1563 /// Return the uniqued reference to the type for an address space
1564 /// qualified type with the specified type and address space.
1565 ///
1566 /// The resulting type has a union of the qualifiers from T and the address
1567 /// space. If T already has an address space specifier, it is silently
1568 /// replaced.
1569 QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const;
1570
1571 /// Remove any existing address space on the type and returns the type
1572 /// with qualifiers intact (or that's the idea anyway)
1573 ///
1574 /// The return type should be T with all prior qualifiers minus the address
1575 /// space.
1577
1578 /// Return the "other" discriminator used for the pointer auth schema used for
1579 /// vtable pointers using the given discriminator type.
1581 bool IsVTTEntry);
1582
1583 /// Return the "other" type-specific discriminator for the given type.
1585
1586 /// Apply Objective-C protocol qualifiers to the given type.
1587 /// \param allowOnPointerType specifies if we can apply protocol
1588 /// qualifiers on ObjCObjectPointerType. It can be set to true when
1589 /// constructing the canonical type of a Objective-C type parameter.
1591 ArrayRef<ObjCProtocolDecl *> protocols, bool &hasError,
1592 bool allowOnPointerType = false) const;
1593
1594 /// Return the uniqued reference to the type for an Objective-C
1595 /// gc-qualified type.
1596 ///
1597 /// The resulting type has a union of the qualifiers from T and the gc
1598 /// attribute.
1600
1601 /// Remove the existing address space on the type if it is a pointer size
1602 /// address space and return the type with qualifiers intact.
1604
1605 /// Return the uniqued reference to the type for a \c restrict
1606 /// qualified type.
1607 ///
1608 /// The resulting type has a union of the qualifiers from \p T and
1609 /// \c restrict.
1613
1614 /// Return the uniqued reference to the type for a \c volatile
1615 /// qualified type.
1616 ///
1617 /// The resulting type has a union of the qualifiers from \p T and
1618 /// \c volatile.
1622
1623 /// Return the uniqued reference to the type for a \c const
1624 /// qualified type.
1625 ///
1626 /// The resulting type has a union of the qualifiers from \p T and \c const.
1627 ///
1628 /// It can be reasonably expected that this will always be equivalent to
1629 /// calling T.withConst().
1630 QualType getConstType(QualType T) const { return T.withConst(); }
1631
1632 /// Rebuild a type, preserving any existing type sugar. For function types,
1633 /// you probably want to just use \c adjustFunctionResultType and friends
1634 /// instead.
1636 llvm::function_ref<QualType(QualType)> Adjust) const;
1637
1638 /// Change the ExtInfo on a function type.
1640 FunctionType::ExtInfo EInfo);
1641
1642 /// Change the result type of a function type, preserving sugar such as
1643 /// attributed types.
1645 QualType NewResultType);
1646
1647 /// Adjust the given function result type.
1649
1650 /// Change the result type of a function type once it is deduced.
1652
1653 /// Get a function type and produce the equivalent function type with the
1654 /// specified exception specification. Type sugar that can be present on a
1655 /// declaration of a function with an exception specification is permitted
1656 /// and preserved. Other type sugar (for instance, typedefs) is not.
1658 QualType Orig, const FunctionProtoType::ExceptionSpecInfo &ESI) const;
1659
1660 /// Determine whether two function types are the same, ignoring
1661 /// exception specifications in cases where they're part of the type.
1663
1664 /// Change the exception specification on a function once it is
1665 /// delay-parsed, instantiated, or computed.
1668 bool AsWritten = false);
1669
1670 /// Get a function type and produce the equivalent function type where
1671 /// pointer size address spaces in the return type and parameter types are
1672 /// replaced with the default address space.
1674
1675 /// Determine whether two function types are the same, ignoring pointer sizes
1676 /// in the return type and parameter types.
1678
1679 /// Get or construct a function type that is equivalent to the input type
1680 /// except that the parameter ABI annotations are stripped.
1682
1683 /// Determine if two function types are the same, ignoring parameter ABI
1684 /// annotations.
1686
1687 /// Return the uniqued reference to the type for a complex
1688 /// number with the specified element type.
1693
1694 /// Return the uniqued reference to the type for a pointer to
1695 /// the specified type.
1700
1701 QualType
1702 getCountAttributedType(QualType T, Expr *CountExpr, bool CountInBytes,
1703 bool OrNull,
1704 ArrayRef<TypeCoupledDeclRefInfo> DependentDecls) const;
1705
1706 /// Return a `CountAttributedType` whose count expression has not been parsed
1707 /// yet, for use by a late-parsed bounds attribute. The result is *not*
1708 /// uniqued, and must be completed with `completeCountAttributedType` once the
1709 /// argument becomes parseable. Returns the node rather than a `QualType` so
1710 /// the caller can retain it for completion.
1712 bool CountInBytes,
1713 bool OrNull) const;
1714
1715 /// Supply the count expression and coupled declarations for a type created by
1716 /// `getIncompleteCountAttributedType`. Enclosing types keep pointing at the
1717 /// same node, so nothing above it needs rebuilding.
1719 CountAttributedType *CATy, Expr *CountExpr,
1720 ArrayRef<TypeCoupledDeclRefInfo> DependentDecls) const;
1721
1722 /// Return a placeholder type for a late-parsed type attribute.
1723 /// This type wraps another type and holds the LateParsedAttribute
1724 /// that will be parsed later.
1726 LateParsedTypeAttribute *LateParsedAttr) const;
1727
1728 /// Return the uniqued reference to a type adjusted from the original
1729 /// type to a new type.
1735
1736 /// Return the uniqued reference to the decayed version of the given
1737 /// type. Can only be called on array and function types which decay to
1738 /// pointer types.
1743 /// Return the uniqued reference to a specified decay from the original
1744 /// type to the decayed type.
1745 QualType getDecayedType(QualType Orig, QualType Decayed) const;
1746
1747 /// Return the uniqued reference to a specified array parameter type from the
1748 /// original array type.
1750
1751 /// Return the uniqued reference to the atomic type for the specified
1752 /// type.
1754
1755 /// Return the uniqued reference to the type for a block of the
1756 /// specified type.
1758
1759 /// Gets the struct used to keep track of the descriptor for pointer to
1760 /// blocks.
1762
1763 /// Return a read_only pipe type for the specified type.
1765
1766 /// Return a write_only pipe type for the specified type.
1768
1769 /// Return a bit-precise integer type with the specified signedness and bit
1770 /// count.
1771 QualType getBitIntType(bool Unsigned, unsigned NumBits) const;
1772
1773 /// Return a dependent bit-precise integer type with the specified signedness
1774 /// and bit count.
1775 QualType getDependentBitIntType(bool Unsigned, Expr *BitsExpr) const;
1776
1778
1779 /// Gets the struct used to keep track of the extended descriptor for
1780 /// pointer to blocks.
1782
1783 /// Map an AST Type to an OpenCLTypeKind enum value.
1784 OpenCLTypeKind getOpenCLTypeKind(const Type *T) const;
1785
1786 /// Get address space for OpenCL type.
1787 LangAS getOpenCLTypeAddrSpace(const Type *T) const;
1788
1789 /// Returns default address space based on OpenCL version and enabled features
1791 return LangOpts.OpenCLGenericAddressSpace ? LangAS::opencl_generic
1793 }
1794
1796 cudaConfigureCallDecl = FD;
1797 }
1798
1800 return cudaConfigureCallDecl;
1801 }
1802
1804 cudaGetParameterBufferDecl = FD;
1805 }
1806
1808 return cudaGetParameterBufferDecl;
1809 }
1810
1811 void setcudaLaunchDeviceDecl(FunctionDecl *FD) { cudaLaunchDeviceDecl = FD; }
1812
1813 FunctionDecl *getcudaLaunchDeviceDecl() { return cudaLaunchDeviceDecl; }
1814
1815 /// Returns true iff we need copy/dispose helpers for the given type.
1816 bool BlockRequiresCopying(QualType Ty, const VarDecl *D);
1817
1818 /// Returns true, if given type has a known lifetime. HasByrefExtendedLayout
1819 /// is set to false in this case. If HasByrefExtendedLayout returns true,
1820 /// byref variable has extended lifetime.
1821 bool getByrefLifetime(QualType Ty,
1822 Qualifiers::ObjCLifetime &Lifetime,
1823 bool &HasByrefExtendedLayout) const;
1824
1825 /// Return the uniqued reference to the type for an lvalue reference
1826 /// to the specified type.
1827 QualType getLValueReferenceType(QualType T, bool SpelledAsLValue = true)
1828 const;
1829
1830 /// Return the uniqued reference to the type for an rvalue reference
1831 /// to the specified type.
1833
1834 /// Return the uniqued reference to the type for a member pointer to
1835 /// the specified type in the specified nested name.
1837 const CXXRecordDecl *Cls) const;
1838
1839 /// Return a non-unique reference to the type for a variable array of
1840 /// the specified element type.
1843 unsigned IndexTypeQuals) const;
1844
1845 /// Return a non-unique reference to the type for a dependently-sized
1846 /// array of the specified element type.
1847 ///
1848 /// FIXME: We will need these to be uniqued, or at least comparable, at some
1849 /// point.
1852 unsigned IndexTypeQuals) const;
1853
1854 /// Return a unique reference to the type for an incomplete array of
1855 /// the specified element type.
1857 unsigned IndexTypeQuals) const;
1858
1859 /// Return the unique reference to the type for a constant array of
1860 /// the specified element type.
1861 QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize,
1862 const Expr *SizeExpr, ArraySizeModifier ASM,
1863 unsigned IndexTypeQuals) const;
1864
1865 /// Return a type for a constant array for a string literal of the
1866 /// specified element type and length.
1867 QualType getStringLiteralArrayType(QualType EltTy, unsigned Length) const;
1868
1869 /// Returns a vla type where known sizes are replaced with [*].
1871
1872 // Convenience struct to return information about a builtin vector type.
1881
1882 /// Returns the element type, element count and number of vectors
1883 /// (in case of tuple) for a builtin vector type.
1884 BuiltinVectorTypeInfo
1885 getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const;
1886
1887 /// Return the unique reference to a scalable vector type of the specified
1888 /// element type and scalable number of elements.
1889 /// For RISC-V, number of fields is also provided when it fetching for
1890 /// tuple type.
1891 ///
1892 /// \pre \p EltTy must be a built-in type.
1893 QualType getScalableVectorType(QualType EltTy, unsigned NumElts,
1894 unsigned NumFields = 1) const;
1895
1896 /// Return a WebAssembly externref type.
1898
1899 /// Return the unique reference to a vector type of the specified
1900 /// element type and size.
1901 ///
1902 /// \pre \p VectorType must be a built-in type.
1903 QualType getVectorType(QualType VectorType, unsigned NumElts,
1904 VectorKind VecKind) const;
1905 /// Return the unique reference to the type for a dependently sized vector of
1906 /// the specified element type.
1908 SourceLocation AttrLoc,
1909 VectorKind VecKind) const;
1910
1911 /// Return the unique reference to an extended vector type
1912 /// of the specified element type and size.
1913 ///
1914 /// \pre \p VectorType must be a built-in type.
1915 QualType getExtVectorType(QualType VectorType, unsigned NumElts) const;
1916
1917 /// \pre Return a non-unique reference to the type for a dependently-sized
1918 /// vector of the specified element type.
1919 ///
1920 /// FIXME: We will need these to be uniqued, or at least comparable, at some
1921 /// point.
1923 Expr *SizeExpr,
1924 SourceLocation AttrLoc) const;
1925
1926 /// Return the unique reference to the matrix type of the specified element
1927 /// type and size
1928 ///
1929 /// \pre \p ElementType must be a valid matrix element type (see
1930 /// MatrixType::isValidElementType).
1932 QualType ElementType, unsigned NumRows, unsigned NumColumns,
1933 std::optional<MatrixType::LayoutKind> Layout = std::nullopt) const;
1934
1935 /// Return the unique reference to the cooperative matrix type of the
1936 /// specified element type and size.
1937 ///
1938 /// \pre \p ElementType must be a valid matrix element type (see
1939 /// MatrixType::isValidElementType).
1940 QualType getCooperativeMatrixType(QualType ElementType, unsigned Scope,
1941 unsigned NumRows, unsigned NumColumns,
1942 unsigned Use) const;
1943
1944 /// Return the unique reference to the matrix type of the specified element
1945 /// type and size
1946 QualType getDependentSizedMatrixType(QualType ElementType, Expr *RowExpr,
1947 Expr *ColumnExpr,
1948 SourceLocation AttrLoc) const;
1949
1951 MatrixType::LayoutKind Layout) const;
1952
1954 Expr *AddrSpaceExpr,
1955 SourceLocation AttrLoc) const;
1956
1957 /// Return a K&R style C function type like 'int()'.
1959 const FunctionType::ExtInfo &Info) const;
1960
1964
1965 /// Return a normal function type with a typed argument list.
1967 const FunctionProtoType::ExtProtoInfo &EPI) const {
1968 return getFunctionTypeInternal(ResultTy, Args, EPI, false);
1969 }
1970
1972
1973 // Represents an inclusive-first/exclusive last bit-offset into a type.
1975 // [First, Last)
1978 };
1979
1980 // Calculate and get the 'padding intervals' inside of a type. Note: calls to
1981 // this potentially invalidate all ArrayRef objects, so effort must be made to
1982 // copy the data if necessary.
1984
1985private:
1986 mutable llvm::DenseMap<QualType, llvm::SmallVector<BitInterval>>
1987 PaddingIntervalCache;
1988
1989 /// Return a normal function type with a typed argument list.
1990 QualType getFunctionTypeInternal(QualType ResultTy, ArrayRef<QualType> Args,
1992 bool OnlyWantCanonical) const;
1993
1994public:
1996 NestedNameSpecifier Qualifier,
1997 const TypeDecl *Decl) const;
1998
1999 /// Return the unique reference to the type for the specified type
2000 /// declaration.
2001 QualType getTypeDeclType(const TypeDecl *Decl) const;
2002
2003 /// Use the normal 'getFooBarType' constructors to obtain these types.
2004 QualType getTypeDeclType(const TagDecl *) const = delete;
2005 QualType getTypeDeclType(const TypedefDecl *) const = delete;
2006 QualType getTypeDeclType(const TypeAliasDecl *) const = delete;
2008
2010
2012 NestedNameSpecifier Qualifier, const UsingShadowDecl *D,
2013 QualType UnderlyingType = QualType()) const;
2014
2015 /// Return the unique reference to the type for the specified
2016 /// typedef-name decl.
2017 /// FIXME: TypeMatchesDeclOrNone is a workaround for a serialization issue:
2018 /// The decl underlying type might still not be available.
2021 const TypedefNameDecl *Decl, QualType UnderlyingType = QualType(),
2022 std::optional<bool> TypeMatchesDeclOrNone = std::nullopt) const;
2023
2024 CanQualType getCanonicalTagType(const TagDecl *TD) const;
2026 NestedNameSpecifier Qualifier, const TagDecl *TD,
2027 bool OwnsTag) const;
2028
2029private:
2030 /// Record a newly created type for statistics and getRecordTypes().
2031 void addType(Type *T) const;
2032
2033 UnresolvedUsingType *getUnresolvedUsingTypeInternal(
2035 const UnresolvedUsingTypenameDecl *D, llvm::FoldingSetInsertToken Token,
2036 const Type *CanonicalType) const;
2037
2038 TagType *getTagTypeInternal(ElaboratedTypeKeyword Keyword,
2039 NestedNameSpecifier Qualifier, const TagDecl *Tag,
2040 bool OwnsTag, bool IsInjected,
2041 const Type *CanonicalType,
2042 bool WithFoldingSetNode) const;
2043
2044public:
2045 /// Compute BestType and BestPromotionType for an enum based on the highest
2046 /// number of negative and positive bits of its elements.
2047 /// Returns true if enum width is too large.
2048 bool computeBestEnumTypes(bool IsPacked, unsigned NumNegativeBits,
2049 unsigned NumPositiveBits, QualType &BestType,
2050 QualType &BestPromotionType);
2051
2052 /// Determine whether the given integral value is representable within
2053 /// the given type T.
2054 bool isRepresentableIntegerValue(llvm::APSInt &Value, QualType T);
2055
2056 /// Compute NumNegativeBits and NumPositiveBits for an enum based on
2057 /// the constant values of its enumerators.
2058 template <typename RangeT>
2059 bool computeEnumBits(RangeT EnumConstants, unsigned &NumNegativeBits,
2060 unsigned &NumPositiveBits) {
2061 NumNegativeBits = 0;
2062 NumPositiveBits = 0;
2063 bool MembersRepresentableByInt = true;
2064 for (auto *Elem : EnumConstants) {
2065 EnumConstantDecl *ECD = cast_or_null<EnumConstantDecl>(Elem);
2066 if (!ECD)
2067 continue; // Already issued a diagnostic.
2068
2069 llvm::APSInt InitVal = ECD->getInitVal();
2070 if (InitVal.isUnsigned() || InitVal.isNonNegative()) {
2071 // If the enumerator is zero that should still be counted as a positive
2072 // bit since we need a bit to store the value zero.
2073 unsigned ActiveBits = InitVal.getActiveBits();
2074 NumPositiveBits = std::max({NumPositiveBits, ActiveBits, 1u});
2075 } else {
2076 NumNegativeBits =
2077 std::max(NumNegativeBits, InitVal.getSignificantBits());
2078 }
2079
2080 MembersRepresentableByInt &= isRepresentableIntegerValue(InitVal, IntTy);
2081 }
2082
2083 // If we have an empty set of enumerators we still need one bit.
2084 // From [dcl.enum]p8
2085 // If the enumerator-list is empty, the values of the enumeration are as if
2086 // the enumeration had a single enumerator with value 0
2087 if (!NumPositiveBits && !NumNegativeBits)
2088 NumPositiveBits = 1;
2089
2090 return MembersRepresentableByInt;
2091 }
2092
2096 NestedNameSpecifier Qualifier,
2097 const UnresolvedUsingTypenameDecl *D) const;
2098
2099 QualType getAttributedType(attr::Kind attrKind, QualType modifiedType,
2100 QualType equivalentType,
2101 const Attr *attr = nullptr) const;
2102
2103 QualType getAttributedType(const Attr *attr, QualType modifiedType,
2104 QualType equivalentType) const;
2105
2106 QualType getAttributedType(NullabilityKind nullability, QualType modifiedType,
2107 QualType equivalentType) const;
2108
2109 QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr,
2110 QualType Wrapped) const;
2111
2112 QualType getOverflowBehaviorType(const OverflowBehaviorAttr *Attr,
2113 QualType Wrapped) const;
2114
2115 QualType
2116 getOverflowBehaviorType(OverflowBehaviorType::OverflowBehaviorKind Kind,
2117 QualType Wrapped) const;
2118
2120 QualType Wrapped, QualType Contained,
2121 const HLSLAttributedResourceType::Attributes &Attrs);
2122
2124 uint32_t Alignment,
2125 ArrayRef<SpirvOperand> Operands);
2126
2128 Decl *AssociatedDecl, unsigned Index,
2130 bool Final) const;
2132 unsigned Index, bool Final,
2133 const TemplateArgument &ArgPack);
2135
2136 QualType
2137 getTemplateTypeParmType(int Depth, int Index, bool ParameterPack,
2138 TemplateTypeParmDecl *ParmDecl = nullptr) const;
2139
2142 ArrayRef<TemplateArgument> CanonicalArgs) const;
2143
2144 QualType
2146 ArrayRef<TemplateArgument> SpecifiedArgs,
2147 ArrayRef<TemplateArgument> CanonicalArgs,
2148 QualType Underlying = QualType()) const;
2149
2150 QualType
2152 ArrayRef<TemplateArgumentLoc> SpecifiedArgs,
2153 ArrayRef<TemplateArgument> CanonicalArgs,
2154 QualType Canon = QualType()) const;
2155
2157 ElaboratedTypeKeyword Keyword, SourceLocation ElaboratedKeywordLoc,
2158 NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKeywordLoc,
2160 const TemplateArgumentListInfo &SpecifiedArgs,
2161 ArrayRef<TemplateArgument> CanonicalArgs,
2162 QualType Canon = QualType()) const;
2163
2164 QualType getParenType(QualType NamedType) const;
2165
2167 const IdentifierInfo *MacroII) const;
2168
2171 const IdentifierInfo *Name) const;
2172
2174
2175 /// Form a pack expansion type with the given pattern.
2176 /// \param NumExpansions The number of expansions for the pack, if known.
2177 /// \param ExpectPackInType If \c false, we should not expect \p Pattern to
2178 /// contain an unexpanded pack. This only makes sense if the pack
2179 /// expansion is used in a context where the arity is inferred from
2180 /// elsewhere, such as if the pattern contains a placeholder type or
2181 /// if this is the canonical type of another pack expansion type.
2183 bool ExpectPackInType = true) const;
2184
2186 ObjCInterfaceDecl *PrevDecl = nullptr) const;
2187
2188 /// Legacy interface: cannot provide type arguments or __kindof.
2190 ObjCProtocolDecl * const *Protocols,
2191 unsigned NumProtocols) const;
2192
2194 ArrayRef<QualType> typeArgs,
2196 bool isKindOf) const;
2197
2199 ArrayRef<ObjCProtocolDecl *> protocols) const;
2201 ObjCTypeParamDecl *New) const;
2202
2204
2205 /// QIdProtocolsAdoptObjCObjectProtocols - Checks that protocols in
2206 /// QT's qualified-id protocol list adopt all protocols in IDecl's list
2207 /// of protocols.
2209 ObjCInterfaceDecl *IDecl);
2210
2211 /// Return a ObjCObjectPointerType type for the given ObjCObjectType.
2213
2214 /// C23 feature and GCC extension.
2215 QualType getTypeOfExprType(Expr *E, TypeOfKind Kind) const;
2216 QualType getTypeOfType(QualType QT, TypeOfKind Kind) const;
2217
2218 QualType getReferenceQualifiedType(const Expr *e) const;
2219
2220 /// C++11 decltype.
2221 QualType getDecltypeType(Expr *e, QualType UnderlyingType) const;
2222
2223 QualType getPackIndexingType(QualType Pattern, Expr *IndexExpr,
2224 bool FullySubstituted = false,
2225 ArrayRef<QualType> Expansions = {},
2226 UnsignedOrNone Index = std::nullopt) const;
2227
2228 /// Unary type transforms
2229 QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType,
2230 UnaryTransformType::UTTKind UKind) const;
2231
2232 /// C++11 deduced auto type.
2233 QualType
2234 getAutoType(DeducedKind DK, QualType DeducedAsType, AutoTypeKeyword Keyword,
2235 TemplateName TypeConstraintConcept = TemplateName(),
2236 ArrayRef<TemplateArgument> TypeConstraintArgs = {}) const;
2237
2238 /// C++11 deduction pattern for 'auto' type.
2239 QualType getAutoDeductType() const;
2240
2241 /// C++11 deduction pattern for 'auto &&' type.
2242 QualType getAutoRRefDeductType() const;
2243
2244 /// Remove any type constraints from a template parameter type, for
2245 /// equivalence comparison of template parameters.
2246 QualType getUnconstrainedType(QualType T) const;
2247
2248 /// C++17 deduced class template specialization type.
2250 QualType DeducedAsType,
2252 TemplateName Template) const;
2253
2254 /// Return the unique type for "size_t" (C99 7.17), defined in
2255 /// <stddef.h>.
2256 ///
2257 /// The sizeof operator requires this (C99 6.5.3.4p4).
2258 QualType getSizeType() const;
2259
2261
2262 /// Return the unique signed counterpart of
2263 /// the integer type corresponding to size_t.
2264 QualType getSignedSizeType() const;
2265
2266 /// Return the unique type for "intmax_t" (C99 7.18.1.5), defined in
2267 /// <stdint.h>.
2268 CanQualType getIntMaxType() const;
2269
2270 /// Return the unique type for "uintmax_t" (C99 7.18.1.5), defined in
2271 /// <stdint.h>.
2273
2274 /// Return the unique wchar_t type available in C++ (and available as
2275 /// __wchar_t as a Microsoft extension).
2276 QualType getWCharType() const { return WCharTy; }
2277
2278 /// Return the type of wide characters. In C++, this returns the
2279 /// unique wchar_t type. In C99, this returns a type compatible with the type
2280 /// defined in <stddef.h> as defined by the target.
2282
2283 /// Return the type of "signed wchar_t".
2284 ///
2285 /// Used when in C++, as a GCC extension.
2287
2288 /// Return the type of "unsigned wchar_t".
2289 ///
2290 /// Used when in C++, as a GCC extension.
2292
2293 /// In C99, this returns a type compatible with the type
2294 /// defined in <stddef.h> as defined by the target.
2295 QualType getWIntType() const { return WIntTy; }
2296
2297 /// Return a type compatible with "intptr_t" (C99 7.18.1.4),
2298 /// as defined by the target.
2299 QualType getIntPtrType() const;
2300
2301 /// Return a type compatible with "uintptr_t" (C99 7.18.1.4),
2302 /// as defined by the target.
2303 QualType getUIntPtrType() const;
2304
2305 /// Return the unique type for "ptrdiff_t" (C99 7.17) defined in
2306 /// <stddef.h>. Pointer - pointer requires this (C99 6.5.6p9).
2308
2309 /// Return the unique unsigned counterpart of "ptrdiff_t"
2310 /// integer type. The standard (C11 7.21.6.1p7) refers to this type
2311 /// in the definition of %tu format specifier.
2313
2314 /// Return the unique type for "pid_t" defined in
2315 /// <sys/types.h>. We need this to compute the correct type for vfork().
2316 QualType getProcessIDType() const;
2317
2318 /// Return the C structure type used to represent constant CFStrings.
2320
2321 /// Returns the C struct type for objc_super
2322 QualType getObjCSuperType() const;
2323 void setObjCSuperType(QualType ST) { ObjCSuperType = ST; }
2324
2325 /// Get the structure type used to representation CFStrings, or NULL
2326 /// if it hasn't yet been built.
2328 if (CFConstantStringTypeDecl)
2330 /*Qualifier=*/std::nullopt,
2331 CFConstantStringTypeDecl);
2332 return QualType();
2333 }
2337
2338 // This setter/getter represents the ObjC type for an NSConstantString.
2341 return ObjCConstantStringType;
2342 }
2343
2345 return ObjCNSStringType;
2346 }
2347
2349 ObjCNSStringType = T;
2350 }
2351
2352 /// Retrieve the type that \c id has been defined to, which may be
2353 /// different from the built-in \c id if \c id has been typedef'd.
2355 if (ObjCIdRedefinitionType.isNull())
2356 return getObjCIdType();
2357 return ObjCIdRedefinitionType;
2358 }
2359
2360 /// Set the user-written type that redefines \c id.
2362 ObjCIdRedefinitionType = RedefType;
2363 }
2364
2365 /// Retrieve the type that \c Class has been defined to, which may be
2366 /// different from the built-in \c Class if \c Class has been typedef'd.
2368 if (ObjCClassRedefinitionType.isNull())
2369 return getObjCClassType();
2370 return ObjCClassRedefinitionType;
2371 }
2372
2373 /// Set the user-written type that redefines 'SEL'.
2375 ObjCClassRedefinitionType = RedefType;
2376 }
2377
2378 /// Retrieve the type that 'SEL' has been defined to, which may be
2379 /// different from the built-in 'SEL' if 'SEL' has been typedef'd.
2381 if (ObjCSelRedefinitionType.isNull())
2382 return getObjCSelType();
2383 return ObjCSelRedefinitionType;
2384 }
2385
2386 /// Set the user-written type that redefines 'SEL'.
2388 ObjCSelRedefinitionType = RedefType;
2389 }
2390
2391 /// Retrieve the identifier 'NSObject'.
2393 if (!NSObjectName) {
2394 NSObjectName = &Idents.get("NSObject");
2395 }
2396
2397 return NSObjectName;
2398 }
2399
2400 /// Retrieve the identifier 'NSCopying'.
2402 if (!NSCopyingName) {
2403 NSCopyingName = &Idents.get("NSCopying");
2404 }
2405
2406 return NSCopyingName;
2407 }
2408
2410
2412
2413 /// Retrieve the identifier 'bool'.
2415 if (!BoolName)
2416 BoolName = &Idents.get("bool");
2417 return BoolName;
2418 }
2419
2420#define BuiltinTemplate(BTName) \
2421 IdentifierInfo *get##BTName##Name() const { \
2422 if (!Name##BTName) \
2423 Name##BTName = &Idents.get(#BTName); \
2424 return Name##BTName; \
2425 }
2426#include "clang/Basic/BuiltinTemplates.inc"
2427
2428 /// Retrieve the Objective-C "instancetype" type.
2431 /*Qualifier=*/std::nullopt,
2433 }
2434
2435 /// Retrieve the typedef declaration corresponding to the Objective-C
2436 /// "instancetype" type.
2438
2439 /// Set the type for the C FILE type.
2440 void setFILEDecl(TypeDecl *FILEDecl) { this->FILEDecl = FILEDecl; }
2441
2442 /// Retrieve the C FILE type.
2444 if (FILEDecl)
2446 /*Qualifier=*/std::nullopt, FILEDecl);
2447 return QualType();
2448 }
2449
2450 /// Set the type for the C jmp_buf type.
2451 void setjmp_bufDecl(TypeDecl *jmp_bufDecl) {
2452 this->jmp_bufDecl = jmp_bufDecl;
2453 }
2454
2455 /// Retrieve the C jmp_buf type.
2457 if (jmp_bufDecl)
2459 /*Qualifier=*/std::nullopt, jmp_bufDecl);
2460 return QualType();
2461 }
2462
2463 /// Set the type for the C sigjmp_buf type.
2464 void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl) {
2465 this->sigjmp_bufDecl = sigjmp_bufDecl;
2466 }
2467
2468 /// Retrieve the C sigjmp_buf type.
2470 if (sigjmp_bufDecl)
2472 /*Qualifier=*/std::nullopt, sigjmp_bufDecl);
2473 return QualType();
2474 }
2475
2476 /// Set the type for the C ucontext_t type.
2477 void setucontext_tDecl(TypeDecl *ucontext_tDecl) {
2478 this->ucontext_tDecl = ucontext_tDecl;
2479 }
2480
2481 /// Retrieve the C ucontext_t type.
2483 if (ucontext_tDecl)
2485 /*Qualifier=*/std::nullopt, ucontext_tDecl);
2486 return QualType();
2487 }
2488
2489 /// The result type of logical operations, '<', '>', '!=', etc.
2491 return getLangOpts().CPlusPlus ? BoolTy : IntTy;
2492 }
2493
2494 /// Emit the Objective-CC type encoding for the given type \p T into
2495 /// \p S.
2496 ///
2497 /// If \p Field is specified then record field names are also encoded.
2498 void getObjCEncodingForType(QualType T, std::string &S,
2499 const FieldDecl *Field=nullptr,
2500 QualType *NotEncodedT=nullptr) const;
2501
2502 /// Emit the Objective-C property type encoding for the given
2503 /// type \p T into \p S.
2504 void getObjCEncodingForPropertyType(QualType T, std::string &S) const;
2505
2507
2508 /// Put the string version of the type qualifiers \p QT into \p S.
2510 std::string &S) const;
2511
2512 /// Emit the encoded type for the function \p Decl into \p S.
2513 ///
2514 /// This is in the same format as Objective-C method encodings.
2515 ///
2516 /// \returns true if an error occurred (e.g., because one of the parameter
2517 /// types is incomplete), false otherwise.
2518 std::string getObjCEncodingForFunctionDecl(const FunctionDecl *Decl) const;
2519
2520 /// Emit the encoded type for the method declaration \p Decl into
2521 /// \p S.
2523 bool Extended = false) const;
2524
2525 /// Return the encoded type for this block declaration.
2526 std::string getObjCEncodingForBlock(const BlockExpr *blockExpr) const;
2527
2528 /// getObjCEncodingForPropertyDecl - Return the encoded type for
2529 /// this method declaration. If non-NULL, Container must be either
2530 /// an ObjCCategoryImplDecl or ObjCImplementationDecl; it should
2531 /// only be NULL when getting encodings for protocol properties.
2533 const Decl *Container) const;
2534
2536 ObjCProtocolDecl *rProto) const;
2537
2539 const ObjCPropertyDecl *PD,
2540 const Decl *Container) const;
2541
2542 /// Return the size of type \p T for Objective-C encoding purpose,
2543 /// in characters.
2545
2546 /// Retrieve the typedef corresponding to the predefined \c id type
2547 /// in Objective-C.
2548 TypedefDecl *getObjCIdDecl() const;
2549
2550 /// Represents the Objective-CC \c id type.
2551 ///
2552 /// This is set up lazily, by Sema. \c id is always a (typedef for a)
2553 /// pointer type, a pointer to a struct.
2556 /*Qualifier=*/std::nullopt, getObjCIdDecl());
2557 }
2558
2559 /// Retrieve the typedef corresponding to the predefined 'SEL' type
2560 /// in Objective-C.
2561 TypedefDecl *getObjCSelDecl() const;
2562
2563 /// Retrieve the type that corresponds to the predefined Objective-C
2564 /// 'SEL' type.
2567 /*Qualifier=*/std::nullopt, getObjCSelDecl());
2568 }
2569
2571
2572 /// Retrieve the typedef declaration corresponding to the predefined
2573 /// Objective-C 'Class' type.
2575
2576 /// Represents the Objective-C \c Class type.
2577 ///
2578 /// This is set up lazily, by Sema. \c Class is always a (typedef for a)
2579 /// pointer type, a pointer to a struct.
2582 /*Qualifier=*/std::nullopt, getObjCClassDecl());
2583 }
2584
2585 /// Retrieve the Objective-C class declaration corresponding to
2586 /// the predefined \c Protocol class.
2588
2589 /// Retrieve declaration of 'BOOL' typedef
2591 return BOOLDecl;
2592 }
2593
2594 /// Save declaration of 'BOOL' typedef
2596 BOOLDecl = TD;
2597 }
2598
2599 /// type of 'BOOL' type.
2602 /*Qualifier=*/std::nullopt, getBOOLDecl());
2603 }
2604
2605 /// Retrieve the type of the Objective-C \c Protocol class.
2609
2610 /// Retrieve the C type declaration corresponding to the predefined
2611 /// \c __builtin_va_list type.
2613
2614 /// Retrieve the type of the \c __builtin_va_list type.
2617 /*Qualifier=*/std::nullopt, getBuiltinVaListDecl());
2618 }
2619
2620 /// Retrieve the C type declaration corresponding to the predefined
2621 /// \c __va_list_tag type used to help define the \c __builtin_va_list type
2622 /// for some targets.
2623 Decl *getVaListTagDecl() const;
2624
2625 /// Retrieve the C type declaration corresponding to the predefined
2626 /// \c __builtin_ms_va_list type.
2628
2629 /// Retrieve the type of the \c __builtin_ms_va_list type.
2632 /*Qualifier=*/std::nullopt, getBuiltinMSVaListDecl());
2633 }
2634
2635 /// Retrieve the implicitly-predeclared 'struct _GUID' declaration.
2637
2638 /// Retrieve the implicitly-predeclared 'struct _GUID' type.
2640 assert(MSGuidTagDecl && "asked for GUID type but MS extensions disabled");
2642 }
2643
2644 /// Retrieve the implicitly-predeclared 'struct type_info' declaration.
2646 // Lazily create this type on demand - it's only needed for MS builds.
2647 if (!MSTypeInfoTagDecl)
2649 return MSTypeInfoTagDecl;
2650 }
2651
2652 /// Retrieve the C type declaration corresponding to the predefined
2653 /// \c __builtin_zos_va_list type.
2655
2656 /// Retrieve the type of the \c __builtin_zos_va_list type.
2659 /*Qualifier=*/std::nullopt,
2661 }
2662
2663 /// Return whether a declaration to a builtin is allowed to be
2664 /// overloaded/redeclared.
2665 bool canBuiltinBeRedeclared(const FunctionDecl *) const;
2666
2667 /// Return a type with additional \c const, \c volatile, or
2668 /// \c restrict qualifiers.
2669 QualType getCVRQualifiedType(QualType T, unsigned CVR) const {
2671 }
2672
2673 /// Un-split a SplitQualType.
2675 return getQualifiedType(split.Ty, split.Quals);
2676 }
2677
2678 /// Return a type with additional qualifiers.
2680 if (!Qs.hasNonFastQualifiers())
2682 QualifierCollector Qc(Qs);
2683 const Type *Ptr = Qc.strip(T);
2684 return getExtQualType(Ptr, Qc);
2685 }
2686
2687 /// Return a type with additional qualifiers.
2689 if (!Qs.hasNonFastQualifiers())
2690 return QualType(T, Qs.getFastQualifiers());
2691 return getExtQualType(T, Qs);
2692 }
2693
2694 /// Return a type with the given lifetime qualifier.
2695 ///
2696 /// \pre Neither type.ObjCLifetime() nor \p lifetime may be \c OCL_None.
2698 Qualifiers::ObjCLifetime lifetime) {
2699 assert(type.getObjCLifetime() == Qualifiers::OCL_None);
2700 assert(lifetime != Qualifiers::OCL_None);
2701
2702 Qualifiers qs;
2703 qs.addObjCLifetime(lifetime);
2704 return getQualifiedType(type, qs);
2705 }
2706
2707 /// getUnqualifiedObjCPointerType - Returns version of
2708 /// Objective-C pointer type with lifetime qualifier removed.
2710 if (!type.getTypePtr()->isObjCObjectPointerType() ||
2711 !type.getQualifiers().hasObjCLifetime())
2712 return type;
2713 Qualifiers Qs = type.getQualifiers();
2714 Qs.removeObjCLifetime();
2715 return getQualifiedType(type.getUnqualifiedType(), Qs);
2716 }
2717
2718 /// \brief Return a type with the given __ptrauth qualifier.
2720 assert(!Ty.getPointerAuth());
2721 assert(PointerAuth);
2722
2723 Qualifiers Qs;
2724 Qs.setPointerAuth(PointerAuth);
2725 return getQualifiedType(Ty, Qs);
2726 }
2727
2728 unsigned char getFixedPointScale(QualType Ty) const;
2729 unsigned char getFixedPointIBits(QualType Ty) const;
2730 llvm::FixedPointSemantics getFixedPointSemantics(QualType Ty) const;
2731 llvm::APFixedPoint getFixedPointMax(QualType Ty) const;
2732 llvm::APFixedPoint getFixedPointMin(QualType Ty) const;
2733
2735 SourceLocation NameLoc) const;
2736
2738 UnresolvedSetIterator End) const;
2740
2742 bool TemplateKeyword,
2743 TemplateName Template) const;
2746
2748 Decl *AssociatedDecl,
2749 unsigned Index,
2751 bool Final) const;
2753 Decl *AssociatedDecl,
2754 unsigned Index,
2755 bool Final) const;
2756
2758 getPackIndexingTemplateName(TemplateName Pattern, Expr *IndexExpr,
2759 bool FullySubstituted = false,
2760 ArrayRef<TemplateName> Expansions = {}) const;
2761
2762 /// Represents a TemplateName which had some of its default arguments
2763 /// deduced. This both represents this default argument deduction as sugar,
2764 /// and provides the support for it's equivalences through canonicalization.
2765 /// For example DeducedTemplateNames which have the same set of default
2766 /// arguments are equivalent, and are also equivalent to the underlying
2767 /// template when the deduced template arguments are the same.
2769 DefaultArguments DefaultArgs) const;
2770
2772 /// No error
2774
2775 /// Missing a type
2777
2778 /// Missing a type from <stdio.h>
2780
2781 /// Missing a type from <setjmp.h>
2783
2784 /// Missing a type from <ucontext.h>
2786 };
2787
2788 QualType DecodeTypeStr(const char *&Str, const ASTContext &Context,
2790 bool &RequireICE, bool AllowTypeModifiers) const;
2791
2792 /// Return the type for the specified builtin.
2793 ///
2794 /// If \p IntegerConstantArgs is non-null, it is filled in with a bitmask of
2795 /// arguments to the builtin that are required to be integer constant
2796 /// expressions.
2798 unsigned *IntegerConstantArgs = nullptr) const;
2799
2800 /// Types and expressions required to build C++2a three-way comparisons
2801 /// using operator<=>, including the values return by builtin <=> operators.
2803
2804private:
2805 CanQualType getFromTargetType(unsigned Type) const;
2806 TypeInfo getTypeInfoImpl(const Type *T) const;
2807
2808 //===--------------------------------------------------------------------===//
2809 // Type Predicates.
2810 //===--------------------------------------------------------------------===//
2811
2812public:
2813 /// Return one of the GCNone, Weak or Strong Objective-C garbage
2814 /// collection attributes.
2816
2817 /// Return true if the given vector types are of the same unqualified
2818 /// type or if they are equivalent to the same GCC vector type.
2819 ///
2820 /// \note This ignores whether they are target-specific (AltiVec or Neon)
2821 /// types.
2822 bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec);
2823
2824 /// Return true if two OverflowBehaviorTypes are compatible for assignment.
2825 /// This checks both the underlying type compatibility and the overflow
2826 /// behavior kind (trap vs wrap).
2828
2829 enum class OBTAssignResult {
2830 Compatible, // No OBT issues
2831 IncompatibleKinds, // __ob_trap vs __ob_wrap (error)
2832 Discards, // OBT -> non-OBT on integer types (warning)
2833 NotApplicable // Not both integers, fall through to normal checking
2834 };
2835
2836 /// Check overflow behavior type compatibility for assignments.
2837 /// Returns detailed information about OBT compatibility for assignment
2838 /// checking.
2840
2841 /// Return true if the given types are an RISC-V vector builtin type and a
2842 /// VectorType that is a fixed-length representation of the RISC-V vector
2843 /// builtin type for a specific vector-length.
2844 bool areCompatibleRVVTypes(QualType FirstType, QualType SecondType);
2845
2846 /// Return true if the given vector types are lax-compatible RISC-V vector
2847 /// types as defined by -flax-vector-conversions=, which permits implicit
2848 /// conversions between vectors with different number of elements and/or
2849 /// incompatible element types, false otherwise.
2850 bool areLaxCompatibleRVVTypes(QualType FirstType, QualType SecondType);
2851
2852 /// Return true if the type has been explicitly qualified with ObjC ownership.
2853 /// A type may be implicitly qualified with ownership under ObjC ARC, and in
2854 /// some cases the compiler treats these differently.
2856
2857 /// Return true if this is an \c NSObject object with its \c NSObject
2858 /// attribute set.
2860 return Ty->isObjCNSObjectType();
2861 }
2862
2863 //===--------------------------------------------------------------------===//
2864 // Type Sizing and Analysis
2865 //===--------------------------------------------------------------------===//
2866
2867 /// Return the APFloat 'semantics' for the specified scalar floating
2868 /// point type.
2869 const llvm::fltSemantics &getFloatTypeSemantics(QualType T) const;
2870
2871 /// Get the size and alignment of the specified complete type in bits.
2872 TypeInfo getTypeInfo(const Type *T) const;
2873 TypeInfo getTypeInfo(QualType T) const { return getTypeInfo(T.getTypePtr()); }
2874
2875 /// Get default simd alignment of the specified complete type in bits.
2876 unsigned getOpenMPDefaultSimdAlign(QualType T) const;
2877
2878 /// Return the size of the specified (complete) type \p T, in bits.
2880 uint64_t getTypeSize(const Type *T) const { return getTypeInfo(T).Width; }
2881
2882 /// Return the size of the character type, in bits.
2884 return getTypeSize(CharTy);
2885 }
2886
2887 /// Convert a size in bits to a size in characters.
2888 CharUnits toCharUnitsFromBits(int64_t BitSize) const;
2889
2890 /// Convert a size in characters to a size in bits.
2891 int64_t toBits(CharUnits CharSize) const;
2892
2893 /// Return the size of the specified (complete) type \p T, in
2894 /// characters.
2896 CharUnits getTypeSizeInChars(const Type *T) const;
2897
2898 std::optional<CharUnits> getTypeSizeInCharsIfKnown(QualType Ty) const {
2899 if (Ty->isIncompleteType() || Ty->isDependentType() ||
2900 Ty->isUndeducedType() || Ty->isSizelessType())
2901 return std::nullopt;
2902 return getTypeSizeInChars(Ty);
2903 }
2904
2905 std::optional<CharUnits> getTypeSizeInCharsIfKnown(const Type *Ty) const {
2906 return getTypeSizeInCharsIfKnown(QualType(Ty, 0));
2907 }
2908
2909 /// Return the ABI-specified alignment of a (complete) type \p T, in
2910 /// bits.
2911 unsigned getTypeAlign(QualType T) const { return getTypeInfo(T).Align; }
2912 unsigned getTypeAlign(const Type *T) const { return getTypeInfo(T).Align; }
2913
2914 /// Return the ABI-specified natural alignment of a (complete) type \p T,
2915 /// before alignment adjustments, in bits.
2916 ///
2917 /// This alignment is currently used only by ARM and AArch64 when passing
2918 /// arguments of a composite type.
2920 return getTypeUnadjustedAlign(T.getTypePtr());
2921 }
2922 unsigned getTypeUnadjustedAlign(const Type *T) const;
2923
2924 /// Return the alignment of a type, in bits, or 0 if
2925 /// the type is incomplete and we cannot determine the alignment (for
2926 /// example, from alignment attributes). The returned alignment is the
2927 /// Preferred alignment if NeedsPreferredAlignment is true, otherwise is the
2928 /// ABI alignment.
2929 unsigned getTypeAlignIfKnown(QualType T,
2930 bool NeedsPreferredAlignment = false) const;
2931
2932 /// Return the ABI-specified alignment of a (complete) type \p T, in
2933 /// characters.
2935 CharUnits getTypeAlignInChars(const Type *T) const;
2936
2937 /// Return the PreferredAlignment of a (complete) type \p T, in
2938 /// characters.
2942
2943 /// getTypeUnadjustedAlignInChars - Return the ABI-specified alignment of a type,
2944 /// in characters, before alignment adjustments. This method does not work on
2945 /// incomplete types.
2948
2949 // getTypeInfoDataSizeInChars - Return the size of a type, in chars. If the
2950 // type is a record, its data size is returned.
2952
2953 TypeInfoChars getTypeInfoInChars(const Type *T) const;
2955
2956 /// Determine if the alignment the type has was required using an
2957 /// alignment attribute.
2958 bool isAlignmentRequired(const Type *T) const;
2959 bool isAlignmentRequired(QualType T) const;
2960
2961 /// More type predicates useful for type checking/promotion
2962 bool isPromotableIntegerType(QualType T) const; // C99 6.3.1.1p2
2963
2964 /// Return the "preferred" alignment of the specified type \p T for
2965 /// the current target, in bits.
2966 ///
2967 /// This can be different than the ABI alignment in cases where it is
2968 /// beneficial for performance or backwards compatibility preserving to
2969 /// overalign a data type. (Note: despite the name, the preferred alignment
2970 /// is ABI-impacting, and not an optimization.)
2972 return getPreferredTypeAlign(T.getTypePtr());
2973 }
2974 unsigned getPreferredTypeAlign(const Type *T) const;
2975
2976 /// Return the default alignment for __attribute__((aligned)) on
2977 /// this target, to be used if no alignment value is specified.
2979
2980 /// Return the alignment in bits that should be given to a
2981 /// global variable with type \p T. If \p VD is non-null it will be
2982 /// considered specifically for the query.
2983 unsigned getAlignOfGlobalVar(QualType T, const VarDecl *VD) const;
2984
2985 /// Return the alignment in characters that should be given to a
2986 /// global variable with type \p T. If \p VD is non-null it will be
2987 /// considered specifically for the query.
2989
2990 /// Return the minimum alignment as specified by the target. If \p VD is
2991 /// non-null it may be used to identify external or weak variables.
2992 unsigned getMinGlobalAlignOfVar(uint64_t Size, const VarDecl *VD) const;
2993
2994 /// Return a conservative estimate of the alignment of the specified
2995 /// decl \p D.
2996 ///
2997 /// \pre \p D must not be a bitfield type, as bitfields do not have a valid
2998 /// alignment.
2999 ///
3000 /// If \p ForAlignof, references are treated like their underlying type
3001 /// and large arrays don't get any special treatment. If not \p ForAlignof
3002 /// it computes the value expected by CodeGen: references are treated like
3003 /// pointers and large arrays get extra alignment.
3004 CharUnits getDeclAlign(const Decl *D, bool ForAlignof = false) const;
3005
3006 /// Return the alignment (in bytes) of the thrown exception object. This is
3007 /// only meaningful for targets that allocate C++ exceptions in a system
3008 /// runtime, such as those using the Itanium C++ ABI.
3010
3011 /// Return whether unannotated records are treated as if they have
3012 /// [[gnu::ms_struct]].
3013 bool defaultsToMsStruct() const;
3014
3015 /// Whether layout (offset and size) information can be queried for \p D.
3016 static bool hasLayout(const RecordDecl *D) {
3017 D = D->getDefinition();
3018 return D && !D->isInvalidDecl() && D->isCompleteDefinition();
3019 }
3020
3021 /// Get or compute information about the layout of the specified
3022 /// record (struct/union/class) \p D, which indicates its size and field
3023 /// position information.
3024 /// \pre hasLayout(D)
3025 const ASTRecordLayout &getASTRecordLayout(const RecordDecl *D) const;
3026
3027 /// Get or compute information about the layout of the specified
3028 /// Objective-C interface.
3030 const;
3031
3032 void DumpRecordLayout(const RecordDecl *RD, raw_ostream &OS,
3033 bool Simple = false) const;
3034
3035 /// Get our current best idea for the key function of the
3036 /// given record decl, or nullptr if there isn't one.
3037 ///
3038 /// The key function is, according to the Itanium C++ ABI section 5.2.3:
3039 /// ...the first non-pure virtual function that is not inline at the
3040 /// point of class definition.
3041 ///
3042 /// Other ABIs use the same idea. However, the ARM C++ ABI ignores
3043 /// virtual functions that are defined 'inline', which means that
3044 /// the result of this computation can change.
3046
3047 /// Observe that the given method cannot be a key function.
3048 /// Checks the key-function cache for the method's class and clears it
3049 /// if matches the given declaration.
3050 ///
3051 /// This is used in ABIs where out-of-line definitions marked
3052 /// inline are not considered to be key functions.
3053 ///
3054 /// \param method should be the declaration from the class definition
3055 void setNonKeyFunction(const CXXMethodDecl *method);
3056
3057 /// Loading virtual member pointers using the virtual inheritance model
3058 /// always results in an adjustment using the vbtable even if the index is
3059 /// zero.
3060 ///
3061 /// This is usually OK because the first slot in the vbtable points
3062 /// backwards to the top of the MDC. However, the MDC might be reusing a
3063 /// vbptr from an nv-base. In this case, the first slot in the vbtable
3064 /// points to the start of the nv-base which introduced the vbptr and *not*
3065 /// the MDC. Modify the NonVirtualBaseAdjustment to account for this.
3067
3068 /// Get the offset of a FieldDecl or IndirectFieldDecl, in bits.
3069 uint64_t getFieldOffset(const ValueDecl *FD) const;
3070
3071 /// Get the offset of an ObjCIvarDecl in bits.
3073 const ObjCIvarDecl *Ivar) const;
3074
3075 /// Find the 'this' offset for the member path in a pointer-to-member
3076 /// APValue.
3078
3079 bool isNearlyEmpty(const CXXRecordDecl *RD) const;
3080
3082
3083 /// If \p T is null pointer, assume the target in ASTContext.
3084 MangleContext *createMangleContext(const TargetInfo *T = nullptr);
3085
3086 /// Creates a device mangle context to correctly mangle lambdas in a mixed
3087 /// architecture compile by setting the lambda mangling number source to the
3088 /// DeviceLambdaManglingNumber. Currently this asserts that the TargetInfo
3089 /// (from the AuxTargetInfo) is a an itanium target.
3091
3093
3094 void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass,
3096
3097 unsigned CountNonClassIvars(const ObjCInterfaceDecl *OI) const;
3098 void CollectInheritedProtocols(const Decl *CDecl,
3100
3101 /// Return true if the specified type has unique object representations
3102 /// according to (C++17 [meta.unary.prop]p9)
3103 bool
3105 bool CheckIfTriviallyCopyable = true) const;
3106
3107 //===--------------------------------------------------------------------===//
3108 // Type Operators
3109 //===--------------------------------------------------------------------===//
3110
3111 /// Return the canonical (structural) type corresponding to the
3112 /// specified potentially non-canonical type \p T.
3113 ///
3114 /// The non-canonical version of a type may have many "decorated" versions of
3115 /// types. Decorators can include typedefs, 'typeof' operators, etc. The
3116 /// returned type is guaranteed to be free of any of these, allowing two
3117 /// canonical types to be compared for exact equality with a simple pointer
3118 /// comparison.
3120 return CanQualType::CreateUnsafe(T.getCanonicalType());
3121 }
3122
3123 static const Type *getCanonicalType(const Type *T) {
3125 }
3126
3127 /// Return the canonical parameter type corresponding to the specific
3128 /// potentially non-canonical one.
3129 ///
3130 /// Qualifiers are stripped off, functions are turned into function
3131 /// pointers, and arrays decay one level into pointers.
3133
3134 /// Determine whether the given types \p T1 and \p T2 are equivalent.
3135 static bool hasSameType(QualType T1, QualType T2) {
3136 return getCanonicalType(T1) == getCanonicalType(T2);
3137 }
3138 static bool hasSameType(const Type *T1, const Type *T2) {
3139 return getCanonicalType(T1) == getCanonicalType(T2);
3140 }
3141
3142 /// Determine whether the given expressions \p X and \p Y are equivalent.
3143 bool hasSameExpr(const Expr *X, const Expr *Y) const;
3144
3145 /// Return this type as a completely-unqualified array type,
3146 /// capturing the qualifiers in \p Quals.
3147 ///
3148 /// This will remove the minimal amount of sugaring from the types, similar
3149 /// to the behavior of QualType::getUnqualifiedType().
3150 ///
3151 /// \param T is the qualified type, which may be an ArrayType
3152 ///
3153 /// \param Quals will receive the full set of qualifiers that were
3154 /// applied to the array.
3155 ///
3156 /// \returns if this is an array type, the completely unqualified array type
3157 /// that corresponds to it. Otherwise, returns T.getUnqualifiedType().
3160 Qualifiers Quals;
3161 return getUnqualifiedArrayType(T, Quals);
3162 }
3163
3164 /// Determine whether the given types are equivalent after
3165 /// cvr-qualifiers have been removed.
3167 return getCanonicalType(T1).getTypePtr() ==
3169 }
3170
3172 bool IsParam) const {
3173 auto SubTnullability = SubT->getNullability();
3174 auto SuperTnullability = SuperT->getNullability();
3175 if (SubTnullability.has_value() == SuperTnullability.has_value()) {
3176 // Neither has nullability; return true
3177 if (!SubTnullability)
3178 return true;
3179 // Both have nullability qualifier.
3180 if (*SubTnullability == *SuperTnullability ||
3181 *SubTnullability == NullabilityKind::Unspecified ||
3182 *SuperTnullability == NullabilityKind::Unspecified)
3183 return true;
3184
3185 if (IsParam) {
3186 // Ok for the superclass method parameter to be "nonnull" and the subclass
3187 // method parameter to be "nullable"
3188 return (*SuperTnullability == NullabilityKind::NonNull &&
3189 *SubTnullability == NullabilityKind::Nullable);
3190 }
3191 // For the return type, it's okay for the superclass method to specify
3192 // "nullable" and the subclass method specify "nonnull"
3193 return (*SuperTnullability == NullabilityKind::Nullable &&
3194 *SubTnullability == NullabilityKind::NonNull);
3195 }
3196 return true;
3197 }
3198
3199 bool ObjCMethodsAreEqual(const ObjCMethodDecl *MethodDecl,
3200 const ObjCMethodDecl *MethodImp);
3201
3202 bool UnwrapSimilarTypes(QualType &T1, QualType &T2,
3203 bool AllowPiMismatch = true) const;
3205 bool AllowPiMismatch = true) const;
3206
3207 /// Determine if two types are similar, according to the C++ rules. That is,
3208 /// determine if they are the same other than qualifiers on the initial
3209 /// sequence of pointer / pointer-to-member / array (and in Clang, object
3210 /// pointer) types and their element types.
3211 ///
3212 /// Clang offers a number of qualifiers in addition to the C++ qualifiers;
3213 /// those qualifiers are also ignored in the 'similarity' check.
3214 bool hasSimilarType(QualType T1, QualType T2) const;
3215
3216 /// Determine if two types are similar, ignoring only CVR qualifiers.
3217 bool hasCvrSimilarType(QualType T1, QualType T2);
3218
3219 /// Retrieves the default calling convention for the current context.
3220 ///
3221 /// The context's default calling convention may differ from the current
3222 /// target's default calling convention if the -fdefault-calling-conv option
3223 /// is used; to get the target's default calling convention, e.g. for built-in
3224 /// functions, call getTargetInfo().getDefaultCallingConv() instead.
3226 bool IsCXXMethod) const;
3227
3228 /// Retrieves the "canonical" template name that refers to a
3229 /// given template.
3230 ///
3231 /// The canonical template name is the simplest expression that can
3232 /// be used to refer to a given template. For most templates, this
3233 /// expression is just the template declaration itself. For example,
3234 /// the template std::vector can be referred to via a variety of
3235 /// names---std::vector, \::std::vector, vector (if vector is in
3236 /// scope), etc.---but all of these names map down to the same
3237 /// TemplateDecl, which is used to form the canonical template name.
3238 ///
3239 /// Dependent template names are more interesting. Here, the
3240 /// template name could be something like T::template apply or
3241 /// std::allocator<T>::template rebind, where the nested name
3242 /// specifier itself is dependent. In this case, the canonical
3243 /// template name uses the shortest form of the dependent
3244 /// nested-name-specifier, which itself contains all canonical
3245 /// types, values, and templates.
3247 bool IgnoreDeduced = false) const;
3248
3249 /// Return the default argument of a template parameter, if one exists.
3250 const TemplateArgument *
3252
3253 /// Determine whether the given template names refer to the same
3254 /// template.
3255 bool hasSameTemplateName(const TemplateName &X, const TemplateName &Y,
3256 bool IgnoreDeduced = false) const;
3257
3258 /// Determine whether the two declarations refer to the same entity.
3259 bool isSameEntity(const NamedDecl *X, const NamedDecl *Y) const;
3260
3261 /// Determine whether two template parameter lists are similar enough
3262 /// that they may be used in declarations of the same template.
3264 const TemplateParameterList *Y) const;
3265
3266 /// Determine whether two template parameters are similar enough
3267 /// that they may be used in declarations of the same template.
3268 bool isSameTemplateParameter(const NamedDecl *X, const NamedDecl *Y) const;
3269
3270 /// Determine whether two 'requires' expressions are similar enough that they
3271 /// may be used in re-declarations.
3272 ///
3273 /// Use of 'requires' isn't mandatory, works with constraints expressed in
3274 /// other ways too.
3276 const AssociatedConstraint &ACY) const;
3277
3278 /// Determine whether two 'requires' expressions are similar enough that they
3279 /// may be used in re-declarations.
3280 ///
3281 /// Use of 'requires' isn't mandatory, works with constraints expressed in
3282 /// other ways too.
3283 bool isSameConstraintExpr(const Expr *XCE, const Expr *YCE) const;
3284
3285 /// Determine whether two type contraint are similar enough that they could
3286 /// used in declarations of the same template.
3287 bool isSameTypeConstraint(const TypeConstraint *XTC,
3288 const TypeConstraint *YTC) const;
3289
3290 /// Determine whether two default template arguments are similar enough
3291 /// that they may be used in declarations of the same template.
3293 const NamedDecl *Y) const;
3294
3295 /// Retrieve the "canonical" template argument.
3296 ///
3297 /// The canonical template argument is the simplest template argument
3298 /// (which may be a type, value, expression, or declaration) that
3299 /// expresses the value of the argument.
3301 const;
3302
3303 /// Canonicalize the given template argument list.
3304 ///
3305 /// Returns true if any arguments were non-canonical, false otherwise.
3306 bool
3308
3309 /// Canonicalize the given TemplateTemplateParmDecl.
3312
3314 TemplateTemplateParmDecl *TTP) const;
3316 TemplateTemplateParmDecl *CanonTTP) const;
3317
3318 /// Determine whether the given template arguments \p Arg1 and \p Arg2 are
3319 /// equivalent.
3321 const TemplateArgument &Arg2) const;
3322
3323 /// Type Query functions. If the type is an instance of the specified class,
3324 /// return the Type pointer for the underlying maximally pretty type. This
3325 /// is a member of ASTContext because this may need to do some amount of
3326 /// canonicalization, e.g. to move type qualifiers into the element type.
3327 const ArrayType *getAsArrayType(QualType T) const;
3329 return dyn_cast_or_null<ConstantArrayType>(getAsArrayType(T));
3330 }
3332 return dyn_cast_or_null<VariableArrayType>(getAsArrayType(T));
3333 }
3335 return dyn_cast_or_null<IncompleteArrayType>(getAsArrayType(T));
3336 }
3338 const {
3339 return dyn_cast_or_null<DependentSizedArrayType>(getAsArrayType(T));
3340 }
3341
3342 /// Return the innermost element type of an array type.
3343 ///
3344 /// For example, will return "int" for int[m][n]
3345 QualType getBaseElementType(const ArrayType *VAT) const;
3346
3347 /// Return the innermost element type of a type (which needn't
3348 /// actually be an array type).
3350
3351 /// Return number of (potentially nested) constant array elements.
3353
3354 /// Return number of elements initialized in a (potentially nested)
3355 /// ArrayInitLoopExpr.
3356 /// \c AILE may be null, in which case 0 is returned.
3357 static uint64_t
3359
3360 /// Perform adjustment on the parameter type of a function.
3361 ///
3362 /// This routine adjusts the given parameter type @p T to the actual
3363 /// parameter type used by semantic analysis (C99 6.7.5.3p[7,8],
3364 /// C++ [dcl.fct]p3). The adjusted parameter type is returned.
3366
3367 /// Retrieve the parameter type as adjusted for use in the signature
3368 /// of a function, decaying array and function types and removing top-level
3369 /// cv-qualifiers.
3371
3373
3374 /// Return the properly qualified result of decaying the specified
3375 /// array type to a pointer.
3376 ///
3377 /// This operation is non-trivial when handling typedefs etc. The canonical
3378 /// type of \p T must be an array type, this returns a pointer to a properly
3379 /// qualified element of the array.
3380 ///
3381 /// See C99 6.7.5.3p7 and C99 6.3.2.1p3.
3383
3384 /// Return the type that \p PromotableType will promote to: C99
3385 /// 6.3.1.1p2, assuming that \p PromotableType is a promotable integer type.
3386 QualType getPromotedIntegerType(QualType PromotableType) const;
3387
3388 /// Recurses in pointer/array types until it finds an Objective-C
3389 /// retainable type and returns its ownership.
3391
3392 /// Whether this is a promotable bitfield reference according
3393 /// to C99 6.3.1.1p2, bullet 2 (and GCC extensions).
3394 ///
3395 /// \returns the type this bit-field will promote to, or NULL if no
3396 /// promotion occurs.
3398
3399 /// Return the highest ranked integer type, see C99 6.3.1.8p1.
3400 ///
3401 /// If \p LHS > \p RHS, returns 1. If \p LHS == \p RHS, returns 0. If
3402 /// \p LHS < \p RHS, return -1.
3403 int getIntegerTypeOrder(QualType LHS, QualType RHS) const;
3404
3405 /// Compare the rank of the two specified floating point types,
3406 /// ignoring the domain of the type (i.e. 'double' == '_Complex double').
3407 ///
3408 /// If \p LHS > \p RHS, returns 1. If \p LHS == \p RHS, returns 0. If
3409 /// \p LHS < \p RHS, return -1.
3410 int getFloatingTypeOrder(QualType LHS, QualType RHS) const;
3411
3412 /// Compare the rank of two floating point types as above, but compare equal
3413 /// if both types have the same floating-point semantics on the target (i.e.
3414 /// long double and double on AArch64 will return 0).
3416
3417 unsigned getTargetAddressSpace(LangAS AS) const;
3418
3419 LangAS getLangASForBuiltinAddressSpace(unsigned AS) const;
3420
3421 /// Get target-dependent integer value for null pointer which is used for
3422 /// constant folding.
3424
3426 return AddrSpaceMapMangling || isTargetAddressSpace(AS);
3427 }
3428
3429 bool hasAnyFunctionEffects() const { return AnyFunctionEffects; }
3430
3431 // Merges two exception specifications, such that the resulting
3432 // exception spec is the union of both. For example, if either
3433 // of them can throw something, the result can throw it as well.
3437 SmallVectorImpl<QualType> &ExceptionTypeStorage,
3438 bool AcceptDependent) const;
3439
3440 // For two "same" types, return a type which has
3441 // the common sugar between them. If Unqualified is true,
3442 // both types need only be the same unqualified type.
3443 // The result will drop the qualifiers which do not occur
3444 // in both types.
3446 bool Unqualified = false) const;
3447
3448private:
3449 // Helper for integer ordering
3450 unsigned getIntegerRank(const Type *T) const;
3451
3452public:
3453 //===--------------------------------------------------------------------===//
3454 // Type Compatibility Predicates
3455 //===--------------------------------------------------------------------===//
3456
3457 /// Compatibility predicates used to check assignment expressions.
3459 bool CompareUnqualified = false); // C99 6.2.7p1
3460
3463
3464 bool isObjCIdType(QualType T) const { return T == getObjCIdType(); }
3465
3466 bool isObjCClassType(QualType T) const { return T == getObjCClassType(); }
3467
3468 bool isObjCSelType(QualType T) const { return T == getObjCSelType(); }
3469
3471 const ObjCObjectPointerType *RHS,
3472 bool ForCompare);
3473
3475 const ObjCObjectPointerType *RHS);
3476
3477 // Check the safety of assignment from LHS to RHS
3479 const ObjCObjectPointerType *RHSOPT);
3481 const ObjCObjectType *RHS);
3483 const ObjCObjectPointerType *LHSOPT,
3484 const ObjCObjectPointerType *RHSOPT,
3485 bool BlockReturnType);
3488 const ObjCObjectPointerType *RHSOPT);
3490
3491 // Functions for calculating composite types
3492 QualType mergeTypes(QualType, QualType, bool OfBlockPointer = false,
3493 bool Unqualified = false, bool BlockReturnType = false,
3494 bool IsConditionalOperator = false);
3495 QualType mergeFunctionTypes(QualType, QualType, bool OfBlockPointer = false,
3496 bool Unqualified = false, bool AllowCXX = false,
3497 bool IsConditionalOperator = false);
3499 bool OfBlockPointer = false,
3500 bool Unqualified = false);
3502 bool OfBlockPointer=false,
3503 bool Unqualified = false);
3505
3507
3508 /// This function merges the ExtParameterInfo lists of two functions. It
3509 /// returns true if the lists are compatible. The merged list is returned in
3510 /// NewParamInfos.
3511 ///
3512 /// \param FirstFnType The type of the first function.
3513 ///
3514 /// \param SecondFnType The type of the second function.
3515 ///
3516 /// \param CanUseFirst This flag is set to true if the first function's
3517 /// ExtParameterInfo list can be used as the composite list of
3518 /// ExtParameterInfo.
3519 ///
3520 /// \param CanUseSecond This flag is set to true if the second function's
3521 /// ExtParameterInfo list can be used as the composite list of
3522 /// ExtParameterInfo.
3523 ///
3524 /// \param NewParamInfos The composite list of ExtParameterInfo. The list is
3525 /// empty if none of the flags are set.
3526 ///
3528 const FunctionProtoType *FirstFnType,
3529 const FunctionProtoType *SecondFnType,
3530 bool &CanUseFirst, bool &CanUseSecond,
3532
3533 void ResetObjCLayout(const ObjCInterfaceDecl *D);
3534
3536 const ObjCInterfaceDecl *SubClass) {
3537 ObjCSubClasses[D].push_back(SubClass);
3538 }
3539
3540 //===--------------------------------------------------------------------===//
3541 // Integer Predicates
3542 //===--------------------------------------------------------------------===//
3543
3544 // The width of an integer, as defined in C99 6.2.6.2. This is the number
3545 // of bits in an integer type excluding any padding bits.
3546 unsigned getIntWidth(QualType T) const;
3547
3548 // Per C99 6.2.5p6, for every signed integer type, there is a corresponding
3549 // unsigned integer type. This method takes a signed type, and returns the
3550 // corresponding unsigned integer type.
3551 // With the introduction of fixed point types in ISO N1169, this method also
3552 // accepts fixed point types and returns the corresponding unsigned type for
3553 // a given fixed point type.
3555
3556 // Per C99 6.2.5p6, for every signed integer type, there is a corresponding
3557 // unsigned integer type. This method takes an unsigned type, and returns the
3558 // corresponding signed integer type.
3559 // With the introduction of fixed point types in ISO N1169, this method also
3560 // accepts fixed point types and returns the corresponding signed type for
3561 // a given fixed point type.
3563
3564 // Per ISO N1169, this method accepts fixed point types and returns the
3565 // corresponding saturated type for a given fixed point type.
3567
3568 // Per ISO N1169, this method accepts fixed point types and returns the
3569 // corresponding non-saturated type for a given fixed point type.
3571
3572 // This method accepts fixed point types and returns the corresponding signed
3573 // type. Unlike getCorrespondingUnsignedType(), this only accepts unsigned
3574 // fixed point types because there are unsigned integer types like bool and
3575 // char8_t that don't have signed equivalents.
3577
3578 //===--------------------------------------------------------------------===//
3579 // Integer Values
3580 //===--------------------------------------------------------------------===//
3581
3582 /// Make an APSInt of the appropriate width and signedness for the
3583 /// given \p Value and integer \p Type.
3584 llvm::APSInt MakeIntValue(uint64_t Value, QualType Type) const {
3585 // If Type is a signed integer type larger than 64 bits, we need to be sure
3586 // to sign extend Res appropriately.
3587 llvm::APSInt Res(64, !Type->isSignedIntegerOrEnumerationType());
3588 Res = Value;
3589 unsigned Width = getIntWidth(Type);
3590 if (Width != Res.getBitWidth())
3591 return Res.extOrTrunc(Width);
3592 return Res;
3593 }
3594
3595 bool isSentinelNullExpr(const Expr *E);
3596
3597 /// Get the implementation of the ObjCInterfaceDecl \p D, or nullptr if
3598 /// none exists.
3600
3601 /// Get the implementation of the ObjCCategoryDecl \p D, or nullptr if
3602 /// none exists.
3604
3605 /// Return true if there is at least one \@implementation in the TU.
3607 return !ObjCImpls.empty();
3608 }
3609
3610 /// Set the implementation of ObjCInterfaceDecl.
3612 ObjCImplementationDecl *ImplD);
3613
3614 /// Set the implementation of ObjCCategoryDecl.
3616 ObjCCategoryImplDecl *ImplD);
3617
3618 /// Get the duplicate declaration of a ObjCMethod in the same
3619 /// interface, or null if none exists.
3620 const ObjCMethodDecl *
3622
3624 const ObjCMethodDecl *Redecl);
3625
3626 /// Returns the Objective-C interface that \p ND belongs to if it is
3627 /// an Objective-C method/property/ivar etc. that is part of an interface,
3628 /// otherwise returns null.
3630
3631 /// Set the copy initialization expression of a block var decl. \p CanThrow
3632 /// indicates whether the copy expression can throw or not.
3633 void setBlockVarCopyInit(const VarDecl* VD, Expr *CopyExpr, bool CanThrow);
3634
3635 /// Get the copy initialization expression of the VarDecl \p VD, or
3636 /// nullptr if none exists.
3638
3639 /// Allocate an uninitialized TypeSourceInfo.
3640 ///
3641 /// The caller should initialize the memory held by TypeSourceInfo using
3642 /// the TypeLoc wrappers.
3643 ///
3644 /// \param T the type that will be the basis for type source info. This type
3645 /// should refer to how the declarator was written in source code, not to
3646 /// what type semantic analysis resolved the declarator to.
3647 ///
3648 /// \param Size the size of the type info to create, or 0 if the size
3649 /// should be calculated based on the type.
3650 TypeSourceInfo *CreateTypeSourceInfo(QualType T, unsigned Size = 0) const;
3651
3652 /// Allocate a TypeSourceInfo where all locations have been
3653 /// initialized to a given location, which defaults to the empty
3654 /// location.
3657 SourceLocation Loc = SourceLocation()) const;
3658
3659 /// Add a deallocation callback that will be invoked when the
3660 /// ASTContext is destroyed.
3661 ///
3662 /// \param Callback A callback function that will be invoked on destruction.
3663 ///
3664 /// \param Data Pointer data that will be provided to the callback function
3665 /// when it is called.
3666 void AddDeallocation(void (*Callback)(void *), void *Data) const;
3667
3668 /// If T isn't trivially destructible, calls AddDeallocation to register it
3669 /// for destruction.
3670 template <typename T> void addDestruction(T *Ptr) const {
3671 if (!std::is_trivially_destructible<T>::value) {
3672 auto DestroyPtr = [](void *V) { static_cast<T *>(V)->~T(); };
3673 AddDeallocation(DestroyPtr, Ptr);
3674 }
3675 }
3676
3679
3680 /// Determines if the decl can be CodeGen'ed or deserialized from PCH
3681 /// lazily, only when used; this is only relevant for function or file scoped
3682 /// var definitions.
3683 ///
3684 /// \returns true if the function/var must be CodeGen'ed/deserialized even if
3685 /// it is not used.
3686 bool DeclMustBeEmitted(const Decl *D);
3687
3688 /// Determines if the global variable or function \p D is emitted on the side
3689 /// of the CUDA/HIP compilation, i.e. host or device, that is being compiled,
3690 /// based on its host/device related attributes.
3691 ///
3692 /// \returns false if CodeGen never emits \p D in this compilation.
3693 bool shouldEmitCUDADecl(const ValueDecl *D) const;
3694
3695 /// Visits all versions of a multiversioned function with the passed
3696 /// predicate.
3698 const FunctionDecl *FD,
3699 llvm::function_ref<void(FunctionDecl *)> Pred) const;
3700
3701 const CXXConstructorDecl *
3703
3705 CXXConstructorDecl *CD);
3706
3708
3710
3712
3714
3715 void setManglingNumber(const NamedDecl *ND, unsigned Number);
3716 unsigned getManglingNumber(const NamedDecl *ND,
3717 bool ForAuxTarget = false) const;
3718
3719 void setStaticLocalNumber(const VarDecl *VD, unsigned Number);
3720 unsigned getStaticLocalNumber(const VarDecl *VD) const;
3721
3722 /// Ordinal for the next TopLevelStmtDecl; counts created and loaded ones.
3724
3726 return !TypeAwareOperatorNewAndDeletes.empty();
3727 }
3728 void setIsDestroyingOperatorDelete(const FunctionDecl *FD, bool IsDestroying);
3729 bool isDestroyingOperatorDelete(const FunctionDecl *FD) const;
3731 bool IsTypeAware);
3732 bool isTypeAwareOperatorNewOrDelete(const FunctionDecl *FD) const;
3733
3735
3737 FunctionDecl *OperatorDelete,
3738 OperatorDeleteKind K) const;
3740 OperatorDeleteKind K) const;
3742 OperatorDeleteKind K) const;
3745
3746 /// Retrieve the context for computing mangling numbers in the given
3747 /// DeclContext.
3751 const Decl *D);
3752
3753 std::unique_ptr<MangleNumberingContext> createMangleNumberingContext() const;
3754
3755 /// Used by ParmVarDecl to store on the side the
3756 /// index of the parameter when it exceeds the size of the normal bitfield.
3757 void setParameterIndex(const ParmVarDecl *D, unsigned index);
3758
3759 /// Used by ParmVarDecl to retrieve on the side the
3760 /// index of the parameter when it exceeds the size of the normal bitfield.
3761 unsigned getParameterIndex(const ParmVarDecl *D) const;
3762
3763 /// Return a string representing the human readable name for the specified
3764 /// function declaration or file name. Used by SourceLocExpr and
3765 /// PredefinedExpr to cache evaluated results.
3767
3768 /// Return the next version number to be used for a string literal evaluated
3769 /// as part of constant evaluation.
3770 unsigned getNextStringLiteralVersion() { return NextStringLiteralVersion++; }
3771
3772 /// Return a declaration for the global GUID object representing the given
3773 /// GUID value.
3775
3776 /// Return a declaration for a uniquified anonymous global constant
3777 /// corresponding to a given APValue.
3780
3781 /// Return the template parameter object of the given type with the given
3782 /// value.
3784 const APValue &V) const;
3785
3786 /// Parses the target attributes passed in, and returns only the ones that are
3787 /// valid feature names.
3788 ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD) const;
3789
3790 const llvm::StringMap<bool> &
3791 getFunctionFeatureMap(const FunctionDecl *FD) const;
3792 const llvm::StringMap<bool> &getFunctionFeatureMap(GlobalDecl GD) const;
3793
3794 void getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap,
3795 const FunctionDecl *) const;
3796 void getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap,
3797 GlobalDecl GD) const;
3798
3799 /// Generates and stores SYCL kernel metadata for the provided
3800 /// SYCL kernel entry point function. The provided function must have
3801 /// an attached sycl_kernel_entry_point attribute that specifies a unique
3802 /// type for the name of a SYCL kernel. Callers are required to detect
3803 /// conflicting SYCL kernel names and issue a diagnostic prior to calling
3804 /// this function.
3806
3807 /// Given a type used as a SYCL kernel name, returns a reference to the
3808 /// metadata generated from the corresponding SYCL kernel entry point.
3809 /// Aborts if the provided type is not a registered SYCL kernel name.
3811
3812 /// Returns a pointer to the metadata generated from the corresponding
3813 /// SYCLkernel entry point if the provided type corresponds to a registered
3814 /// SYCL kernel name. Returns a null pointer otherwise.
3816
3817 //===--------------------------------------------------------------------===//
3818 // Statistics
3819 //===--------------------------------------------------------------------===//
3820
3821 /// The number of implicitly-declared default constructors.
3823
3824 /// The number of implicitly-declared default constructors for
3825 /// which declarations were built.
3827
3828 /// The number of implicitly-declared copy constructors.
3830
3831 /// The number of implicitly-declared copy constructors for
3832 /// which declarations were built.
3834
3835 /// The number of implicitly-declared move constructors.
3837
3838 /// The number of implicitly-declared move constructors for
3839 /// which declarations were built.
3841
3842 /// The number of implicitly-declared copy assignment operators.
3844
3845 /// The number of implicitly-declared copy assignment operators for
3846 /// which declarations were built.
3848
3849 /// The number of implicitly-declared move assignment operators.
3851
3852 /// The number of implicitly-declared move assignment operators for
3853 /// which declarations were built.
3855
3856 /// The number of implicitly-declared destructors.
3858
3859 /// The number of implicitly-declared destructors for which
3860 /// declarations were built.
3862
3863public:
3864 /// Initialize built-in types.
3865 ///
3866 /// This routine may only be invoked once for a given ASTContext object.
3867 /// It is normally invoked after ASTContext construction.
3868 ///
3869 /// \param Target The target
3870 void InitBuiltinTypes(const TargetInfo &Target,
3871 const TargetInfo *AuxTarget = nullptr);
3872
3873private:
3874 void InitBuiltinType(CanQualType &R, BuiltinType::Kind K);
3875
3876 class ObjCEncOptions {
3877 unsigned Bits;
3878
3879 ObjCEncOptions(unsigned Bits) : Bits(Bits) {}
3880
3881 public:
3882 ObjCEncOptions() : Bits(0) {}
3883
3884#define OPT_LIST(V) \
3885 V(ExpandPointedToStructures, 0) \
3886 V(ExpandStructures, 1) \
3887 V(IsOutermostType, 2) \
3888 V(EncodingProperty, 3) \
3889 V(IsStructField, 4) \
3890 V(EncodeBlockParameters, 5) \
3891 V(EncodeClassNames, 6) \
3892
3893#define V(N,I) ObjCEncOptions& set##N() { Bits |= 1 << I; return *this; }
3894OPT_LIST(V)
3895#undef V
3896
3897#define V(N,I) bool N() const { return Bits & 1 << I; }
3898OPT_LIST(V)
3899#undef V
3900
3901#undef OPT_LIST
3902
3903 [[nodiscard]] ObjCEncOptions keepingOnly(ObjCEncOptions Mask) const {
3904 return Bits & Mask.Bits;
3905 }
3906
3907 [[nodiscard]] ObjCEncOptions forComponentType() const {
3908 ObjCEncOptions Mask = ObjCEncOptions()
3909 .setIsOutermostType()
3910 .setIsStructField();
3911 return Bits & ~Mask.Bits;
3912 }
3913 };
3914
3915 // Return the Objective-C type encoding for a given type.
3916 void getObjCEncodingForTypeImpl(QualType t, std::string &S,
3917 ObjCEncOptions Options,
3918 const FieldDecl *Field,
3919 QualType *NotEncodedT = nullptr) const;
3920
3921 // Adds the encoding of the structure's members.
3922 void getObjCEncodingForStructureImpl(RecordDecl *RD, std::string &S,
3923 const FieldDecl *Field,
3924 bool includeVBases = true,
3925 QualType *NotEncodedT=nullptr) const;
3926
3927public:
3928 // Adds the encoding of a method parameter or return type.
3930 QualType T, std::string& S,
3931 bool Extended) const;
3932
3933 /// Returns true if this is an inline-initialized static data member
3934 /// which is treated as a definition for MSVC compatibility.
3935 bool isMSStaticDataMemberInlineDefinition(const VarDecl *VD) const;
3936
3938 /// Not an inline variable.
3939 None,
3940
3941 /// Weak definition of inline variable.
3943
3944 /// Weak for now, might become strong later in this TU.
3946
3947 /// Strong definition.
3949 };
3950
3951 /// Determine whether a definition of this inline variable should
3952 /// be treated as a weak or strong definition. For compatibility with
3953 /// C++14 and before, for a constexpr static data member, if there is an
3954 /// out-of-line declaration of the member, we may promote it from weak to
3955 /// strong.
3958
3959private:
3961 friend class DeclContext;
3962
3963 const ASTRecordLayout &getObjCLayout(const ObjCInterfaceDecl *D) const;
3964
3965 /// A set of deallocations that should be performed when the
3966 /// ASTContext is destroyed.
3967 // FIXME: We really should have a better mechanism in the ASTContext to
3968 // manage running destructors for types which do variable sized allocation
3969 // within the AST. In some places we thread the AST bump pointer allocator
3970 // into the datastructures which avoids this mess during deallocation but is
3971 // wasteful of memory, and here we require a lot of error prone book keeping
3972 // in order to track and run destructors while we're tearing things down.
3973 using DeallocationFunctionsAndArguments =
3974 llvm::SmallVector<std::pair<void (*)(void *), void *>, 16>;
3975 mutable DeallocationFunctionsAndArguments Deallocations;
3976
3977 // FIXME: This currently contains the set of StoredDeclMaps used
3978 // by DeclContext objects. This probably should not be in ASTContext,
3979 // but we include it here so that ASTContext can quickly deallocate them.
3980 llvm::PointerIntPair<StoredDeclsMap *, 1> LastSDM;
3981
3982 std::vector<Decl *> TraversalScope;
3983
3984 std::unique_ptr<VTableContextBase> VTContext;
3985
3986 void ReleaseDeclContextMaps();
3987
3988public:
3989 enum PragmaSectionFlag : unsigned {
3996 PSF_Invalid = 0x80000000U,
3997 };
3998
4010
4011 llvm::StringMap<SectionInfo> SectionInfos;
4012
4013 /// Return a new OMPTraitInfo object owned by this context.
4015
4016 /// Whether a C++ static variable or CUDA/HIP kernel may be externalized.
4017 bool mayExternalize(const Decl *D) const;
4018
4019 /// Whether a C++ static variable or CUDA/HIP kernel should be externalized.
4020 bool shouldExternalize(const Decl *D) const;
4021
4022 /// Resolve the root record to be used to derive the vtable pointer
4023 /// authentication policy for the specified record.
4024 const CXXRecordDecl *
4025 baseForVTableAuthentication(const CXXRecordDecl *ThisClass) const;
4026
4027 bool useAbbreviatedThunkName(GlobalDecl VirtualMethodDecl,
4028 StringRef MangledName);
4029
4030 StringRef getCUIDHash() const;
4031
4032 /// Returns a list of PFP fields for the given type, including subfields in
4033 /// bases or other fields, except for fields contained within fields of union
4034 /// type.
4035 std::vector<PFPField> findPFPFields(QualType Ty) const;
4036
4037 bool hasPFPFields(QualType Ty) const;
4038 static bool isPFPField(const FieldDecl *Field);
4039
4040 /// Returns whether this record's PFP fields (if any) are trivially
4041 /// copyable (i.e. may be memcpy'd). This may also return true if the
4042 /// record does not have any PFP fields, so it may be necessary for the caller
4043 /// to check for PFP fields, e.g. by calling hasPFPFields().
4044 bool arePFPFieldsTriviallyCopyable(const RecordDecl *RD) const;
4045
4046 llvm::SetVector<const FieldDecl *> PFPFieldsWithEvaluatedOffset;
4049
4050private:
4051 /// All OMPTraitInfo objects live in this collection, one per
4052 /// `pragma omp [begin] declare variant` directive.
4053 SmallVector<std::unique_ptr<OMPTraitInfo>, 4> OMPTraitInfoVector;
4054
4055 llvm::DenseMap<GlobalDecl, llvm::StringSet<>> ThunksToBeAbbreviated;
4056};
4057
4058/// Insertion operator for diagnostics.
4060 const ASTContext::SectionInfo &Section);
4061
4062/// Utility function for constructing a nullary selector.
4063inline Selector GetNullarySelector(StringRef name, ASTContext &Ctx) {
4064 const IdentifierInfo *II = &Ctx.Idents.get(name);
4065 return Ctx.Selectors.getSelector(0, &II);
4066}
4067
4068/// Utility function for constructing an unary selector.
4069inline Selector GetUnarySelector(StringRef name, ASTContext &Ctx) {
4070 const IdentifierInfo *II = &Ctx.Idents.get(name);
4071 return Ctx.Selectors.getSelector(1, &II);
4072}
4073
4074} // namespace clang
4075
4076// operator new and delete aren't allowed inside namespaces.
4077
4078/// Placement new for using the ASTContext's allocator.
4079///
4080/// This placement form of operator new uses the ASTContext's allocator for
4081/// obtaining memory.
4082///
4083/// IMPORTANT: These are also declared in clang/AST/ASTContextAllocate.h!
4084/// Any changes here need to also be made there.
4085///
4086/// We intentionally avoid using a nothrow specification here so that the calls
4087/// to this operator will not perform a null check on the result -- the
4088/// underlying allocator never returns null pointers.
4089///
4090/// Usage looks like this (assuming there's an ASTContext 'Context' in scope):
4091/// @code
4092/// // Default alignment (8)
4093/// IntegerLiteral *Ex = new (Context) IntegerLiteral(arguments);
4094/// // Specific alignment
4095/// IntegerLiteral *Ex2 = new (Context, 4) IntegerLiteral(arguments);
4096/// @endcode
4097/// Memory allocated through this placement new operator does not need to be
4098/// explicitly freed, as ASTContext will free all of this memory when it gets
4099/// destroyed. Please note that you cannot use delete on the pointer.
4100///
4101/// @param Bytes The number of bytes to allocate. Calculated by the compiler.
4102/// @param C The ASTContext that provides the allocator.
4103/// @param Alignment The alignment of the allocated memory (if the underlying
4104/// allocator supports it).
4105/// @return The allocated memory. Could be nullptr.
4106inline void *operator new(size_t Bytes, const clang::ASTContext &C,
4107 size_t Alignment /* = 8 */) {
4108 return C.Allocate(Bytes, Alignment);
4109}
4110
4111/// Placement delete companion to the new above.
4112///
4113/// This operator is just a companion to the new above. There is no way of
4114/// invoking it directly; see the new operator for more details. This operator
4115/// is called implicitly by the compiler if a placement new expression using
4116/// the ASTContext throws in the object constructor.
4117inline void operator delete(void *Ptr, const clang::ASTContext &C, size_t) {
4118 C.Deallocate(Ptr);
4119}
4120
4121/// This placement form of operator new[] uses the ASTContext's allocator for
4122/// obtaining memory.
4123///
4124/// We intentionally avoid using a nothrow specification here so that the calls
4125/// to this operator will not perform a null check on the result -- the
4126/// underlying allocator never returns null pointers.
4127///
4128/// Usage looks like this (assuming there's an ASTContext 'Context' in scope):
4129/// @code
4130/// // Default alignment (8)
4131/// char *data = new (Context) char[10];
4132/// // Specific alignment
4133/// char *data = new (Context, 4) char[10];
4134/// @endcode
4135/// Memory allocated through this placement new[] operator does not need to be
4136/// explicitly freed, as ASTContext will free all of this memory when it gets
4137/// destroyed. Please note that you cannot use delete on the pointer.
4138///
4139/// @param Bytes The number of bytes to allocate. Calculated by the compiler.
4140/// @param C The ASTContext that provides the allocator.
4141/// @param Alignment The alignment of the allocated memory (if the underlying
4142/// allocator supports it).
4143/// @return The allocated memory. Could be nullptr.
4144inline void *operator new[](size_t Bytes, const clang::ASTContext& C,
4145 size_t Alignment /* = 8 */) {
4146 return C.Allocate(Bytes, Alignment);
4147}
4148
4149/// Placement delete[] companion to the new[] above.
4150///
4151/// This operator is just a companion to the new[] above. There is no way of
4152/// invoking it directly; see the new[] operator for more details. This operator
4153/// is called implicitly by the compiler if a placement new[] expression using
4154/// the ASTContext throws in the object constructor.
4155inline void operator delete[](void *Ptr, const clang::ASTContext &C, size_t) {
4156 C.Deallocate(Ptr);
4157}
4158
4159template <> struct llvm::DenseMapInfo<llvm::FoldingSetNodeID> {
4160 static unsigned getHashValue(const FoldingSetNodeID &Val) {
4161 return Val.computeHash();
4162 }
4163
4164 static bool isEqual(const FoldingSetNodeID &LHS,
4165 const FoldingSetNodeID &RHS) {
4166 return LHS == RHS;
4167 }
4168};
4169template <> struct llvm::DenseMapInfo<llvm::FoldingSetNodeIDRef> {
4170 static unsigned getHashValue(FoldingSetNodeIDRef Val) {
4171 return Val.computeHash();
4172 }
4173 static bool isEqual(FoldingSetNodeIDRef LHS, FoldingSetNodeIDRef RHS) {
4174 return LHS == RHS;
4175 }
4176 static unsigned getHashValue(const FoldingSetNodeID &Val) {
4177 return Val.computeHash();
4178 }
4179 static bool isEqual(const FoldingSetNodeID &LHS, FoldingSetNodeIDRef RHS) {
4180 return LHS == RHS;
4181 }
4182};
4183
4184#endif // LLVM_CLANG_AST_ASTCONTEXT_H
#define OPT_LIST(V)
#define V(N, I)
Forward declaration of all AST node types.
static bool CanThrow(Expr *E, ASTContext &Ctx)
Definition CFG.cpp:2822
clang::CharUnits operator*(clang::CharUnits::QuantityType Scale, clang::CharUnits CU)
Definition CharUnits.h:194
#define X(type, name)
Definition Value.h:97
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Forward-declares types that need PointerLikeTypeTraits.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
This file declares types used to describe SYCL kernels.
Defines the clang::SourceLocation class and associated facilities.
#define CXXABI(Name, Str)
Allows QualTypes to be sorted and hence used in maps and sets.
C Language Family Type Representation.
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:246
ASTContext(LangOptions &LOpts, SourceManager &SM, IdentifierTable &idents, SelectorTable &sels, Builtin::Context &builtins, TranslationUnitKind TUKind)
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Definition APValue.h:158
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:246
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.
CanQualType AccumTy
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
SourceManager & getSourceManager()
Definition ASTContext.h:923
TranslationUnitDecl * getTranslationUnitDecl() const
const ConstantArrayType * getAsConstantArrayType(QualType T) const
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.
llvm::SmallPtrSet< const FunctionDecl *, 4 > CUDADeviceInvalidFuncs
Functions whose device body should be replaced with a trap stub.
QualType getBuiltinZOSVaListType() const
Retrieve the type of the __builtin_zos_va_list type.
LangAS getOpenCLTypeAddrSpace(const Type *T) const
Get address space for OpenCL type.
friend class ASTWriter
Definition ASTContext.h:618
const llvm::StringMap< bool > & getFunctionFeatureMap(const FunctionDecl *FD) const
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.
QualType getParenType(QualType NamedType) const
size_t getSideTableAllocatedMemory() const
Return the total memory used for various side tables.
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
CanQualType ARCUnbridgedCastTy
uint64_t getTypeSize(const Type *T) const
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.
QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr, QualType Wrapped) const
llvm::DenseMap< const Decl *, comments::FullComment * > ParsedComments
Mapping from declarations to parsed comments attached to any redeclaration.
unsigned getManglingNumber(const NamedDecl *ND, bool ForAuxTarget=false) const
static const Type * getCanonicalType(const Type *T)
CanQualType LongTy
unsigned getIntWidth(QualType T) const
CanQualType getCanonicalParamType(QualType T) const
Return the canonical parameter type corresponding to the specific potentially non-canonical one.
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
TemplateOrSpecializationInfo getTemplateOrSpecializationInfo(const VarDecl *Var)
CanQualType WIntTy
@ Weak
Weak definition of inline variable.
@ WeakUnknown
Weak for now, might become strong later in this TU.
bool dtorHasOperatorDelete(const CXXDestructorDecl *Dtor, OperatorDeleteKind K) const
const ProfileList & getProfileList() const
void setObjCConstantStringInterface(ObjCInterfaceDecl *Decl)
TypedefDecl * getObjCClassDecl() const
Retrieve the typedef declaration corresponding to the predefined Objective-C 'Class' type.
TypedefNameDecl * getTypedefNameForUnnamedTagDecl(const TagDecl *TD)
QualType getTypeDeclType(const UnresolvedUsingTypenameDecl *) const =delete
TypedefDecl * getCFConstantStringDecl() const
CanQualType Int128Ty
CanQualType SatUnsignedFractTy
CanQualType getAdjustedType(CanQualType Orig, CanQualType New) 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...
QualType getConstantMatrixType(QualType ElementType, unsigned NumRows, unsigned NumColumns, std::optional< MatrixType::LayoutKind > Layout=std::nullopt) const
Return the unique reference to the matrix type of the specified element type and size.
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 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
bool AnyObjCImplementation()
Return true if there is at least one @implementation in the TU.
CanQualType UnsignedShortAccumTy
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)
Deallocates a DeclListNode by returning it to the ListNodeFreeList pool.
Definition ASTContext.h:963
unsigned NumTopLevelStmtDecls
Ordinal for the next TopLevelStmtDecl; counts created and loaded ones.
DeclListNode * AllocateDeclListNode(clang::NamedDecl *ND)
Allocates a DeclListNode or returns one from the ListNodeFreeList pool.
Definition ASTContext.h:952
QualType adjustFunctionResultType(QualType FunctionType, QualType NewResultType)
Change the result type of a function type, preserving sugar such as attributed types.
void setTemplateOrSpecializationInfo(VarDecl *Inst, TemplateOrSpecializationInfo TSI)
bool isTypeAwareOperatorNewOrDelete(const FunctionDecl *FD) const
bool ProtocolCompatibleWithProtocol(ObjCProtocolDecl *lProto, ObjCProtocolDecl *rProto) const
ProtocolCompatibleWithProtocol - return 'true' if 'lProto' is in the inheritance hierarchy of 'rProto...
TypedefDecl * buildImplicitTypedef(QualType T, StringRef Name) const
Create a new implicit TU-level typedef declaration.
unsigned getTypeAlign(const Type *T) const
QualType getCanonicalTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName T, ArrayRef< TemplateArgument > CanonicalArgs) const
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
QualType getAutoType(DeducedKind DK, QualType DeducedAsType, AutoTypeKeyword Keyword, TemplateName TypeConstraintConcept=TemplateName(), ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
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.
static CanQualType getCanonicalType(QualType T)
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
QualType getBuiltinVaListType() const
Retrieve the type of the __builtin_va_list type.
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:866
comments::FullComment * cloneFullComment(comments::FullComment *FC, const Decl *D) const
bool containsNonRelocatablePointerAuth(QualType T)
Examines a given type, and returns whether the type itself or any data it transitively contains has a...
Definition ASTContext.h:773
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.
const TemplateArgument * getDefaultTemplateArgumentOrNone(const NamedDecl *P) const
Return the default argument of a template parameter, if one exists.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType, const Attr *attr=nullptr) const
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.
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.
std::unique_ptr< MangleNumberingContext > createMangleNumberingContext() const
CanQualType SatAccumTy
ArrayRef< CXXDefaultArgExpr * > getCtorClosureDefaultArgs(const CXXConstructorDecl *CD)
QualType getUnsignedPointerDiffType() const
Return the unique unsigned counterpart of "ptrdiff_t" integer type.
QualType getucontext_tType() const
Retrieve the C ucontext_t type.
void setDeclVisibilityCallback(std::function< bool(const NamedDecl *)> Callback)
Set the callback that isDeclVisible() uses for declarations that are not unconditionally visible.
std::optional< CharUnits > getTypeSizeInCharsIfKnown(const Type *Ty) const
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.
TemplateName getPackIndexingTemplateName(TemplateName Pattern, Expr *IndexExpr, bool FullySubstituted=false, ArrayRef< TemplateName > Expansions={}) const
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.
MangleContext * createMangleContext(const TargetInfo *T=nullptr)
If T is null pointer, assume the target in ASTContext.
RawComment * getRawCommentNoCache(RawCommentLookupKey Key) const
Return the documentation comment attached to a given declaration or macro, without looking into cache...
QualType getRealTypeForBitwidth(unsigned DestWidth, FloatModeKind ExplicitType) const
getRealTypeForBitwidth - sets floating point QualTy according to specified bitwidth.
ArrayRef< Decl * > getTraversalScope() const
Definition ASTContext.h:908
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
CanQualType ShortAccumTy
ASTMutationListener * getASTMutationListener() const
Retrieve a pointer to the AST mutation listener associated with this AST context, if any.
unsigned NumImplicitCopyAssignmentOperatorsDeclared
The number of implicitly-declared copy assignment operators for which declarations were built.
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,...
unsigned char getFixedPointIBits(QualType Ty) const
QualType getSubstBuiltinTemplatePack(const TemplateArgument &ArgPack)
QualType getCorrespondingSignedFixedPointType(QualType Ty) const
IntrusiveRefCntPtr< ExternalASTSource > ExternalSource
Definition ASTContext.h:867
CanQualType FloatTy
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.
bool isObjCIdType(QualType T) const
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.
friend class IncrementalParser
Definition ASTContext.h:621
unsigned NumImplicitDestructorsDeclared
The number of implicitly-declared destructors for which declarations were built.
bool isObjCClassType(QualType T) const
void setObjCNSStringType(QualType T)
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
bool propertyTypesAreCompatible(QualType, QualType)
void setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst, UsingShadowDecl *Pattern)
CanQualType DoubleTy
QualType getCooperativeMatrixType(QualType ElementType, unsigned Scope, unsigned NumRows, unsigned NumColumns, unsigned Use) const
Return the unique reference to the cooperative matrix type of the specified element type and size.
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
CanQualType SatLongAccumTy
const XRayFunctionFilter & getXRayFilter() const
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.
FunctionDecl * getcudaGetParameterBufferDecl()
TemplateName getDependentTemplateName(const DependentTemplateStorage &Name) const
Retrieve the template name that represents a dependent template name such as MetaFun::template operat...
QualType getFILEType() const
Retrieve the C FILE type.
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.
void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl)
Set the type for the C sigjmp_buf type.
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
CanQualType OMPArrayShapingTy
ASTContext(LangOptions &LOpts, SourceManager &SM, IdentifierTable &idents, SelectorTable &sels, Builtin::Context &builtins, TranslationUnitKind TUKind)
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
TemplateName getCanonicalTemplateName(TemplateName Name, bool IgnoreDeduced=false) const
Retrieves the "canonical" template name that refers to a given template.
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 '...
void addComment(const RawComment &RC)
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...
void setRelocationInfoForCXXRecord(const CXXRecordDecl *, CXXRecordDeclRelocationInfo)
QualType getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl, unsigned Index, UnsignedOrNone PackIndex, bool Final) const
Retrieve a substitution-result type.
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'.
void setFILEDecl(TypeDecl *FILEDecl)
Set the type for the C FILE type.
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
bool defaultsToMsStruct() const
Return whether unannotated records are treated as if they have [[gnu::ms_struct]].
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...
void completeCountAttributedType(CountAttributedType *CATy, Expr *CountExpr, ArrayRef< TypeCoupledDeclRefInfo > DependentDecls) const
Supply the count expression and coupled declarations for a type created by getIncompleteCountAttribut...
CanQualType UnsignedLongFractTy
QualType mergeTagDefinitions(QualType, QualType)
void setClassMaybeNeedsVectorDeletingDestructor(const CXXRecordDecl *RD)
overridden_method_range overridden_methods(const CXXMethodDecl *Method) const
void setIsTypeAwareOperatorNewOrDelete(const FunctionDecl *FD, bool IsTypeAware)
bool hasSeenTypeAwareOperatorNewOrDelete() 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
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
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:942
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
bool QIdProtocolsAdoptObjCObjectProtocols(QualType QT, ObjCInterfaceDecl *IDecl)
QIdProtocolsAdoptObjCObjectProtocols - Checks that protocols in QT's qualified-id protocol list adopt...
FunctionProtoType::ExceptionSpecInfo mergeExceptionSpecs(FunctionProtoType::ExceptionSpecInfo ESI1, FunctionProtoType::ExceptionSpecInfo ESI2, SmallVectorImpl< QualType > &ExceptionTypeStorage, bool AcceptDependent) const
llvm::PointerUnion< const Decl *, const MacroInfo * > RawCommentLookupKey
Key used to look up the raw comment attached to a declaration or macro.
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...
bool BlockRequiresCopying(QualType Ty, const VarDecl *D)
Returns true iff we need copy/dispose helpers for the given type.
QualType getTypeDeclType(const TypeAliasDecl *) const =delete
CanQualType NullPtrTy
QualType getUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const UsingShadowDecl *D, QualType UnderlyingType=QualType()) const
std::optional< QualType > tryMergeOverflowBehaviorTypes(QualType LHS, QualType RHS, bool OfBlockPointer, bool Unqualified, bool BlockReturnType, bool IsConditionalOperator)
Attempts to merge two types that may be OverflowBehaviorTypes.
CanQualType WideCharTy
CanQualType OMPIteratorTy
IdentifierTable & Idents
Definition ASTContext.h:862
Builtin::Context & BuiltinInfo
Definition ASTContext.h:864
bool computeEnumBits(RangeT EnumConstants, unsigned &NumNegativeBits, unsigned &NumPositiveBits)
Compute NumNegativeBits and NumPositiveBits for an enum based on the constant values of its enumerato...
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
QualType getConstType(QualType T) const
Return the uniqued reference to the type for a const qualified type.
bool containsAddressDiscriminatedPointerAuth(QualType T) const
Examines a given type, and returns whether the type itself is address discriminated,...
Definition ASTContext.h:762
QualType getFunctionTypeWithoutPtrSizes(QualType T)
Get a function type and produce the equivalent function type where pointer size address spaces in the...
uint64_t lookupFieldBitOffset(const ObjCInterfaceDecl *OID, const ObjCIvarDecl *Ivar) const
Get the offset of an ObjCIvarDecl in bits.
CanQualType getLogicalOperationType() const
The result type of logical operations, '<', '>', '!=', etc.
SelectorTable & Selectors
Definition ASTContext.h:863
bool isTypeIgnoredBySanitizer(const SanitizerMask &Mask, const QualType &Ty) const
Check if a type can have its sanitizer instrumentation elided based on its presence within an ignorel...
unsigned getMinGlobalAlignOfVar(uint64_t Size, const VarDecl *VD) const
Return the minimum alignment as specified by the target.
RawCommentList Comments
All comments in this translation unit.
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 getLateParsedAttrType(QualType Wrapped, LateParsedTypeAttribute *LateParsedAttr) const
Return a placeholder type for a late-parsed type attribute.
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...
llvm::ArrayRef< BitInterval > getPaddingIntervals(QualType Ty) const
void setObjCSuperType(QualType ST)
TagDecl * MSTypeInfoTagDecl
TypedefDecl * getBOOLDecl() const
Retrieve declaration of 'BOOL' typedef.
CanQualType SatShortFractTy
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current context.
bool canBindObjCObjectType(QualType To, QualType From)
unsigned getNextStringLiteralVersion()
Return the next version number to be used for a string literal evaluated as part of constant evaluati...
TemplateTemplateParmDecl * insertCanonicalTemplateTemplateParmDeclInternal(TemplateTemplateParmDecl *CanonTTP) const
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...
QualType getObjCInstanceType()
Retrieve the Objective-C "instancetype" type.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier NNS, const IdentifierInfo *Name) const
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:977
static bool hasSameType(const Type *T1, const Type *T2)
CanQualType Ibm128Ty
void setASTMutationListener(ASTMutationListener *Listener)
Attach an AST mutation listener to the AST context.
static bool hasLayout(const RecordDecl *D)
Whether layout (offset and size) information can be queried for D.
bool hasUniqueObjectRepresentations(QualType Ty, bool CheckIfTriviallyCopyable=true) const
Return true if the specified type has unique object representations according to (C++17 [meta....
const QualType GetHigherPrecisionFPType(QualType ElementType) const
Definition ASTContext.h:984
CanQualType getCanonicalSizeType() const
bool typesAreBlockPointerCompatible(QualType, QualType)
CanQualType SatUnsignedAccumTy
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.
friend class ASTReader
Definition ASTContext.h:617
QualType getObjCProtoType() const
Retrieve the type of the Objective-C Protocol class.
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.
llvm::SetVector< const VarDecl * > CUDADeviceVarODRUsedByHost
Keep track of CUDA/HIP device-side variables ODR-used by host code.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
Decl * getPrimaryMergedDecl(Decl *D)
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
CanQualType ObjCBuiltinIdTy
overridden_cxx_method_iterator overridden_methods_end(const CXXMethodDecl *Method) const
VTableContextBase * getVTableContext()
void setBOOLDecl(TypedefDecl *TD)
Save declaration of 'BOOL' typedef.
llvm::SetVector< const ValueDecl * > CUDAExternalDeviceDeclODRUsedByHost
Keep track of CUDA/HIP external kernels or device variables ODR-used by host code.
ComparisonCategories CompCategories
Types and expressions required to build C++2a three-way comparisons using operator<=>,...
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
PointerAuthQualifier getObjCMemberSelTypePtrAuth()
QualType AutoDeductTy
CanQualType BoolTy
void setcudaLaunchDeviceDecl(FunctionDecl *FD)
void attachCommentsToJustParsedDecls(ArrayRef< Decl * > Decls, const Preprocessor *PP)
Searches existing comments for doc comments that should be attached to Decls.
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth,...
llvm::BumpPtrAllocator & getAllocator() const
Definition ASTContext.h:932
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
friend class ASTDeclReader
Definition ASTContext.h:616
QualType getCFConstantStringType() const
Return the C structure type used to represent constant CFStrings.
const NoSanitizeList & getNoSanitizeList() const
struct clang::ASTContext::CUDAConstantEvalContext CUDAConstantEvalCtx
IdentifierInfo * getNSObjectName() const
Retrieve the identifier 'NSObject'.
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.
std::string getObjCEncodingForFunctionDecl(const FunctionDecl *Decl) const
Emit the encoded type for the function Decl into S.
TypeSourceInfo * getTemplateSpecializationTypeInfo(ElaboratedTypeKeyword Keyword, SourceLocation ElaboratedKeywordLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKeywordLoc, TemplateName T, SourceLocation TLoc, const TemplateArgumentListInfo &SpecifiedArgs, ArrayRef< TemplateArgument > CanonicalArgs, QualType Canon=QualType()) const
CanQualType MetaInfoTy
bool addressSpaceMapManglingFor(LangAS AS) const
CanQualType UnsignedFractTy
QualType getjmp_bufType() const
Retrieve the C jmp_buf type.
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.
void addOverriddenMethod(const CXXMethodDecl *Method, const CXXMethodDecl *Overridden)
Note that the given C++ Method overrides the given Overridden method.
TemplateTemplateParmDecl * findCanonicalTemplateTemplateParmDeclInternal(TemplateTemplateParmDecl *TTP) const
const TargetInfo * getAuxTargetInfo() const
Definition ASTContext.h:982
CanQualType Float128Ty
CanQualType ObjCBuiltinClassTy
unsigned NumImplicitDefaultConstructorsDeclared
The number of implicitly-declared default constructors for which declarations were built.
CanQualType UnresolvedTemplateTy
void setucontext_tDecl(TypeDecl *ucontext_tDecl)
Set the type for the C ucontext_t type.
OMPTraitInfo & getNewOMPTraitInfo()
Return a new OMPTraitInfo object owned by this context.
friend class CXXRecordDecl
Definition ASTContext.h:620
CanQualType UnsignedLongTy
llvm::DenseSet< const FunctionDecl * > CUDAImplicitHostDeviceFunUsedByDevice
Keep track of CUDA/HIP implicit host device functions used on device side in device compilation.
void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass, SmallVectorImpl< const ObjCIvarDecl * > &Ivars) const
DeepCollectObjCIvars - This routine first collects all declared, but not synthesized,...
bool computeBestEnumTypes(bool IsPacked, unsigned NumNegativeBits, unsigned NumPositiveBits, QualType &BestType, QualType &BestPromotionType)
Compute BestType and BestPromotionType for an enum based on the highest number of negative and positi...
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,...
QualType adjustType(QualType OldType, llvm::function_ref< QualType(QualType)> Adjust) const
Rebuild a type, preserving any existing type sugar.
void addedLocalImportDecl(ImportDecl *Import)
Notify the AST context that a new import declaration has been parsed or implicitly created within thi...
bool hasAnyFunctionEffects() const
const TranslationUnitKind TUKind
Definition ASTContext.h:865
QualType getQualifiedType(const Type *T, Qualifiers Qs) const
Return a type with additional qualifiers.
CanQualType UnsignedLongAccumTy
QualType AutoRRefDeductTy
QualType getRestrictType(QualType T) const
Return the uniqued reference to the type for a restrict qualified type.
RawComment * getRawCommentNoCacheImpl(RawCommentLookupKey Key, const SourceLocation RepresentativeLoc, const std::map< unsigned, RawComment * > &CommentsInFile) const
CountAttributedType * getIncompleteCountAttributedType(QualType WrappedTy, bool CountInBytes, bool OrNull) const
Return a CountAttributedType whose count expression has not been parsed yet, for use by a late-parsed...
TypeInfo getTypeInfo(const Type *T) const
Get the size and alignment of the specified complete type in bits.
CanQualType ShortFractTy
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 arePFPFieldsTriviallyCopyable(const RecordDecl *RD) const
Returns whether this record's PFP fields (if any) are trivially copyable (i.e.
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.
QualType getSubstTemplateTypeParmPackType(Decl *AssociatedDecl, unsigned Index, bool Final, const TemplateArgument &ArgPack)
llvm::DenseMap< const CXXMethodDecl *, CXXCastPath > LambdaCastPaths
For capturing lambdas with an explicit object parameter whose type is derived from the lambda type,...
CanQualType BoundMemberTy
CanQualType SatUnsignedShortFractTy
CanQualType CharTy
QualType removeAddrSpaceQualType(QualType T) const
Remove any existing address space on the type and returns the type with qualifiers intact (or that's ...
bool hasSameFunctionTypeIgnoringParamABI(QualType T, QualType U) const
Determine if two function types are the same, ignoring parameter ABI annotations.
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.
BlockVarCopyInit getBlockVarCopyInit(const VarDecl *VD) const
Get the copy initialization expression of the VarDecl VD, or nullptr if none exists.
QualType getHLSLInlineSpirvType(uint32_t Opcode, uint32_t Size, uint32_t Alignment, ArrayRef< SpirvOperand > Operands)
unsigned NumImplicitMoveConstructorsDeclared
The number of implicitly-declared move constructors for which declarations were built.
bool isInSameModule(const Module *M1, const Module *M2) const
If the two module M1 and M2 are in the same module.
unsigned NumImplicitCopyConstructorsDeclared
The number of implicitly-declared copy constructors for which declarations were built.
QualType getLeastIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
CanQualType IntTy
CanQualType PseudoObjectTy
QualType getWebAssemblyExternrefType() const
Return a WebAssembly externref type.
void setTraversalScope(const std::vector< Decl * > &)
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
friend class NestedNameSpecifier
Definition ASTContext.h:247
void PrintStats() const
MangleContext * cudaNVInitDeviceMC()
unsigned getAlignOfGlobalVar(QualType T, const VarDecl *VD) const
Return the alignment in bits that should be given to a global variable with type T.
bool areCompatibleOverflowBehaviorTypes(QualType LHS, QualType RHS)
Return true if two OverflowBehaviorTypes are compatible for assignment.
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.
unsigned NumImplicitDestructors
The number of implicitly-declared destructors.
CanQualType Float16Ty
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
bool isAlignmentRequired(const Type *T) const
Determine if the alignment the type has was required using an alignment attribute.
TagDecl * MSGuidTagDecl
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
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
ASTMutationListener * Listener
Definition ASTContext.h:868
void setNonKeyFunction(const CXXMethodDecl *method)
Observe that the given method cannot be a key function.
CanQualType ObjCBuiltinBoolTy
TypeInfoChars getTypeInfoInChars(const Type *T) const
QualType getPredefinedSugarType(PredefinedSugarType::Kind KD) 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.
TemplateParamObjectDecl * getTemplateParamObjectDecl(QualType T, const APValue &V) const
Return the template parameter object of the given type with the given value.
interp::Context & getInterpContext() const
Returns the clang bytecode interpreter context.
const SourceManager & getSourceManager() const
Definition ASTContext.h:924
CanQualType OverloadTy
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.
TemplateTemplateParmDecl * getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const
Canonicalize the given TemplateTemplateParmDecl.
CanQualType OCLClkEventTy
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.
bool hasPFPFields(QualType Ty) const
const clang::PrintingPolicy & getPrintingPolicy() const
Definition ASTContext.h:915
void ResetObjCLayout(const ObjCInterfaceDecl *D)
ArrayRef< Module * > getModulesWithMergedDefinition(const NamedDecl *Def)
Get the additional modules in which the definition Def has been merged.
static ImportDecl * getNextLocalImport(ImportDecl *Import)
void setCtorClosureDefaultArgs(const CXXConstructorDecl *CD, ArrayRef< CXXDefaultArgExpr * > Args)
llvm::FixedPointSemantics getFixedPointSemantics(QualType Ty) const
CanQualType SatUnsignedShortAccumTy
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false, bool IsConditionalOperator=false)
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.
QualType getPackIndexingType(QualType Pattern, Expr *IndexExpr, bool FullySubstituted=false, ArrayRef< QualType > Expansions={}, UnsignedOrNone Index=std::nullopt) const
static bool isObjCNSObjectType(QualType Ty)
Return true if this is an NSObject object with its NSObject attribute set.
GVALinkage GetGVALinkageForVariable(const VarDecl *VD) const
llvm::PointerUnion< VarTemplateDecl *, MemberSpecializationInfo * > TemplateOrSpecializationInfo
A type synonym for the TemplateOrInstantiation mapping.
Definition ASTContext.h:612
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)...
QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a non-unique reference to the type for a variable array of the specified element type.
QualType getObjCIdType() const
Represents the Objective-CC id type.
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".
QualType getFunctionTypeWithoutParamABIs(QualType T) const
Get or construct a function type that is equivalent to the input type except that the parameter ABI a...
QualType getCorrespondingUnsaturatedType(QualType Ty) const
comments::FullComment * getCommentForDecl(const Decl *D, const Preprocessor *PP) const
Return parsed documentation comment attached to a given declaration.
TemplateArgument getInjectedTemplateArg(NamedDecl *ParamDecl) const
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.
llvm::DenseMap< CanQualType, SYCLKernelInfo > SYCLKernels
Map of SYCL kernels indexed by the unique type used to name the kernel.
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.
QualType getTypeDeclType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypeDecl *Decl) const
bool isDestroyingOperatorDelete(const FunctionDecl *FD) const
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CanQualType UnsignedInt128Ty
CanQualType BuiltinFnTy
ObjCInterfaceDecl * getObjCProtocolDecl() const
Retrieve the Objective-C class declaration corresponding to the predefined Protocol class.
unsigned NumImplicitDefaultConstructors
The number of implicitly-declared default constructors.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
llvm::iterator_range< overridden_cxx_method_iterator > overridden_method_range
unsigned NumImplicitMoveAssignmentOperatorsDeclared
The number of implicitly-declared move assignment operators for which declarations were built.
void setManglingNumber(const NamedDecl *ND, unsigned Number)
CanQualType OCLSamplerTy
TypedefDecl * getBuiltinVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_va_list type.
TypeInfo getTypeInfo(QualType T) const
CanQualType getCanonicalTypeDeclType(const TypeDecl *TD) const
CanQualType VoidTy
QualType getPackExpansionType(QualType Pattern, UnsignedOrNone NumExpansions, bool ExpectPackInType=true) const
Form a pack expansion type with the given pattern.
CanQualType UnsignedCharTy
CanQualType UnsignedShortFractTy
BuiltinTemplateDecl * buildBuiltinTemplateDecl(BuiltinTemplateKind BTK, const IdentifierInfo *II) const
void * Allocate(size_t Size, unsigned Align=8) const
Definition ASTContext.h:936
ArrayRef< ExplicitInstantiationDecl * > getExplicitInstantiationDecls(const NamedDecl *Spec) const
Get all ExplicitInstantiationDecls for a given specialization.
bool canBuiltinBeRedeclared(const FunctionDecl *) const
Return whether a declaration to a builtin is allowed to be overloaded/redeclared.
CanQualType UnsignedIntTy
unsigned NumImplicitMoveConstructors
The number of implicitly-declared move constructors.
QualType getTypedefType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypedefNameDecl *Decl, QualType UnderlyingType=QualType(), std::optional< bool > TypeMatchesDeclOrNone=std::nullopt) const
Return the unique reference to the type for the specified typedef-name decl.
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.
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...
static bool isPFPField(const FieldDecl *Field)
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.
QualType getTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName T, ArrayRef< TemplateArgument > SpecifiedArgs, ArrayRef< TemplateArgument > CanonicalArgs, QualType Underlying=QualType()) const
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
TagDecl * getMSTypeInfoTagDecl() const
Retrieve the implicitly-predeclared 'struct type_info' declaration.
TemplateName getQualifiedTemplateName(NestedNameSpecifier Qualifier, bool TemplateKeyword, TemplateName Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
QualType getObjCClassRedefinitionType() const
Retrieve the type that Class has been defined to, which may be different from the built-in Class if C...
TagDecl * getMSGuidTagDecl() const
Retrieve the implicitly-predeclared 'struct _GUID' declaration.
bool isSameAssociatedConstraint(const AssociatedConstraint &ACX, const AssociatedConstraint &ACY) const
Determine whether two 'requires' expressions are similar enough that they may be used in re-declarati...
QualType getExceptionObjectType(QualType T) const
CanQualType UnknownAnyTy
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 ...
FieldDecl * getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field) const
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
CanQualType UnsignedLongLongTy
QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error, unsigned *IntegerConstantArgs=nullptr) const
Return the type for the specified builtin.
CanQualType OCLReserveIDTy
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...
void registerSYCLEntryPointFunction(FunctionDecl *FD)
Generates and stores SYCL kernel metadata for the provided SYCL kernel entry point function.
QualType getTypeDeclType(const TagDecl *) const =delete
Use the normal 'getFooBarType' constructors to obtain these types.
size_t getASTAllocatedMemory() const
Return the total amount of physical memory allocated for representing AST nodes and type information.
Definition ASTContext.h:970
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
FunctionDecl * getOperatorDeleteForVDtor(const CXXDestructorDecl *Dtor, OperatorDeleteKind K) const
AttrVec * allocateAttrVec()
Allocate an empty attribute vector with the lifetime of this context.
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...
void UnwrapSimilarArrayTypes(QualType &T1, QualType &T2, bool AllowPiMismatch=true) const
Attempt to unwrap two types that may both be array types with the same bound (or both be array types ...
QualType getObjCConstantStringInterface() const
bool isRepresentableIntegerValue(llvm::APSInt &Value, QualType T)
Determine whether the given integral value is representable within the given type T.
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.
llvm::DenseMap< RawCommentLookupKey, const RawComment * > RawComments
Mapping from declaration or macro to directly attached comment.
const SYCLKernelInfo & getSYCLKernelInfo(QualType T) const
Given a type used as a SYCL kernel name, returns a reference to the metadata generated from the corre...
bool canAssignObjCInterfacesInBlockPointer(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT, bool BlockReturnType)
canAssignObjCInterfacesInBlockPointer - This routine is specifically written for providing type-safet...
CanQualType SatUnsignedLongFractTy
QualType getMemberPointerType(QualType T, NestedNameSpecifier Qualifier, const CXXRecordDecl *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
void setcudaConfigureCallDecl(FunctionDecl *FD)
CanQualType getDecayedType(CanQualType T) const
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
QualType getObjCIdRedefinitionType() const
Retrieve the type that id has been defined to, which may be different from the built-in id if id has ...
const CXXConstructorDecl * getCopyConstructorForExceptionObject(CXXRecordDecl *RD)
QualType getDependentAddressSpaceType(QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttrLoc) const
QualType getTagType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TagDecl *TD, bool OwnsTag) const
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.
CanQualType getMSGuidType() const
Retrieve the implicitly-predeclared 'struct _GUID' type.
const VariableArrayType * getAsVariableArrayType(QualType T) const
QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType, UnaryTransformType::UTTKind UKind) const
Unary type transforms.
void setExternalSource(IntrusiveRefCntPtr< ExternalASTSource > Source)
Attach an external AST source to the AST context.
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
StringLiteral * getPredefinedStringLiteralFromCache(StringRef Key) const
Return a string representing the human readable name for the specified function declaration or file n...
CanQualType getCanonicalUnresolvedUsingType(const UnresolvedUsingTypenameDecl *D) const
bool hasSimilarType(QualType T1, QualType T2) const
Determine if two types are similar, according to the C++ rules.
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.
void setObjCClassRedefinitionType(QualType RedefType)
Set the user-written type that redefines 'SEL'.
bool classMaybeNeedsVectorDeletingDestructor(const CXXRecordDecl *RD)
QualType getTemplateTypeParmType(int Depth, int 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 hasDirectOwnershipQualifier(QualType Ty) const
Return true if the type has been explicitly qualified with ObjC ownership.
CanQualType FractTy
Qualifiers::ObjCLifetime getInnerObjCOwnership(QualType T) const
Recurses in pointer/array types until it finds an Objective-C retainable type and returns its ownersh...
void addCopyConstructorForExceptionObject(CXXRecordDecl *RD, CXXConstructorDecl *CD)
void deduplicateMergedDefinitionsFor(NamedDecl *ND)
Clean up the merged definition list.
FunctionDecl * getcudaConfigureCallDecl()
static uint64_t getConstantArrayElementCount(const ConstantArrayType *CA)
Return number of (potentially nested) constant array elements.
bool isDeclVisible(const NamedDecl *D) const
DiagnosticsEngine & getDiagnostics() const
llvm::StringRef backupStr(llvm::StringRef S) const
Definition ASTContext.h:944
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
const SmallVectorImpl< Type * > & getRecordTypes() const
Retrieve all RecordType and InjectedClassNameType nodes created so far, in creation order.
QualType getUnqualifiedObjCPointerType(QualType type) const
getUnqualifiedObjCPointerType - Returns version of Objective-C pointer type with lifetime qualifier r...
CanQualType LongAccumTy
CanQualType Char32Ty
void recordOffsetOfEvaluation(const OffsetOfExpr *E)
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
QualType getCVRQualifiedType(QualType T, unsigned CVR) const
Return a type with additional const, volatile, or restrict qualifiers.
UnnamedGlobalConstantDecl * getUnnamedGlobalConstantDecl(QualType Ty, const APValue &Value) const
Return a declaration for a uniquified anonymous global constant corresponding to a given APValue.
CanQualType SatFractTy
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size.
QualType getUnresolvedUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const UnresolvedUsingTypenameDecl *D) const
bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec)
Return true if the given vector types are of the same unqualified type or if they are equivalent to t...
void getOverriddenMethods(const NamedDecl *Method, SmallVectorImpl< const NamedDecl * > &Overridden) const
Return C++ or ObjC overridden methods for the given Method.
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
bool hasSameTemplateName(const TemplateName &X, const TemplateName &Y, bool IgnoreDeduced=false) const
Determine whether the given template names refer to the same template.
CanQualType SatLongFractTy
const TargetInfo & getTargetInfo() const
Definition ASTContext.h:981
void setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst, FieldDecl *Tmpl)
CanQualType OCLQueueTy
CanQualType LongFractTy
OBTAssignResult checkOBTAssignmentCompatibility(QualType LHS, QualType RHS)
Check overflow behavior type compatibility for assignments.
CanQualType SatShortAccumTy
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
CanQualType BFloat16Ty
unsigned NumImplicitCopyConstructors
The number of implicitly-declared copy constructors.
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
static uint64_t getArrayInitLoopExprElementCount(const ArrayInitLoopExpr *AILE)
Return number of elements initialized in a (potentially nested) ArrayInitLoopExpr.
void addExplicitInstantiationDecl(const NamedDecl *Spec, ExplicitInstantiationDecl *EID)
Add an ExplicitInstantiationDecl for a given specialization.
QualType getOverflowBehaviorType(const OverflowBehaviorAttr *Attr, QualType Wrapped) const
CanQualType IncompleteMatrixIdxTy
std::optional< CharUnits > getTypeSizeInCharsIfKnown(QualType Ty) const
CXXRecordDecl *& getLambdaDeclarationSlotForMerging(const Decl *ContextDecl, int IndexInContext)
Definition ASTContext.h:751
friend class DeclarationNameTable
CanQualType getNSIntegerType() const
QualType getCorrespondingUnsignedType(QualType T) const
void setBlockVarCopyInit(const VarDecl *VD, Expr *CopyExpr, bool CanThrow)
Set the copy initialization expression of a block var decl.
QualType getLifetimeQualifiedType(QualType type, Qualifiers::ObjCLifetime lifetime)
Return a type with the given lifetime qualifier.
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
TemplateName getSubstTemplateTemplateParmPack(const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index, bool Final) const
QualType getObjCNSStringType() const
bool shouldEmitCUDADecl(const ValueDecl *D) const
Determines if the global variable or function D is emitted on the side of the CUDA/HIP compilation,...
TargetCXXABI::Kind getCXXABIKind() const
Return the C++ ABI kind that should be used.
void setjmp_bufDecl(TypeDecl *jmp_bufDecl)
Set the type for the C jmp_buf type.
QualType getHLSLAttributedResourceType(QualType Wrapped, QualType Contained, const HLSLAttributedResourceType::Attributes &Attrs)
void addDestruction(T *Ptr) const
If T isn't trivially destructible, calls AddDeallocation to register it for destruction.
bool UnwrapSimilarTypes(QualType &T1, QualType &T2, bool AllowPiMismatch=true) const
Attempt to unwrap two types that may be similar (C++ [conv.qual]).
IntrusiveRefCntPtr< ExternalASTSource > getExternalSourcePtr() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
QualType getSignedSizeType() const
Return the unique signed counterpart of the integer type corresponding to size_t.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
void setcudaGetParameterBufferDecl(FunctionDecl *FD)
CanQualType SatUnsignedLongAccumTy
QualType getUnconstrainedType(QualType T) const
Remove any type constraints from a template parameter type, for equivalence comparison of template pa...
CanQualType LongLongTy
CanQualType getCanonicalTagType(const TagDecl *TD) const
bool isSameTemplateArgument(const TemplateArgument &Arg1, const TemplateArgument &Arg2) const
Determine whether the given template arguments Arg1 and Arg2 are equivalent.
QualType getTypeOfType(QualType QT, TypeOfKind Kind) const
getTypeOfType - Unlike many "get<Type>" functions, we don't unique TypeOfType nodes.
QualType getCorrespondingSignedType(QualType T) const
QualType mergeObjCGCQualifiers(QualType, QualType)
mergeObjCGCQualifiers - This routine merges ObjC's GC attribute of 'LHS' and 'RHS' attributes and ret...
QualType getQualifiedType(QualType T, Qualifiers Qs) const
Return a type with additional qualifiers.
llvm::DenseMap< const Decl *, const Decl * > CommentlessRedeclChains
Keeps track of redeclaration chains that don't have any comment attached.
unsigned getTargetAddressSpace(LangAS AS) const
ParentMapContext & getParentMapContext()
Returns the dynamic AST node parent map context.
Definition ASTContext.h:888
std::vector< PFPField > findPFPFields(QualType Ty) const
Returns a list of PFP fields for the given type, including subfields in bases or other fields,...
QualType getWideCharType() const
Return the type of wide characters.
QualType getIntPtrType() const
Return a type compatible with "intptr_t" (C99 7.18.1.4), as defined by the target.
void mergeDefinitionIntoModule(NamedDecl *ND, Module *M, bool NotifyListeners=true)
Note that the definition ND has been merged into module M, and should be visible whenever M is visibl...
QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a non-unique reference to the type for a dependently-sized array of the specified element type...
void addTranslationUnitDecl()
CanQualType WCharTy
bool hasSameNullabilityTypeQualifier(QualType SubT, QualType SuperT, bool IsParam) const
void getObjCEncodingForPropertyType(QualType T, std::string &S) const
Emit the Objective-C property type encoding for the given type T into S.
unsigned NumImplicitCopyAssignmentOperators
The number of implicitly-declared copy assignment operators.
void CollectInheritedProtocols(const Decl *CDecl, llvm::SmallPtrSet< ObjCProtocolDecl *, 8 > &Protocols)
CollectInheritedProtocols - Collect all protocols in current class and those inherited by it.
bool isPromotableIntegerType(QualType T) const
More type predicates useful for type checking/promotion.
T * Allocate(size_t Num=1) const
Definition ASTContext.h:939
llvm::DenseMap< const Decl *, const Decl * > RedeclChainComments
Mapping from canonical declaration to the first redeclaration in chain that has a comment attached.
void adjustDeducedFunctionResultType(FunctionDecl *FD, QualType ResultType)
Change the result type of a function type once it is deduced.
QualType getObjCGCQualType(QualType T, Qualifiers::GC gcAttr) const
Return the uniqued reference to the type for an Objective-C gc-qualified type.
QualType getPointerAuthType(QualType Ty, PointerAuthQualifier PointerAuth)
Return a type with the given __ptrauth qualifier.
QualType getDecltypeType(Expr *e, QualType UnderlyingType) const
C++11 decltype.
std::optional< CXXRecordDeclRelocationInfo > getRelocationInfoForCXXRecord(const CXXRecordDecl *) const
static bool hasSameUnqualifiedType(QualType T1, QualType T2)
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
InlineVariableDefinitionKind getInlineVariableDefinitionKind(const VarDecl *VD) const
Determine whether a definition of this inline variable should be treated as a weak or strong definiti...
const RawComment * getRawCommentForAnyRedecl(RawCommentLookupKey Key, const Decl **OriginalDecl=nullptr) const
Return the documentation comment attached to a given declaration or macro.
void setPrimaryMergedDecl(Decl *D, Decl *Primary)
TemplateName getSubstTemplateTemplateParm(TemplateName replacement, Decl *AssociatedDecl, unsigned Index, UnsignedOrNone PackIndex, bool Final) const
CanQualType getUIntMaxType() const
Return the unique type for "uintmax_t" (C99 7.18.1.5), defined in <stdint.h>.
IdentifierInfo * getBoolName() const
Retrieve the identifier 'bool'.
friend class DeclContext
CharUnits getOffsetOfBaseWithVBPtr(const CXXRecordDecl *RD) const
Loading virtual member pointers using the virtual inheritance model always results in an adjustment u...
LangAS getLangASForBuiltinAddressSpace(unsigned AS) const
bool hasSameFunctionTypeIgnoringPtrSizes(QualType T, QualType U)
Determine whether two function types are the same, ignoring pointer sizes in the return type and para...
void addOperatorDeleteForVDtor(const CXXDestructorDecl *Dtor, FunctionDecl *OperatorDelete, OperatorDeleteKind K) const
unsigned char getFixedPointScale(QualType Ty) const
QualType getIncompleteArrayType(QualType EltTy, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a unique reference to the type for an incomplete array of the specified element type.
QualType getDependentSizedExtVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc) const
QualType DecodeTypeStr(const char *&Str, const ASTContext &Context, ASTContext::GetBuiltinTypeError &Error, bool &RequireICE, bool AllowTypeModifiers) const
void addObjCSubClass(const ObjCInterfaceDecl *D, const ObjCInterfaceDecl *SubClass)
TemplateName getAssumedTemplateName(DeclarationName Name) const
Retrieve a template name representing an unqualified-id that has been assumed to name a template for ...
@ GE_None
No error.
@ GE_Missing_stdio
Missing a type from <stdio.h>
@ GE_Missing_type
Missing a type.
@ GE_Missing_ucontext
Missing a type from <ucontext.h>
@ GE_Missing_setjmp
Missing a type from <setjmp.h>
QualType adjustStringLiteralBaseType(QualType StrLTy) const
uint16_t getPointerAuthTypeDiscriminator(QualType T)
Return the "other" type-specific discriminator for the given type.
llvm::SetVector< const FieldDecl * > PFPFieldsWithEvaluatedOffset
uint16_t getPointerAuthVTablePointerDiscriminator(const CXXRecordDecl *RD, bool IsVTTEntry)
Return the "other" discriminator used for the pointer auth schema used for vtable pointers using the ...
bool canonicalizeTemplateArguments(MutableArrayRef< TemplateArgument > Args) const
Canonicalize the given template argument list.
QualType getTypeOfExprType(Expr *E, TypeOfKind Kind) const
C23 feature and GCC extension.
QualType getMatrixTypeWithLayout(QualType T, MatrixType::LayoutKind Layout) const
CanQualType Char8Ty
bool isUnaryOverflowPatternExcluded(const UnaryOperator *UO)
QualType getSignedWCharType() const
Return the type of "signed wchar_t".
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals) const
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
QualType getTypeDeclType(const TypedefDecl *) const =delete
bool hasCvrSimilarType(QualType T1, QualType T2)
Determine if two types are similar, ignoring only CVR qualifiers.
TemplateName getDeducedTemplateName(TemplateName Underlying, DefaultArguments DefaultArgs) const
Represents a TemplateName which had some of its default arguments deduced.
ObjCImplementationDecl * getObjCImplementation(ObjCInterfaceDecl *D)
Get the implementation of the ObjCInterfaceDecl D, or nullptr if none exists.
CanQualType HalfTy
CanQualType UnsignedAccumTy
void setObjCMethodRedeclaration(const ObjCMethodDecl *MD, const ObjCMethodDecl *Redecl)
void addTypedefNameForUnnamedTagDecl(TagDecl *TD, TypedefNameDecl *TND)
bool isDependenceAllowed() const
QualType getWIntType() const
In C99, this returns a type compatible with the type defined in <stddef.h> as defined by the target.
const CXXRecordDecl * baseForVTableAuthentication(const CXXRecordDecl *ThisClass) const
Resolve the root record to be used to derive the vtable pointer authentication policy for the specifi...
void cacheRawComment(RawCommentLookupKey Original, const RawComment &Comment) const
Attaches Comment to Original (a declaration or macro), and to its redeclaration chain when Original i...
QualType getVariableArrayDecayedType(QualType Ty) const
Returns a vla type where known sizes are replaced with [*].
void setCFConstantStringType(QualType T)
const SYCLKernelInfo * findSYCLKernelInfo(QualType T) const
Returns a pointer to the metadata generated from the corresponding SYCLkernel entry point if the prov...
ASTContext & operator=(const ASTContext &)=delete
Module * getCurrentNamedModule() const
Get module under construction, nullptr if this is not a C++20 module.
unsigned getParameterIndex(const ParmVarDecl *D) const
Used by ParmVarDecl to retrieve on the side the index of the parameter when it exceeds the size of th...
QualType getCommonSugaredType(QualType X, QualType Y, bool Unqualified=false) const
CanQualType OCLEventTy
void setPrintingPolicy(const clang::PrintingPolicy &Policy)
Definition ASTContext.h:919
void AddDeallocation(void(*Callback)(void *), void *Data) const
Add a deallocation callback that will be invoked when the ASTContext is destroyed.
QualType getDeducedTemplateSpecializationType(DeducedKind DK, QualType DeducedAsType, ElaboratedTypeKeyword Keyword, TemplateName Template) const
C++17 deduced class template specialization type.
CXXMethodVector::const_iterator overridden_cxx_method_iterator
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
QualType mergeTransparentUnionType(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false)
mergeTransparentUnionType - if T is a transparent union type and a member of T is compatible with Sub...
QualType isPromotableBitField(Expr *E) const
Whether this is a promotable bitfield reference according to C99 6.3.1.1p2, bullet 2 (and GCC extensi...
bool isSentinelNullExpr(const Expr *E)
CanQualType getNSUIntegerType() const
IdentifierInfo * getNSCopyingName()
Retrieve the identifier 'NSCopying'.
void setIsDestroyingOperatorDelete(const FunctionDecl *FD, bool IsDestroying)
TypedefDecl * getBuiltinZOSVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_zos_va_list type.
void recordMemberDataPointerEvaluation(const ValueDecl *VD)
uint64_t getCharWidth() const
Return the size of the character type, in bits.
CanQualType getPointerType(CanQualType T) const
QualType getUnqualifiedArrayType(QualType T) const
import_range local_imports() const
QualType getBitIntType(bool Unsigned, unsigned NumBits) const
Return a bit-precise integer type with the specified signedness and bit count.
const DependentSizedArrayType * getAsDependentSizedArrayType(QualType T) const
unsigned NumImplicitMoveAssignmentOperators
The number of implicitly-declared move assignment operators.
FunctionDecl * getcudaLaunchDeviceDecl()
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
Represents a loop initializing the elements of an array.
Definition Expr.h:6054
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition TypeBase.h:3821
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Definition Expr.h:7014
Attr - This represents one attribute.
Definition Attr.h:47
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition Expr.h:6758
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
This class is used for builtin types like 'int'.
Definition TypeBase.h:3246
Holds information about both target-independent and target-specific builtins, allowing easy queries b...
Definition Builtins.h:238
Implements C++ ABI-specific semantic analysis functions.
Definition CXXABI.h:29
Represents a C++ constructor within a class.
Definition DeclCXX.h:2645
Represents a C++ destructor within a class.
Definition DeclCXX.h:2924
Represents a static or instance method of a struct/union/class.
Definition DeclCXX.h:2153
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
static CanQual< Type > CreateUnsafe(QualType Other)
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
This is an opaque type for sizes expressed in character units.
Definition CharUnits.h:38
Declaration of a C++20 concept.
Represents the canonical version of C arrays with a specified constant size.
Definition TypeBase.h:3859
Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...
Definition TypeBase.h:3510
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition DeclBase.h:1468
A list storing NamedDecls in the lookup tables.
Definition DeclBase.h:1348
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
Definition DeclBase.h:198
bool isInvalidDecl() const
Definition DeclBase.h:598
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition DeclBase.h:997
The name of a declaration.
Represents a ValueDecl that came out of a declarator.
Definition Decl.h:782
Represents an array type in C++ whose size is a value-dependent expression.
Definition TypeBase.h:4110
Represents a dependent template name that cannot be resolved prior to template instantiation.
Concrete class used by the front-end to report problems and issues.
Definition Diagnostic.h:240
Container for either a single DynTypedNode or for an ArrayRef to DynTypedNode.
An instance of this object exists for each enum constant that is defined.
Definition Decl.h:3609
llvm::APSInt getInitVal() const
Definition Decl.h:3630
Represents an explicit instantiation of a template entity in source code.
This represents one expression.
Definition Expr.h:114
Declaration context for names declared as extern "C" in C++.
Definition Decl.h:249
Abstract interface for external sources of AST nodes.
Represents a member of a struct/union/class.
Definition Decl.h:3346
A SourceLocation and its associated SourceManager.
Represents a function declaration or definition.
Definition Decl.h:2082
Represents a prototype with parameter type info, e.g.
Definition TypeBase.h:5650
A class which abstracts out some details necessary for making a call.
Definition TypeBase.h:4957
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition TypeBase.h:4846
GlobalDecl - represents a global declaration.
Definition GlobalDecl.h:60
One of these records is kept for each identifier that is lexed.
Implements an efficient mapping from strings to IdentifierInfo nodes.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition Decl.h:5246
Represents a C array with an unspecified size.
Definition TypeBase.h:4008
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
A global _GUID constant.
Definition DeclCXX.h:4468
MangleContext - Context for tracking state which persists across multiple calls to the C++ name mangl...
Definition Mangle.h:56
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
Provides information a specialization of a member of a class template, which may be a member function...
Describes a module or submodule.
Definition Module.h:340
This represents a decl that may have a name.
Definition Decl.h:276
A C++ nested-name-specifier augmented with source location information.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
ObjCCategoryDecl - Represents a category declaration.
Definition DeclObjC.h:2335
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
Definition DeclObjC.h:2551
ObjCContainerDecl - Represents a container for method declarations.
Definition DeclObjC.h:954
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition DeclObjC.h:2603
Represents an ObjC class declaration.
Definition DeclObjC.h:1160
ObjCIvarDecl - Represents an ObjC instance variable.
Definition DeclObjC.h:1958
ObjCMethodDecl - Represents an instance or class method declaration.
Definition DeclObjC.h:140
Represents a pointer to an Objective C object.
Definition TypeBase.h:8321
Represents one property declaration in an Objective-C interface.
Definition DeclObjC.h:734
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition DeclObjC.h:2811
Represents an Objective-C protocol declaration.
Definition DeclObjC.h:2090
Represents the declaration of an Objective-C type parameter.
Definition DeclObjC.h:581
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type,...
Definition Expr.h:2596
Represents a parameter to a function.
Definition Decl.h:1832
Pointer-authentication qualifiers.
Definition TypeBase.h:153
PredefinedSugarKind Kind
Definition TypeBase.h:8591
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
A (possibly-)qualified type.
Definition TypeBase.h:938
QualType withFastQualifiers(unsigned TQs) const
Definition TypeBase.h:1217
PointerAuthQualifier getPointerAuth() const
Definition TypeBase.h:1469
QualType withConst() const
Definition TypeBase.h:1175
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition TypeBase.h:8680
A qualifier set is used to build a set of qualifiers.
Definition TypeBase.h:8620
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
Definition TypeBase.h:8627
The collection of all-type qualifiers we support.
Definition TypeBase.h:332
@ OCL_None
There is no lifetime qualification on this type.
Definition TypeBase.h:351
void removeObjCLifetime()
Definition TypeBase.h:552
bool hasNonFastQualifiers() const
Return true if the set contains any qualifiers which require an ExtQuals node to be allocated.
Definition TypeBase.h:639
unsigned getFastQualifiers() const
Definition TypeBase.h:620
static Qualifiers fromCVRMask(unsigned CVR)
Definition TypeBase.h:436
void setPointerAuth(PointerAuthQualifier Q)
Definition TypeBase.h:607
void addObjCLifetime(ObjCLifetime type)
Definition TypeBase.h:553
This class represents all comments included in the translation unit, sorted in order of appearance in...
Represents a struct/union/class.
Definition Decl.h:4512
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
Definition Decl.h:4696
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
Definition Decl.h:5523
Scope - A scope is a transient data structure that is used while parsing the program.
Definition Scope.h:42
This table allows us to fully hide how we implement multi-keyword caching.
Selector getSelector(unsigned NumArgs, const IdentifierInfo **IIV)
Can create any sort of selector.
Smart pointer class that efficiently represents Objective-C method names.
Encodes a location in the source.
This class handles loading and caching of source files into memory.
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
clang::DiagStorageAllocator DiagStorageAllocator
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1844
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3904
TagTypeKind TagKind
Definition Decl.h:3909
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition Decl.h:4005
Kind
The basic C++ ABI kind.
Exposes information about the current target.
Definition TargetInfo.h:228
A convenient class for passing around template argument information.
Represents a template argument.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Represents a C++ template name within the type system.
A template parameter object.
Stores a list of template parameters for a TemplateDecl and its derived classes.
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Declaration of a template type parameter.
Token - This structure provides full information about a lexed token.
Definition Token.h:36
The top declaration context.
Definition Decl.h:107
static TranslationUnitDecl * Create(ASTContext &C)
Definition Decl.cpp:5609
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Definition Decl.h:3875
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Definition ASTConcept.h:224
Represents a declaration of a type.
Definition Decl.h:3700
A container of type source information.
Definition TypeBase.h:8651
The base class of the type hierarchy.
Definition TypeBase.h:1879
bool isSizelessType() const
As an extension, we classify types as one of "sized" or "sizeless"; every type is one or the other.
Definition Type.cpp:2812
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
Definition Type.cpp:2433
bool isObjCNSObjectType() const
Definition Type.cpp:5626
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition TypeBase.h:2864
QualType getCanonicalTypeInternal() const
Definition TypeBase.h:3201
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
Definition TypeBase.h:9453
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
Definition Type.cpp:2678
NullabilityKindOrNone getNullability() const
Determine the nullability of the given type.
Definition Type.cpp:5353
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Definition Decl.h:3854
Base class for declarations which introduce a typedef-name.
Definition Decl.h:3749
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition Expr.h:2313
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
Definition DeclCXX.h:4525
The iterator over UnresolvedSets.
Represents the dependent type named by a dependently-scoped typename using declaration,...
Definition TypeBase.h:6365
Represents a dependent using declaration which was marked with typename.
Definition DeclCXX.h:4084
Represents a C++ using-enum-declaration.
Definition DeclCXX.h:3839
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition DeclCXX.h:3446
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:714
Represents a variable declaration or definition.
Definition Decl.h:934
Declaration of a variable template.
Represents a C array with a specified size that is not an integer-constant-expression.
Definition TypeBase.h:4065
Represents a GCC generic vector type.
Definition TypeBase.h:4399
This class provides information about commands that can be used in comments.
A full comment attached to a declaration, contains block content.
Definition Comment.h:1097
Holds all information required to evaluate constexpr code in a module.
Definition Context.h:49
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicDynCastAllOfMatcher< Stmt, BlockExpr > blockExpr
Matches a reference to a block.
llvm::FixedPointSemantics FixedPointSemantics
Definition Interp.h:57
Top level wrappers for InstallAPI frontend operations.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
GVALinkage
A more specific kind of linkage than enum Linkage.
Definition Linkage.h:72
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
Definition TypeBase.h:1838
bool isTargetAddressSpace(LangAS AS)
OpenCLTypeKind
OpenCL type kinds.
Definition TargetInfo.h:214
Stmt Stmt * Callback
Definition StmtOpenMP.h:930
NullabilityKind
Describes the nullability of a particular type.
Definition Specifiers.h:350
@ Nullable
Values of this type can be null.
Definition Specifiers.h:354
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
Definition Specifiers.h:359
@ NonNull
Values of this type can never be null.
Definition Specifiers.h:352
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
Definition Parser.h:62
TypeOfKind
The kind of 'typeof' expression we're after.
Definition TypeBase.h:919
SmallVector< Attr *, 4 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
Definition Linkage.h:54
Selector GetUnarySelector(StringRef name, ASTContext &Ctx)
Utility function for constructing an unary selector.
@ Result
The result type of a method or function.
Definition TypeBase.h:906
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition TypeBase.h:3818
OptionalUnsigned< unsigned > UnsignedOrNone
@ Template
We are parsing a template declaration.
Definition Parser.h:82
Selector GetNullarySelector(StringRef name, ASTContext &Ctx)
Utility function for constructing a nullary selector.
@ Class
The "class" keyword.
Definition TypeBase.h:6284
BuiltinTemplateKind
Kinds of BuiltinTemplateDecl.
Definition Builtins.h:508
@ Keyword
The name has been typo-corrected to a keyword.
Definition Sema.h:556
LangAS
Defines the address space values used by the address space qualifier of QualType.
TranslationUnitKind
Describes the kind of translation unit being processed.
@ TU_Incremental
The translation unit is a is a complete translation unit that we might incrementally extend later.
DeducedKind
Definition TypeBase.h:1811
FloatModeKind
Definition TargetInfo.h:76
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
Definition ASTContext.h:148
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ConceptReference *C)
Insertion operator for diagnostics.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Definition Specifiers.h:192
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition Specifiers.h:282
U cast(CodeGen::Address addr)
Definition Address.h:327
AlignRequirementKind
Definition ASTContext.h:175
@ ResistPragmaPack
The type's natural alignment is preserved under pragma pack in MSVC record layout (e....
Definition ASTContext.h:190
@ None
The alignment was not explicit in code.
Definition ASTContext.h:177
@ RequiredByEnum
The alignment comes from an alignment attribute on a enum type.
Definition ASTContext.h:186
@ RequiredByTypedef
The alignment comes from an alignment attribute on a typedef.
Definition ASTContext.h:180
@ RequiredByRecord
The alignment comes from an alignment attribute on a record type.
Definition ASTContext.h:183
@ PackIndex
Index of a pack indexing expression or specifier.
Definition Sema.h:845
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition TypeBase.h:6248
@ None
No keyword precedes the qualified type name.
Definition TypeBase.h:6269
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
int const char * function
Definition c++config.h:31
int32_t uint32_t uint32_t __builtin_riscv_mhracc_i32 __builtin_riscv_mhraccu_u32 __builtin_riscv_mhraccsu_i32 __builtin_riscv_mhacc_h1_i32 __builtin_riscv_mhaccsu_h1_i32 __builtin_riscv_mulqr_i32 __builtin_riscv_mqrwacc_i64 __packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 __packed_splat4 uint16_t
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t int64_t
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t uint64_t __builtin_riscv_ssha_i32 __builtin_riscv_sshl_u32 uint64_t
int32_t uint32_t uint32_t __builtin_riscv_mhracc_i32 __builtin_riscv_mhraccu_u32 __builtin_riscv_mhraccsu_i32 __builtin_riscv_mhacc_h1_i32 __builtin_riscv_mhaccsu_h1_i32 __builtin_riscv_mulqr_i32 __builtin_riscv_mqrwacc_i64 __packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 uint8_t
BuiltinVectorTypeInfo(QualType ElementType, llvm::ElementCount EC, unsigned NumVectors)
CUDAConstantEvalContextRAII(ASTContext &Ctx_, bool NoWrongSidedVars)
Definition ASTContext.h:880
BuiltinVectorTypeInfo(QualType ElementType, llvm::ElementCount EC, unsigned NumVectors)
CUDAConstantEvalContextRAII(ASTContext &Ctx_, bool NoWrongSidedVars)
Definition ASTContext.h:880
bool NoWrongSidedVars
Do not allow wrong-sided variables in constant expressions.
Definition ASTContext.h:875
SourceLocation PragmaSectionLocation
SectionInfo(NamedDecl *Decl, SourceLocation PragmaSectionLocation, int SectionFlags)
Copy initialization expr of a __block variable and a boolean flag that indicates whether the expressi...
Definition Expr.h:6804
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
Holds information about the various types of exception specification.
Definition TypeBase.h:5707
Extra information about a function prototype.
Definition TypeBase.h:5735
A late-parsed attribute that will be applied as a type attribute.
Definition Parser.h:239
Parts of a decomposed MSGuidDecl.
Definition DeclCXX.h:4443
FieldDecl * Field
Definition ASTContext.h:225
CharUnits Offset
Definition ASTContext.h:224
Contains information gathered from parsing the contents of TargetAttr.
Definition TargetInfo.h:59
Describes how types, statements, expressions, and declarations should be printed.
UniquingSet info for pools keyed on a QualType and a bool.
Definition ASTContext.h:230
static unsigned getHashValue(const KeyTy &Key)
Definition ASTContext.h:235
static KeyTy getKey(const T &N)
Definition ASTContext.h:233
static bool isEqual(const KeyTy &Key, const T &N)
Definition ASTContext.h:239
std::pair< QualType, bool > KeyTy
Definition ASTContext.h:231
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
Definition TypeBase.h:871
const Type * Ty
The locally-unqualified type.
Definition TypeBase.h:873
Qualifiers Quals
The local qualifiers.
Definition TypeBase.h:876
AlignRequirementKind AlignRequirement
Definition ASTContext.h:211
TypeInfoChars(CharUnits Width, CharUnits Align, AlignRequirementKind AlignRequirement)
Definition ASTContext.h:214
bool isAlignRequired()
Definition ASTContext.h:202
AlignRequirementKind AlignRequirement
Definition ASTContext.h:196
TypeInfo(uint64_t Width, unsigned Align, AlignRequirementKind AlignRequirement)
Definition ASTContext.h:199
static bool isEqual(const ScalableVecTyKey &LHS, const ScalableVecTyKey &RHS)
Definition ASTContext.h:78
static unsigned getHashValue(const ScalableVecTyKey &Val)
Definition ASTContext.h:74
static bool isEqual(FoldingSetNodeIDRef LHS, FoldingSetNodeIDRef RHS)
static unsigned getHashValue(FoldingSetNodeIDRef Val)
static bool isEqual(const FoldingSetNodeID &LHS, FoldingSetNodeIDRef RHS)
static unsigned getHashValue(const FoldingSetNodeID &Val)
static bool isEqual(const FoldingSetNodeID &LHS, const FoldingSetNodeID &RHS)
static unsigned getHashValue(const FoldingSetNodeID &Val)
clang::QualType EltTy
Definition ASTContext.h:61
bool operator==(const ScalableVecTyKey &RHS) const
Definition ASTContext.h:65