clang 23.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 "llvm/ADT/DenseMap.h"
34#include "llvm/ADT/DenseMapInfo.h"
35#include "llvm/ADT/DenseSet.h"
36#include "llvm/ADT/FoldingSet.h"
37#include "llvm/ADT/IntrusiveRefCntPtr.h"
38#include "llvm/ADT/MapVector.h"
39#include "llvm/ADT/PointerIntPair.h"
40#include "llvm/ADT/PointerUnion.h"
41#include "llvm/ADT/SetVector.h"
42#include "llvm/ADT/SmallVector.h"
43#include "llvm/ADT/StringMap.h"
44#include "llvm/ADT/StringRef.h"
45#include "llvm/ADT/StringSet.h"
46#include "llvm/ADT/TinyPtrVector.h"
47#include "llvm/Support/TypeSize.h"
48#include <optional>
49
50namespace llvm {
51
52class APFixedPoint;
54struct fltSemantics;
55template <typename T, unsigned N> class SmallPtrSet;
56
59 unsigned NumElts;
60 unsigned NumFields;
61
62 bool operator==(const ScalableVecTyKey &RHS) const {
63 return EltTy == RHS.EltTy && NumElts == RHS.NumElts &&
64 NumFields == RHS.NumFields;
65 }
66};
67
68// Provide a DenseMapInfo specialization so that ScalableVecTyKey can be used
69// as a key in DenseMap.
70template <> struct DenseMapInfo<ScalableVecTyKey> {
71 static inline ScalableVecTyKey getEmptyKey() {
72 return {DenseMapInfo<clang::QualType>::getEmptyKey(), ~0U, ~0U};
73 }
75 return {DenseMapInfo<clang::QualType>::getTombstoneKey(), ~0U, ~0U};
76 }
77 static unsigned getHashValue(const ScalableVecTyKey &Val) {
78 return hash_combine(DenseMapInfo<clang::QualType>::getHashValue(Val.EltTy),
79 Val.NumElts, Val.NumFields);
80 }
81 static bool isEqual(const ScalableVecTyKey &LHS,
82 const ScalableVecTyKey &RHS) {
83 return LHS == RHS;
84 }
85};
86
87} // namespace llvm
88
89namespace clang {
90
91class APValue;
93class ASTRecordLayout;
94class AtomicExpr;
95class BlockExpr;
96struct BlockVarCopyInit;
98class CharUnits;
99class ConceptDecl;
100class CXXABI;
102class CXXMethodDecl;
103class CXXRecordDecl;
105class DynTypedNodeList;
106class Expr;
108enum class FloatModeKind;
109class GlobalDecl;
110class IdentifierTable;
111class LangOptions;
112class MangleContext;
115class Module;
116struct MSGuidDeclParts;
118class NoSanitizeList;
119class ObjCCategoryDecl;
122class ObjCImplDecl;
125class ObjCIvarDecl;
126class ObjCMethodDecl;
127class ObjCPropertyDecl;
129class ObjCProtocolDecl;
131class OMPTraitInfo;
132class ParentMapContext;
133struct ParsedTargetAttr;
134class Preprocessor;
135class ProfileList;
136class StoredDeclsMap;
137class TargetAttr;
138class TargetInfo;
139class TemplateDecl;
143class TypeConstraint;
145class UsingShadowDecl;
146class VarTemplateDecl;
149
150/// A simple array of base specifiers.
152
153namespace Builtin {
154
155class Context;
156
157} // namespace Builtin
158
160enum OpenCLTypeKind : uint8_t;
161
162namespace comments {
163
164class FullComment;
165
166} // namespace comments
167
168namespace interp {
169
170class Context;
171
172} // namespace interp
173
174namespace serialization {
175template <class> class AbstractTypeReader;
176} // namespace serialization
177
179 /// The alignment was not explicit in code.
181
182 /// The alignment comes from an alignment attribute on a typedef.
184
185 /// The alignment comes from an alignment attribute on a record type.
187
188 /// The alignment comes from an alignment attribute on a enum type.
190};
191
205
219
224
225/// Holds long-lived AST nodes (such as types and decls) that can be
226/// referred to throughout the semantic analysis of a file.
227class ASTContext : public RefCountedBase<ASTContext> {
229
230 mutable SmallVector<Type *, 0> Types;
231 mutable llvm::FoldingSet<ExtQuals> ExtQualNodes;
232 mutable llvm::FoldingSet<ComplexType> ComplexTypes;
233 mutable llvm::FoldingSet<PointerType> PointerTypes{GeneralTypesLog2InitSize};
234 mutable llvm::FoldingSet<AdjustedType> AdjustedTypes;
235 mutable llvm::FoldingSet<BlockPointerType> BlockPointerTypes;
236 mutable llvm::FoldingSet<LValueReferenceType> LValueReferenceTypes;
237 mutable llvm::FoldingSet<RValueReferenceType> RValueReferenceTypes;
238 mutable llvm::FoldingSet<MemberPointerType> MemberPointerTypes;
239 mutable llvm::ContextualFoldingSet<ConstantArrayType, ASTContext &>
240 ConstantArrayTypes;
241 mutable llvm::FoldingSet<IncompleteArrayType> IncompleteArrayTypes;
242 mutable std::vector<VariableArrayType*> VariableArrayTypes;
243 mutable llvm::ContextualFoldingSet<DependentSizedArrayType, ASTContext &>
244 DependentSizedArrayTypes;
245 mutable llvm::ContextualFoldingSet<DependentSizedExtVectorType, ASTContext &>
246 DependentSizedExtVectorTypes;
247 mutable llvm::ContextualFoldingSet<DependentAddressSpaceType, ASTContext &>
248 DependentAddressSpaceTypes;
249 mutable llvm::FoldingSet<VectorType> VectorTypes;
250 mutable llvm::ContextualFoldingSet<DependentVectorType, ASTContext &>
251 DependentVectorTypes;
252 mutable llvm::FoldingSet<ConstantMatrixType> MatrixTypes;
253 mutable llvm::ContextualFoldingSet<DependentSizedMatrixType, ASTContext &>
254 DependentSizedMatrixTypes;
255 mutable llvm::FoldingSet<FunctionNoProtoType> FunctionNoProtoTypes;
256 mutable llvm::ContextualFoldingSet<FunctionProtoType, ASTContext&>
257 FunctionProtoTypes;
258 mutable llvm::ContextualFoldingSet<DependentTypeOfExprType, ASTContext &>
259 DependentTypeOfExprTypes;
260 mutable llvm::ContextualFoldingSet<DependentDecltypeType, ASTContext &>
261 DependentDecltypeTypes;
262
263 mutable llvm::ContextualFoldingSet<PackIndexingType, ASTContext &>
264 DependentPackIndexingTypes;
265
266 mutable llvm::FoldingSet<TemplateTypeParmType> TemplateTypeParmTypes;
267 mutable llvm::FoldingSet<ObjCTypeParamType> ObjCTypeParamTypes;
268 mutable llvm::FoldingSet<SubstTemplateTypeParmType>
269 SubstTemplateTypeParmTypes;
270 mutable llvm::FoldingSet<SubstTemplateTypeParmPackType>
271 SubstTemplateTypeParmPackTypes;
272 mutable llvm::FoldingSet<SubstBuiltinTemplatePackType>
273 SubstBuiltinTemplatePackTypes;
274 mutable llvm::ContextualFoldingSet<TemplateSpecializationType, ASTContext&>
275 TemplateSpecializationTypes;
276 mutable llvm::FoldingSet<ParenType> ParenTypes{GeneralTypesLog2InitSize};
277 mutable llvm::FoldingSet<TagTypeFoldingSetPlaceholder> TagTypes;
278 mutable llvm::FoldingSet<FoldingSetPlaceholder<UnresolvedUsingType>>
279 UnresolvedUsingTypes;
280 mutable llvm::FoldingSet<UsingType> UsingTypes;
281 mutable llvm::FoldingSet<FoldingSetPlaceholder<TypedefType>> TypedefTypes;
282 mutable llvm::FoldingSet<DependentNameType> DependentNameTypes;
283 mutable llvm::FoldingSet<PackExpansionType> PackExpansionTypes;
284 mutable llvm::FoldingSet<ObjCObjectTypeImpl> ObjCObjectTypes;
285 mutable llvm::FoldingSet<ObjCObjectPointerType> ObjCObjectPointerTypes;
286 mutable llvm::FoldingSet<UnaryTransformType> UnaryTransformTypes;
287 // An AutoType can have a dependency on another AutoType via its template
288 // arguments. Since both dependent and dependency are on the same set,
289 // we can end up in an infinite recursion when looking for a node if we used
290 // a `FoldingSet`, since both could end up in the same bucket.
291 mutable llvm::DenseMap<llvm::FoldingSetNodeID, AutoType *> AutoTypes;
292 mutable llvm::FoldingSet<DeducedTemplateSpecializationType>
293 DeducedTemplateSpecializationTypes;
294 mutable llvm::FoldingSet<AtomicType> AtomicTypes;
295 mutable llvm::FoldingSet<AttributedType> AttributedTypes;
296 mutable llvm::FoldingSet<PipeType> PipeTypes;
297 mutable llvm::FoldingSet<BitIntType> BitIntTypes;
298 mutable llvm::ContextualFoldingSet<DependentBitIntType, ASTContext &>
299 DependentBitIntTypes;
300 mutable llvm::FoldingSet<BTFTagAttributedType> BTFTagAttributedTypes;
301 mutable llvm::FoldingSet<OverflowBehaviorType> OverflowBehaviorTypes;
302 llvm::FoldingSet<HLSLAttributedResourceType> HLSLAttributedResourceTypes;
303 llvm::FoldingSet<HLSLInlineSpirvType> HLSLInlineSpirvTypes;
304
305 mutable llvm::FoldingSet<CountAttributedType> CountAttributedTypes;
306
307 mutable llvm::FoldingSet<QualifiedTemplateName> QualifiedTemplateNames;
308 mutable llvm::FoldingSet<DependentTemplateName> DependentTemplateNames;
309 mutable llvm::FoldingSet<SubstTemplateTemplateParmStorage>
310 SubstTemplateTemplateParms;
311 mutable llvm::ContextualFoldingSet<SubstTemplateTemplateParmPackStorage,
312 ASTContext&>
313 SubstTemplateTemplateParmPacks;
314 mutable llvm::ContextualFoldingSet<DeducedTemplateStorage, ASTContext &>
315 DeducedTemplates;
316
317 mutable llvm::ContextualFoldingSet<ArrayParameterType, ASTContext &>
318 ArrayParameterTypes;
319
320 /// Store the unique Type corresponding to each Kind.
321 mutable std::array<Type *,
322 llvm::to_underlying(PredefinedSugarType::Kind::Last) + 1>
323 PredefinedSugarTypes{};
324
325 /// Internal storage for NestedNameSpecifiers.
326 ///
327 /// This set is managed by the NestedNameSpecifier class.
328 mutable llvm::FoldingSet<NamespaceAndPrefixStorage>
329 NamespaceAndPrefixStorages;
330
331 /// A cache mapping from RecordDecls to ASTRecordLayouts.
332 ///
333 /// This is lazily created. This is intentionally not serialized.
334 mutable llvm::DenseMap<const RecordDecl*, const ASTRecordLayout*>
335 ASTRecordLayouts;
336 mutable llvm::DenseMap<const ObjCInterfaceDecl *, const ASTRecordLayout *>
337 ObjCLayouts;
338
339 /// A cache from types to size and alignment information.
340 using TypeInfoMap = llvm::DenseMap<const Type *, struct TypeInfo>;
341 mutable TypeInfoMap MemoizedTypeInfo;
342
343 /// A cache from types to unadjusted alignment information. Only ARM and
344 /// AArch64 targets need this information, keeping it separate prevents
345 /// imposing overhead on TypeInfo size.
346 using UnadjustedAlignMap = llvm::DenseMap<const Type *, unsigned>;
347 mutable UnadjustedAlignMap MemoizedUnadjustedAlign;
348
349 /// A cache mapping from CXXRecordDecls to key functions.
350 llvm::DenseMap<const CXXRecordDecl*, LazyDeclPtr> KeyFunctions;
351
352 /// Mapping from ObjCContainers to their ObjCImplementations.
353 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*> ObjCImpls;
354
355 /// Mapping from ObjCMethod to its duplicate declaration in the same
356 /// interface.
357 llvm::DenseMap<const ObjCMethodDecl*,const ObjCMethodDecl*> ObjCMethodRedecls;
358
359 /// Mapping from __block VarDecls to BlockVarCopyInit.
360 llvm::DenseMap<const VarDecl *, BlockVarCopyInit> BlockVarCopyInits;
361
362 /// Mapping from GUIDs to the corresponding MSGuidDecl.
363 mutable llvm::FoldingSet<MSGuidDecl> MSGuidDecls;
364
365 /// Mapping from APValues to the corresponding UnnamedGlobalConstantDecl.
366 mutable llvm::FoldingSet<UnnamedGlobalConstantDecl>
367 UnnamedGlobalConstantDecls;
368
369 /// Mapping from APValues to the corresponding TemplateParamObjects.
370 mutable llvm::FoldingSet<TemplateParamObjectDecl> TemplateParamObjectDecls;
371
372 /// A cache mapping a string value to a StringLiteral object with the same
373 /// value.
374 ///
375 /// This is lazily created. This is intentionally not serialized.
376 mutable llvm::StringMap<StringLiteral *> StringLiteralCache;
377
378 mutable llvm::DenseSet<const FunctionDecl *> DestroyingOperatorDeletes;
379 mutable llvm::DenseSet<const FunctionDecl *> TypeAwareOperatorNewAndDeletes;
380
381 /// Global and array operators delete are only required for MSVC deleting
382 /// destructors support. Store them here to avoid keeping 4 pointers that are
383 /// not always used in each redeclaration of the destructor.
384 mutable llvm::DenseMap<const CXXDestructorDecl *, FunctionDecl *>
385 OperatorDeletesForVirtualDtor;
386 mutable llvm::DenseMap<const CXXDestructorDecl *, FunctionDecl *>
387 GlobalOperatorDeletesForVirtualDtor;
388 mutable llvm::DenseMap<const CXXDestructorDecl *, FunctionDecl *>
389 ArrayOperatorDeletesForVirtualDtor;
390 mutable llvm::DenseMap<const CXXDestructorDecl *, FunctionDecl *>
391 GlobalArrayOperatorDeletesForVirtualDtor;
392
393 /// To remember for which types we met new[] call, these potentially require a
394 /// vector deleting dtor.
395 llvm::DenseSet<const CXXRecordDecl *> MaybeRequireVectorDeletingDtor;
396
397 /// The next string literal "version" to allocate during constant evaluation.
398 /// This is used to distinguish between repeated evaluations of the same
399 /// string literal.
400 ///
401 /// We don't need to serialize this because constants get re-evaluated in the
402 /// current file before they are compared locally.
403 unsigned NextStringLiteralVersion = 0;
404
405 /// MD5 hash of CUID. It is calculated when first used and cached by this
406 /// data member.
407 mutable std::string CUIDHash;
408
409 /// Representation of a "canonical" template template parameter that
410 /// is used in canonical template names.
411 class CanonicalTemplateTemplateParm : public llvm::FoldingSetNode {
412 TemplateTemplateParmDecl *Parm;
413
414 public:
415 CanonicalTemplateTemplateParm(TemplateTemplateParmDecl *Parm)
416 : Parm(Parm) {}
417
418 TemplateTemplateParmDecl *getParam() const { return Parm; }
419
420 void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &C) {
421 Profile(ID, C, Parm);
422 }
423
424 static void Profile(llvm::FoldingSetNodeID &ID,
425 const ASTContext &C,
426 TemplateTemplateParmDecl *Parm);
427 };
428 mutable llvm::ContextualFoldingSet<CanonicalTemplateTemplateParm,
429 const ASTContext&>
430 CanonTemplateTemplateParms;
431
432 /// The typedef for the __int128_t type.
433 mutable TypedefDecl *Int128Decl = nullptr;
434
435 /// The typedef for the __uint128_t type.
436 mutable TypedefDecl *UInt128Decl = nullptr;
437
438 /// The typedef for the target specific predefined
439 /// __builtin_va_list type.
440 mutable TypedefDecl *BuiltinVaListDecl = nullptr;
441
442 /// The typedef for the predefined \c __builtin_ms_va_list type.
443 mutable TypedefDecl *BuiltinMSVaListDecl = nullptr;
444
445 /// The typedef for the predefined \c id type.
446 mutable TypedefDecl *ObjCIdDecl = nullptr;
447
448 /// The typedef for the predefined \c SEL type.
449 mutable TypedefDecl *ObjCSelDecl = nullptr;
450
451 /// The typedef for the predefined \c Class type.
452 mutable TypedefDecl *ObjCClassDecl = nullptr;
453
454 /// The typedef for the predefined \c Protocol class in Objective-C.
455 mutable ObjCInterfaceDecl *ObjCProtocolClassDecl = nullptr;
456
457 /// The typedef for the predefined 'BOOL' type.
458 mutable TypedefDecl *BOOLDecl = nullptr;
459
460 // Typedefs which may be provided defining the structure of Objective-C
461 // pseudo-builtins
462 QualType ObjCIdRedefinitionType;
463 QualType ObjCClassRedefinitionType;
464 QualType ObjCSelRedefinitionType;
465
466 /// The identifier 'bool'.
467 mutable IdentifierInfo *BoolName = nullptr;
468
469 /// The identifier 'NSObject'.
470 mutable IdentifierInfo *NSObjectName = nullptr;
471
472 /// The identifier 'NSCopying'.
473 IdentifierInfo *NSCopyingName = nullptr;
474
475#define BuiltinTemplate(BTName) mutable IdentifierInfo *Name##BTName = nullptr;
476#include "clang/Basic/BuiltinTemplates.inc"
477
478 QualType ObjCConstantStringType;
479 mutable RecordDecl *CFConstantStringTagDecl = nullptr;
480 mutable TypedefDecl *CFConstantStringTypeDecl = nullptr;
481
482 mutable QualType ObjCSuperType;
483
484 QualType ObjCNSStringType;
485
486 /// The typedef declaration for the Objective-C "instancetype" type.
487 TypedefDecl *ObjCInstanceTypeDecl = nullptr;
488
489 /// The type for the C FILE type.
490 TypeDecl *FILEDecl = nullptr;
491
492 /// The type for the C jmp_buf type.
493 TypeDecl *jmp_bufDecl = nullptr;
494
495 /// The type for the C sigjmp_buf type.
496 TypeDecl *sigjmp_bufDecl = nullptr;
497
498 /// The type for the C ucontext_t type.
499 TypeDecl *ucontext_tDecl = nullptr;
500
501 /// Type for the Block descriptor for Blocks CodeGen.
502 ///
503 /// Since this is only used for generation of debug info, it is not
504 /// serialized.
505 mutable RecordDecl *BlockDescriptorType = nullptr;
506
507 /// Type for the Block descriptor for Blocks CodeGen.
508 ///
509 /// Since this is only used for generation of debug info, it is not
510 /// serialized.
511 mutable RecordDecl *BlockDescriptorExtendedType = nullptr;
512
513 /// Declaration for the CUDA cudaConfigureCall function.
514 FunctionDecl *cudaConfigureCallDecl = nullptr;
515 /// Declaration for the CUDA cudaGetParameterBuffer function.
516 FunctionDecl *cudaGetParameterBufferDecl = nullptr;
517 /// Declaration for the CUDA cudaLaunchDevice function.
518 FunctionDecl *cudaLaunchDeviceDecl = nullptr;
519
520 /// Keeps track of all declaration attributes.
521 ///
522 /// Since so few decls have attrs, we keep them in a hash map instead of
523 /// wasting space in the Decl class.
524 llvm::DenseMap<const Decl*, AttrVec*> DeclAttrs;
525
526 /// A mapping from non-redeclarable declarations in modules that were
527 /// merged with other declarations to the canonical declaration that they were
528 /// merged into.
529 llvm::DenseMap<Decl*, Decl*> MergedDecls;
530
531 /// A mapping from a defining declaration to a list of modules (other
532 /// than the owning module of the declaration) that contain merged
533 /// definitions of that entity.
534 llvm::DenseMap<NamedDecl*, llvm::TinyPtrVector<Module*>> MergedDefModules;
535
536 /// Initializers for a module, in order. Each Decl will be either
537 /// something that has a semantic effect on startup (such as a variable with
538 /// a non-constant initializer), or an ImportDecl (which recursively triggers
539 /// initialization of another module).
540 struct PerModuleInitializers {
541 llvm::SmallVector<Decl*, 4> Initializers;
542 llvm::SmallVector<GlobalDeclID, 4> LazyInitializers;
543
544 void resolve(ASTContext &Ctx);
545 };
546 llvm::DenseMap<Module*, PerModuleInitializers*> ModuleInitializers;
547
548 /// This is the top-level (C++20) Named module we are building.
549 Module *CurrentCXXNamedModule = nullptr;
550
551 /// Help structures to decide whether two `const Module *` belongs
552 /// to the same conceptual module to avoid the expensive to string comparison
553 /// if possible.
554 ///
555 /// Not serialized intentionally.
556 mutable llvm::StringMap<const Module *> PrimaryModuleNameMap;
557 mutable llvm::DenseMap<const Module *, const Module *> SameModuleLookupSet;
558
559 static constexpr unsigned ConstantArrayTypesLog2InitSize = 8;
560 static constexpr unsigned GeneralTypesLog2InitSize = 9;
561 static constexpr unsigned FunctionProtoTypesLog2InitSize = 12;
562
563 /// A mapping from an ObjC class to its subclasses.
564 llvm::DenseMap<const ObjCInterfaceDecl *,
565 SmallVector<const ObjCInterfaceDecl *, 4>>
566 ObjCSubClasses;
567
568 // A mapping from Scalable Vector Type keys to their corresponding QualType.
569 mutable llvm::DenseMap<llvm::ScalableVecTyKey, QualType> ScalableVecTyMap;
570
571 ASTContext &this_() { return *this; }
572
573public:
574 /// A type synonym for the TemplateOrInstantiation mapping.
576 llvm::PointerUnion<VarTemplateDecl *, MemberSpecializationInfo *>;
577
578private:
579 friend class ASTDeclReader;
580 friend class ASTReader;
581 friend class ASTWriter;
582 template <class> friend class serialization::AbstractTypeReader;
583 friend class CXXRecordDecl;
584 friend class IncrementalParser;
585
586 /// A mapping to contain the template or declaration that
587 /// a variable declaration describes or was instantiated from,
588 /// respectively.
589 ///
590 /// For non-templates, this value will be NULL. For variable
591 /// declarations that describe a variable template, this will be a
592 /// pointer to a VarTemplateDecl. For static data members
593 /// of class template specializations, this will be the
594 /// MemberSpecializationInfo referring to the member variable that was
595 /// instantiated or specialized. Thus, the mapping will keep track of
596 /// the static data member templates from which static data members of
597 /// class template specializations were instantiated.
598 ///
599 /// Given the following example:
600 ///
601 /// \code
602 /// template<typename T>
603 /// struct X {
604 /// static T value;
605 /// };
606 ///
607 /// template<typename T>
608 /// T X<T>::value = T(17);
609 ///
610 /// int *x = &X<int>::value;
611 /// \endcode
612 ///
613 /// This mapping will contain an entry that maps from the VarDecl for
614 /// X<int>::value to the corresponding VarDecl for X<T>::value (within the
615 /// class template X) and will be marked TSK_ImplicitInstantiation.
616 llvm::DenseMap<const VarDecl *, TemplateOrSpecializationInfo>
617 TemplateOrInstantiation;
618
619 /// Keeps track of the declaration from which a using declaration was
620 /// created during instantiation.
621 ///
622 /// The source and target declarations are always a UsingDecl, an
623 /// UnresolvedUsingValueDecl, or an UnresolvedUsingTypenameDecl.
624 ///
625 /// For example:
626 /// \code
627 /// template<typename T>
628 /// struct A {
629 /// void f();
630 /// };
631 ///
632 /// template<typename T>
633 /// struct B : A<T> {
634 /// using A<T>::f;
635 /// };
636 ///
637 /// template struct B<int>;
638 /// \endcode
639 ///
640 /// This mapping will contain an entry that maps from the UsingDecl in
641 /// B<int> to the UnresolvedUsingDecl in B<T>.
642 llvm::DenseMap<NamedDecl *, NamedDecl *> InstantiatedFromUsingDecl;
643
644 /// Like InstantiatedFromUsingDecl, but for using-enum-declarations. Maps
645 /// from the instantiated using-enum to the templated decl from whence it
646 /// came.
647 /// Note that using-enum-declarations cannot be dependent and
648 /// thus will never be instantiated from an "unresolved"
649 /// version thereof (as with using-declarations), so each mapping is from
650 /// a (resolved) UsingEnumDecl to a (resolved) UsingEnumDecl.
651 llvm::DenseMap<UsingEnumDecl *, UsingEnumDecl *>
652 InstantiatedFromUsingEnumDecl;
653
654 /// Similarly maps instantiated UsingShadowDecls to their origin.
655 llvm::DenseMap<UsingShadowDecl*, UsingShadowDecl*>
656 InstantiatedFromUsingShadowDecl;
657
658 llvm::DenseMap<FieldDecl *, FieldDecl *> InstantiatedFromUnnamedFieldDecl;
659
660 /// Maps a canonical specialization Decl to all ExplicitInstantiationDecls
661 /// that reference it (declarations and definitions).
662 llvm::DenseMap<const NamedDecl *,
663 llvm::TinyPtrVector<ExplicitInstantiationDecl *>>
664 ExplicitInstantiations;
665
666 /// Mapping that stores the methods overridden by a given C++
667 /// member function.
668 ///
669 /// Since most C++ member functions aren't virtual and therefore
670 /// don't override anything, we store the overridden functions in
671 /// this map on the side rather than within the CXXMethodDecl structure.
672 using CXXMethodVector = llvm::TinyPtrVector<const CXXMethodDecl *>;
673 llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector> OverriddenMethods;
674
675 /// Mapping from each declaration context to its corresponding
676 /// mangling numbering context (used for constructs like lambdas which
677 /// need to be consistently numbered for the mangler).
678 llvm::DenseMap<const DeclContext *, std::unique_ptr<MangleNumberingContext>>
679 MangleNumberingContexts;
680 llvm::DenseMap<const Decl *, std::unique_ptr<MangleNumberingContext>>
681 ExtraMangleNumberingContexts;
682
683 /// Side-table of mangling numbers for declarations which rarely
684 /// need them (like static local vars).
685 llvm::MapVector<const NamedDecl *, unsigned> MangleNumbers;
686 llvm::MapVector<const VarDecl *, unsigned> StaticLocalNumbers;
687 /// Mapping the associated device lambda mangling number if present.
688 mutable llvm::DenseMap<const CXXRecordDecl *, unsigned>
689 DeviceLambdaManglingNumbers;
690
691 /// Mapping that stores parameterIndex values for ParmVarDecls when
692 /// that value exceeds the bitfield size of ParmVarDeclBits.ParameterIndex.
693 using ParameterIndexTable = llvm::DenseMap<const VarDecl *, unsigned>;
694 ParameterIndexTable ParamIndices;
695
696public:
700 std::optional<CXXRecordDeclRelocationInfo>
704
705 /// Examines a given type, and returns whether the type itself
706 /// is address discriminated, or any transitively embedded types
707 /// contain data that is address discriminated. This includes
708 /// implicitly authenticated values like vtable pointers, as well as
709 /// explicitly qualified fields.
711 if (!isPointerAuthenticationAvailable())
712 return false;
713 return findPointerAuthContent(T) != PointerAuthContent::None;
714 }
715
716 /// Examines a given type, and returns whether the type itself
717 /// or any data it transitively contains has a pointer authentication
718 /// schema that is not safely relocatable. e.g. any data or fields
719 /// with address discrimination other than any otherwise similar
720 /// vtable pointers.
722 if (!isPointerAuthenticationAvailable())
723 return false;
724 return findPointerAuthContent(T) != PointerAuthContent::None;
725 }
726
727private:
728 llvm::DenseMap<const CXXRecordDecl *, CXXRecordDeclRelocationInfo>
729 RelocatableClasses;
730
731 // FIXME: store in RecordDeclBitfields in future?
732 enum class PointerAuthContent : uint8_t {
733 None,
734 AddressDiscriminatedVTable,
735 AddressDiscriminatedData
736 };
737
738 // A simple helper function to short circuit pointer auth checks.
739 bool isPointerAuthenticationAvailable() const {
740 return LangOpts.PointerAuthCalls || LangOpts.PointerAuthIntrinsics;
741 }
742 PointerAuthContent findPointerAuthContent(QualType T) const;
743 mutable llvm::DenseMap<const RecordDecl *, PointerAuthContent>
744 RecordContainsAddressDiscriminatedPointerAuth;
745
746 ImportDecl *FirstLocalImport = nullptr;
747 ImportDecl *LastLocalImport = nullptr;
748
749 TranslationUnitDecl *TUDecl = nullptr;
750 mutable ExternCContextDecl *ExternCContext = nullptr;
751
752#define BuiltinTemplate(BTName) \
753 mutable BuiltinTemplateDecl *Decl##BTName = nullptr;
754#include "clang/Basic/BuiltinTemplates.inc"
755
756 /// The associated SourceManager object.
757 SourceManager &SourceMgr;
758
759 /// The language options used to create the AST associated with
760 /// this ASTContext object.
761 LangOptions &LangOpts;
762
763 /// NoSanitizeList object that is used by sanitizers to decide which
764 /// entities should not be instrumented.
765 std::unique_ptr<NoSanitizeList> NoSanitizeL;
766
767 /// Function filtering mechanism to determine whether a given function
768 /// should be imbued with the XRay "always" or "never" attributes.
769 std::unique_ptr<XRayFunctionFilter> XRayFilter;
770
771 /// ProfileList object that is used by the profile instrumentation
772 /// to decide which entities should be instrumented.
773 std::unique_ptr<ProfileList> ProfList;
774
775 /// The allocator used to create AST objects.
776 ///
777 /// AST objects are never destructed; rather, all memory associated with the
778 /// AST objects will be released when the ASTContext itself is destroyed.
779 mutable llvm::BumpPtrAllocator BumpAlloc;
780
781 /// Allocator for partial diagnostics.
783
784 /// The current C++ ABI.
785 std::unique_ptr<CXXABI> ABI;
786 CXXABI *createCXXABI(const TargetInfo &T);
787
788 /// Address space map mangling must be used with language specific
789 /// address spaces (e.g. OpenCL/CUDA)
790 bool AddrSpaceMapMangling;
791
792 /// For performance, track whether any function effects are in use.
793 mutable bool AnyFunctionEffects = false;
794
795 const TargetInfo *Target = nullptr;
796 const TargetInfo *AuxTarget = nullptr;
797 clang::PrintingPolicy PrintingPolicy;
798 mutable std::unique_ptr<interp::Context> InterpContext;
799 std::unique_ptr<ParentMapContext> ParentMapCtx;
800
801 /// Keeps track of the deallocated DeclListNodes for future reuse.
802 DeclListNode *ListNodeFreeList = nullptr;
803
804public:
812
813 /// Returns the clang bytecode interpreter context.
815
817 /// Do not allow wrong-sided variables in constant expressions.
818 bool NoWrongSidedVars = false;
829
830 /// Returns the dynamic AST node parent map context.
832
833 // A traversal scope limits the parts of the AST visible to certain analyses.
834 // RecursiveASTVisitor only visits specified children of TranslationUnitDecl.
835 // getParents() will only observe reachable parent edges.
836 //
837 // The scope is defined by a set of "top-level" declarations which will be
838 // visible under the TranslationUnitDecl.
839 // Initially, it is the entire TU, represented by {getTranslationUnitDecl()}.
840 //
841 // After setTraversalScope({foo, bar}), the exposed AST looks like:
842 // TranslationUnitDecl
843 // - foo
844 // - ...
845 // - bar
846 // - ...
847 // All other siblings of foo and bar are pruned from the tree.
848 // (However they are still accessible via TranslationUnitDecl->decls())
849 //
850 // Changing the scope clears the parent cache, which is expensive to rebuild.
851 ArrayRef<Decl *> getTraversalScope() const { return TraversalScope; }
852 void setTraversalScope(const std::vector<Decl *> &);
853
854 /// Forwards to get node parents from the ParentMapContext. New callers should
855 /// use ParentMapContext::getParents() directly.
856 template <typename NodeT> DynTypedNodeList getParents(const NodeT &Node);
857
859 return PrintingPolicy;
860 }
861
863 PrintingPolicy = Policy;
864 }
865
866 SourceManager& getSourceManager() { return SourceMgr; }
867 const SourceManager& getSourceManager() const { return SourceMgr; }
868
869 // Cleans up some of the data structures. This allows us to do cleanup
870 // normally done in the destructor earlier. Renders much of the ASTContext
871 // unusable, mostly the actual AST nodes, so should be called when we no
872 // longer need access to the AST.
873 void cleanup();
874
875 llvm::BumpPtrAllocator &getAllocator() const {
876 return BumpAlloc;
877 }
878
879 void *Allocate(size_t Size, unsigned Align = 8) const {
880 return BumpAlloc.Allocate(Size, Align);
881 }
882 template <typename T> T *Allocate(size_t Num = 1) const {
883 return static_cast<T *>(Allocate(Num * sizeof(T), alignof(T)));
884 }
885 void Deallocate(void *Ptr) const {}
886
887 llvm::StringRef backupStr(llvm::StringRef S) const {
888 char *Buf = new (*this) char[S.size()];
889 llvm::copy(S, Buf);
890 return llvm::StringRef(Buf, S.size());
891 }
892
893 /// Allocates a \c DeclListNode or returns one from the \c ListNodeFreeList
894 /// pool.
896 if (DeclListNode *Alloc = ListNodeFreeList) {
897 ListNodeFreeList = dyn_cast_if_present<DeclListNode *>(Alloc->Rest);
898 Alloc->D = ND;
899 Alloc->Rest = nullptr;
900 return Alloc;
901 }
902 return new (*this) DeclListNode(ND);
903 }
904 /// Deallocates a \c DeclListNode by returning it to the \c ListNodeFreeList
905 /// pool.
907 N->Rest = ListNodeFreeList;
908 ListNodeFreeList = N;
909 }
910
911 /// Return the total amount of physical memory allocated for representing
912 /// AST nodes and type information.
913 size_t getASTAllocatedMemory() const {
914 return BumpAlloc.getTotalMemory();
915 }
916
917 /// Return the total memory used for various side tables.
918 size_t getSideTableAllocatedMemory() const;
919
921 return DiagAllocator;
922 }
923
924 const TargetInfo &getTargetInfo() const { return *Target; }
925 const TargetInfo *getAuxTargetInfo() const { return AuxTarget; }
926
927 const QualType GetHigherPrecisionFPType(QualType ElementType) const {
928 const auto *CurrentBT = cast<BuiltinType>(ElementType);
929 switch (CurrentBT->getKind()) {
930 case BuiltinType::Kind::Half:
931 case BuiltinType::Kind::Float16:
932 return FloatTy;
933 case BuiltinType::Kind::Float:
934 case BuiltinType::Kind::BFloat16:
935 return DoubleTy;
936 case BuiltinType::Kind::Double:
937 return LongDoubleTy;
938 default:
939 return ElementType;
940 }
941 return ElementType;
942 }
943
944 /// getIntTypeForBitwidth -
945 /// sets integer QualTy according to specified details:
946 /// bitwidth, signed/unsigned.
947 /// Returns empty type if there is no appropriate target types.
948 QualType getIntTypeForBitwidth(unsigned DestWidth,
949 unsigned Signed) const;
950
951 /// getRealTypeForBitwidth -
952 /// sets floating point QualTy according to specified bitwidth.
953 /// Returns empty type if there is no appropriate target types.
954 QualType getRealTypeForBitwidth(unsigned DestWidth,
955 FloatModeKind ExplicitType) const;
956
957 bool AtomicUsesUnsupportedLibcall(const AtomicExpr *E) const;
958
959 const LangOptions& getLangOpts() const { return LangOpts; }
960
961 // If this condition is false, typo correction must be performed eagerly
962 // rather than delayed in many places, as it makes use of dependent types.
963 // the condition is false for clang's C-only codepath, as it doesn't support
964 // dependent types yet.
965 bool isDependenceAllowed() const {
966 return LangOpts.CPlusPlus || LangOpts.RecoveryAST;
967 }
968
969 const NoSanitizeList &getNoSanitizeList() const { return *NoSanitizeL; }
970
972 const QualType &Ty) const;
973
975
977 return *XRayFilter;
978 }
979
980 const ProfileList &getProfileList() const { return *ProfList; }
981
983
985 return FullSourceLoc(Loc,SourceMgr);
986 }
987
988 /// Return the C++ ABI kind that should be used. The C++ ABI can be overriden
989 /// at compile time with `-fc++-abi=`. If this is not provided, we instead use
990 /// the default ABI set by the target.
992
993 /// All comments in this translation unit.
995
996 /// True if comments are already loaded from ExternalASTSource.
997 mutable bool CommentsLoaded = false;
998
999 /// Mapping from declaration to directly attached comment.
1000 ///
1001 /// Raw comments are owned by Comments list. This mapping is populated
1002 /// lazily.
1003 mutable llvm::DenseMap<const Decl *, const RawComment *> DeclRawComments;
1004
1005 /// Mapping from canonical declaration to the first redeclaration in chain
1006 /// that has a comment attached.
1007 ///
1008 /// Raw comments are owned by Comments list. This mapping is populated
1009 /// lazily.
1010 mutable llvm::DenseMap<const Decl *, const Decl *> RedeclChainComments;
1011
1012 /// Keeps track of redeclaration chains that don't have any comment attached.
1013 /// Mapping from canonical declaration to redeclaration chain that has no
1014 /// comments attached to any redeclaration. Specifically it's mapping to
1015 /// the last redeclaration we've checked.
1016 ///
1017 /// Shall not contain declarations that have comments attached to any
1018 /// redeclaration in their chain.
1019 mutable llvm::DenseMap<const Decl *, const Decl *> CommentlessRedeclChains;
1020
1021 /// Mapping from declarations to parsed comments attached to any
1022 /// redeclaration.
1023 mutable llvm::DenseMap<const Decl *, comments::FullComment *> ParsedComments;
1024
1025 /// Attaches \p Comment to \p OriginalD and to its redeclaration chain
1026 /// and removes the redeclaration chain from the set of commentless chains.
1027 ///
1028 /// Don't do anything if a comment has already been attached to \p OriginalD
1029 /// or its redeclaration chain.
1030 void cacheRawCommentForDecl(const Decl &OriginalD,
1031 const RawComment &Comment) const;
1032
1033 /// \returns searches \p CommentsInFile for doc comment for \p D.
1034 ///
1035 /// \p RepresentativeLocForDecl is used as a location for searching doc
1036 /// comments. \p CommentsInFile is a mapping offset -> comment of files in the
1037 /// same file where \p RepresentativeLocForDecl is.
1039 const Decl *D, const SourceLocation RepresentativeLocForDecl,
1040 const std::map<unsigned, RawComment *> &CommentsInFile) const;
1041
1042 /// Return the documentation comment attached to a given declaration,
1043 /// without looking into cache.
1045
1046public:
1047 void addComment(const RawComment &RC);
1048
1049 /// Return the documentation comment attached to a given declaration.
1050 /// Returns nullptr if no comment is attached.
1051 ///
1052 /// \param OriginalDecl if not nullptr, is set to declaration AST node that
1053 /// had the comment, if the comment we found comes from a redeclaration.
1054 const RawComment *
1056 const Decl **OriginalDecl = nullptr) const;
1057
1058 /// Searches existing comments for doc comments that should be attached to \p
1059 /// Decls. If any doc comment is found, it is parsed.
1060 ///
1061 /// Requirement: All \p Decls are in the same file.
1062 ///
1063 /// If the last comment in the file is already attached we assume
1064 /// there are not comments left to be attached to \p Decls.
1066 const Preprocessor *PP);
1067
1068 /// Return parsed documentation comment attached to a given declaration.
1069 /// Returns nullptr if no comment is attached.
1070 ///
1071 /// \param PP the Preprocessor used with this TU. Could be nullptr if
1072 /// preprocessor is not available.
1074 const Preprocessor *PP) const;
1075
1076 /// Attempts to merge two types that may be OverflowBehaviorTypes.
1077 ///
1078 /// \returns A QualType if the types were handled, std::nullopt otherwise.
1079 /// A null QualType indicates an incompatible merge.
1080 std::optional<QualType>
1081 tryMergeOverflowBehaviorTypes(QualType LHS, QualType RHS, bool OfBlockPointer,
1082 bool Unqualified, bool BlockReturnType,
1083 bool IsConditionalOperator);
1084
1085 /// Return parsed documentation comment attached to a given declaration.
1086 /// Returns nullptr if no comment is attached. Does not look at any
1087 /// redeclarations of the declaration.
1089
1091 const Decl *D) const;
1092
1093private:
1094 mutable comments::CommandTraits CommentCommandTraits;
1095
1096 /// Iterator that visits import declarations.
1097 class import_iterator {
1098 ImportDecl *Import = nullptr;
1099
1100 public:
1101 using value_type = ImportDecl *;
1102 using reference = ImportDecl *;
1103 using pointer = ImportDecl *;
1104 using difference_type = int;
1105 using iterator_category = std::forward_iterator_tag;
1106
1107 import_iterator() = default;
1108 explicit import_iterator(ImportDecl *Import) : Import(Import) {}
1109
1110 reference operator*() const { return Import; }
1111 pointer operator->() const { return Import; }
1112
1113 import_iterator &operator++() {
1114 Import = ASTContext::getNextLocalImport(Import);
1115 return *this;
1116 }
1117
1118 import_iterator operator++(int) {
1119 import_iterator Other(*this);
1120 ++(*this);
1121 return Other;
1122 }
1123
1124 friend bool operator==(import_iterator X, import_iterator Y) {
1125 return X.Import == Y.Import;
1126 }
1127
1128 friend bool operator!=(import_iterator X, import_iterator Y) {
1129 return X.Import != Y.Import;
1130 }
1131 };
1132
1133public:
1135 return CommentCommandTraits;
1136 }
1137
1138 /// Retrieve the attributes for the given declaration.
1139 AttrVec& getDeclAttrs(const Decl *D);
1140
1141 /// Erase the attributes corresponding to the given declaration.
1142 void eraseDeclAttrs(const Decl *D);
1143
1144 /// Get all ExplicitInstantiationDecls for a given specialization.
1146 getExplicitInstantiationDecls(const NamedDecl *Spec) const;
1147
1148 /// Add an ExplicitInstantiationDecl for a given specialization.
1149 void addExplicitInstantiationDecl(const NamedDecl *Spec,
1151
1152 /// If this variable is an instantiated static data member of a
1153 /// class template specialization, returns the templated static data member
1154 /// from which it was instantiated.
1155 // FIXME: Remove ?
1157 const VarDecl *Var);
1158
1159 /// Note that the static data member \p Inst is an instantiation of
1160 /// the static data member template \p Tmpl of a class template.
1163 SourceLocation PointOfInstantiation = SourceLocation());
1164
1167
1170
1171 /// If the given using decl \p Inst is an instantiation of
1172 /// another (possibly unresolved) using decl, return it.
1174
1175 /// Remember that the using decl \p Inst is an instantiation
1176 /// of the using decl \p Pattern of a class template.
1177 void setInstantiatedFromUsingDecl(NamedDecl *Inst, NamedDecl *Pattern);
1178
1179 /// If the given using-enum decl \p Inst is an instantiation of
1180 /// another using-enum decl, return it.
1182
1183 /// Remember that the using enum decl \p Inst is an instantiation
1184 /// of the using enum decl \p Pattern of a class template.
1186 UsingEnumDecl *Pattern);
1187
1190 UsingShadowDecl *Pattern);
1191
1193
1195
1196 // Access to the set of methods overridden by the given C++ method.
1197 using overridden_cxx_method_iterator = CXXMethodVector::const_iterator;
1200
1203
1204 unsigned overridden_methods_size(const CXXMethodDecl *Method) const;
1205
1207 llvm::iterator_range<overridden_cxx_method_iterator>;
1208
1210
1211 /// Note that the given C++ \p Method overrides the given \p
1212 /// Overridden method.
1214 const CXXMethodDecl *Overridden);
1215
1216 /// Return C++ or ObjC overridden methods for the given \p Method.
1217 ///
1218 /// An ObjC method is considered to override any method in the class's
1219 /// base classes, its protocols, or its categories' protocols, that has
1220 /// the same selector and is of the same kind (class or instance).
1221 /// A method in an implementation is not considered as overriding the same
1222 /// method in the interface or its categories.
1224 const NamedDecl *Method,
1225 SmallVectorImpl<const NamedDecl *> &Overridden) const;
1226
1227 /// Notify the AST context that a new import declaration has been
1228 /// parsed or implicitly created within this translation unit.
1229 void addedLocalImportDecl(ImportDecl *Import);
1230
1232 return Import->getNextLocalImport();
1233 }
1234
1235 using import_range = llvm::iterator_range<import_iterator>;
1236
1238 return import_range(import_iterator(FirstLocalImport), import_iterator());
1239 }
1240
1242 Decl *Result = MergedDecls.lookup(D);
1243 return Result ? Result : D;
1244 }
1245 void setPrimaryMergedDecl(Decl *D, Decl *Primary) {
1246 MergedDecls[D] = Primary;
1247 }
1248
1249 /// Note that the definition \p ND has been merged into module \p M,
1250 /// and should be visible whenever \p M is visible.
1252 bool NotifyListeners = true);
1253
1254 /// Clean up the merged definition list. Call this if you might have
1255 /// added duplicates into the list.
1257
1258 /// Get the additional modules in which the definition \p Def has
1259 /// been merged.
1261
1262 /// Add a declaration to the list of declarations that are initialized
1263 /// for a module. This will typically be a global variable (with internal
1264 /// linkage) that runs module initializers, such as the iostream initializer,
1265 /// or an ImportDecl nominating another module that has initializers.
1267
1269
1270 /// Get the initializations to perform when importing a module, if any.
1272
1273 /// Set the (C++20) module we are building.
1275
1276 /// Get module under construction, nullptr if this is not a C++20 module.
1277 Module *getCurrentNamedModule() const { return CurrentCXXNamedModule; }
1278
1279 /// If the two module \p M1 and \p M2 are in the same module.
1280 ///
1281 /// FIXME: The signature may be confusing since `clang::Module` means to
1282 /// a module fragment or a module unit but not a C++20 module.
1283 bool isInSameModule(const Module *M1, const Module *M2) const;
1284
1286 assert(TUDecl && "TUDecl might have been reset by 'cleanup' likely because "
1287 "'CodeGenOpts.ClearASTBeforeBackend' was set.");
1288 assert(TUDecl->getMostRecentDecl() == TUDecl &&
1289 "The active TU is not current one!");
1290 return TUDecl->getMostRecentDecl();
1291 }
1293 assert(!TUDecl || TUKind == TU_Incremental);
1295 if (TraversalScope.empty() || TraversalScope.back() == TUDecl)
1296 TraversalScope = {NewTUDecl};
1297 if (TUDecl)
1298 NewTUDecl->setPreviousDecl(TUDecl);
1299 TUDecl = NewTUDecl;
1300 }
1301
1303
1304#define BuiltinTemplate(BTName) BuiltinTemplateDecl *get##BTName##Decl() const;
1305#include "clang/Basic/BuiltinTemplates.inc"
1306
1307 // Builtin Types.
1311 CanQualType WCharTy; // [C++ 3.9.1p5].
1312 CanQualType WideCharTy; // Same as WCharTy in C++, integer type in C99.
1313 CanQualType WIntTy; // [C99 7.24.1], integer type unchanged by default promotions.
1314 CanQualType Char8Ty; // [C++20 proposal]
1315 CanQualType Char16Ty; // [C++0x 3.9.1p5], integer type in C99.
1316 CanQualType Char32Ty; // [C++0x 3.9.1p5], integer type in C99.
1322 LongAccumTy; // ISO/IEC JTC1 SC22 WG14 N1169 Extension
1332 CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
1334 CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
1342#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1343 CanQualType SingletonId;
1344#include "clang/Basic/OpenCLImageTypes.def"
1350#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1351 CanQualType Id##Ty;
1352#include "clang/Basic/OpenCLExtensionTypes.def"
1353#define SVE_TYPE(Name, Id, SingletonId) \
1354 CanQualType SingletonId;
1355#include "clang/Basic/AArch64ACLETypes.def"
1356#define PPC_VECTOR_TYPE(Name, Id, Size) \
1357 CanQualType Id##Ty;
1358#include "clang/Basic/PPCTypes.def"
1359#define RVV_TYPE(Name, Id, SingletonId) \
1360 CanQualType SingletonId;
1361#include "clang/Basic/RISCVVTypes.def"
1362#define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
1363#include "clang/Basic/WebAssemblyReferenceTypes.def"
1364#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
1365 CanQualType SingletonId;
1366#include "clang/Basic/AMDGPUTypes.def"
1367#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
1368#include "clang/Basic/HLSLIntangibleTypes.def"
1369
1370 // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand.
1371 mutable QualType AutoDeductTy; // Deduction against 'auto'.
1372 mutable QualType AutoRRefDeductTy; // Deduction against 'auto &&'.
1373
1374 // Decl used to help define __builtin_va_list for some targets.
1375 // The decl is built when constructing 'BuiltinVaListDecl'.
1376 mutable Decl *VaListTagDecl = nullptr;
1377
1378 // Implicitly-declared type 'struct _GUID'.
1379 mutable TagDecl *MSGuidTagDecl = nullptr;
1380
1381 // Implicitly-declared type 'struct type_info'.
1382 mutable TagDecl *MSTypeInfoTagDecl = nullptr;
1383
1384 /// Keep track of CUDA/HIP device-side variables ODR-used by host code.
1385 /// This does not include extern shared variables used by device host
1386 /// functions as addresses of shared variables are per warp, therefore
1387 /// cannot be accessed by host code.
1388 llvm::SetVector<const VarDecl *> CUDADeviceVarODRUsedByHost;
1389
1390 /// Keep track of CUDA/HIP external kernels or device variables ODR-used by
1391 /// host code. SetVector is used to maintain the order.
1392 llvm::SetVector<const ValueDecl *> CUDAExternalDeviceDeclODRUsedByHost;
1393
1394 /// Keep track of CUDA/HIP implicit host device functions used on device side
1395 /// in device compilation.
1396 llvm::DenseSet<const FunctionDecl *> CUDAImplicitHostDeviceFunUsedByDevice;
1397
1398 /// Map of SYCL kernels indexed by the unique type used to name the kernel.
1399 /// Entries are not serialized but are recreated on deserialization of a
1400 /// sycl_kernel_entry_point attributed function declaration.
1401 llvm::DenseMap<CanQualType, SYCLKernelInfo> SYCLKernels;
1402
1403 /// For capturing lambdas with an explicit object parameter whose type is
1404 /// derived from the lambda type, we need to perform derived-to-base
1405 /// conversion so we can access the captures; the cast paths for that
1406 /// are stored here.
1407 llvm::DenseMap<const CXXMethodDecl *, CXXCastPath> LambdaCastPaths;
1408
1410 SelectorTable &sels, Builtin::Context &builtins,
1412 ASTContext(const ASTContext &) = delete;
1413 ASTContext &operator=(const ASTContext &) = delete;
1414 ~ASTContext();
1415
1416 /// Attach an external AST source to the AST context.
1417 ///
1418 /// The external AST source provides the ability to load parts of
1419 /// the abstract syntax tree as needed from some external storage,
1420 /// e.g., a precompiled header.
1422
1423 /// Retrieve a pointer to the external AST source associated
1424 /// with this AST context, if any.
1426 return ExternalSource.get();
1427 }
1428
1429 /// Retrieve a pointer to the external AST source associated
1430 /// with this AST context, if any. Returns as an IntrusiveRefCntPtr.
1434
1435 /// Attach an AST mutation listener to the AST context.
1436 ///
1437 /// The AST mutation listener provides the ability to track modifications to
1438 /// the abstract syntax tree entities committed after they were initially
1439 /// created.
1441 this->Listener = Listener;
1442 }
1443
1444 /// Retrieve a pointer to the AST mutation listener associated
1445 /// with this AST context, if any.
1447
1448 void PrintStats() const;
1449 const SmallVectorImpl<Type *>& getTypes() const { return Types; }
1450
1452 const IdentifierInfo *II) const;
1453
1454 /// Create a new implicit TU-level CXXRecordDecl or RecordDecl
1455 /// declaration.
1457 StringRef Name,
1458 RecordDecl::TagKind TK = RecordDecl::TagKind::Struct) const;
1459
1460 /// Create a new implicit TU-level typedef declaration.
1461 TypedefDecl *buildImplicitTypedef(QualType T, StringRef Name) const;
1462
1463 /// Retrieve the declaration for the 128-bit signed integer type.
1464 TypedefDecl *getInt128Decl() const;
1465
1466 /// Retrieve the declaration for the 128-bit unsigned integer type.
1467 TypedefDecl *getUInt128Decl() const;
1468
1469 //===--------------------------------------------------------------------===//
1470 // Type Constructors
1471 //===--------------------------------------------------------------------===//
1472
1473private:
1474 /// Return a type with extended qualifiers.
1475 QualType getExtQualType(const Type *Base, Qualifiers Quals) const;
1476
1477 QualType getPipeType(QualType T, bool ReadOnly) const;
1478
1479public:
1480 /// Return the uniqued reference to the type for an address space
1481 /// qualified type with the specified type and address space.
1482 ///
1483 /// The resulting type has a union of the qualifiers from T and the address
1484 /// space. If T already has an address space specifier, it is silently
1485 /// replaced.
1486 QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const;
1487
1488 /// Remove any existing address space on the type and returns the type
1489 /// with qualifiers intact (or that's the idea anyway)
1490 ///
1491 /// The return type should be T with all prior qualifiers minus the address
1492 /// space.
1494
1495 /// Return the "other" discriminator used for the pointer auth schema used for
1496 /// vtable pointers in instances of the requested type.
1497 uint16_t
1499
1500 /// Return the "other" type-specific discriminator for the given type.
1502
1503 /// Apply Objective-C protocol qualifiers to the given type.
1504 /// \param allowOnPointerType specifies if we can apply protocol
1505 /// qualifiers on ObjCObjectPointerType. It can be set to true when
1506 /// constructing the canonical type of a Objective-C type parameter.
1508 ArrayRef<ObjCProtocolDecl *> protocols, bool &hasError,
1509 bool allowOnPointerType = false) const;
1510
1511 /// Return the uniqued reference to the type for an Objective-C
1512 /// gc-qualified type.
1513 ///
1514 /// The resulting type has a union of the qualifiers from T and the gc
1515 /// attribute.
1517
1518 /// Remove the existing address space on the type if it is a pointer size
1519 /// address space and return the type with qualifiers intact.
1521
1522 /// Return the uniqued reference to the type for a \c restrict
1523 /// qualified type.
1524 ///
1525 /// The resulting type has a union of the qualifiers from \p T and
1526 /// \c restrict.
1530
1531 /// Return the uniqued reference to the type for a \c volatile
1532 /// qualified type.
1533 ///
1534 /// The resulting type has a union of the qualifiers from \p T and
1535 /// \c volatile.
1539
1540 /// Return the uniqued reference to the type for a \c const
1541 /// qualified type.
1542 ///
1543 /// The resulting type has a union of the qualifiers from \p T and \c const.
1544 ///
1545 /// It can be reasonably expected that this will always be equivalent to
1546 /// calling T.withConst().
1547 QualType getConstType(QualType T) const { return T.withConst(); }
1548
1549 /// Rebuild a type, preserving any existing type sugar. For function types,
1550 /// you probably want to just use \c adjustFunctionResultType and friends
1551 /// instead.
1553 llvm::function_ref<QualType(QualType)> Adjust) const;
1554
1555 /// Change the ExtInfo on a function type.
1557 FunctionType::ExtInfo EInfo);
1558
1559 /// Change the result type of a function type, preserving sugar such as
1560 /// attributed types.
1562 QualType NewResultType);
1563
1564 /// Adjust the given function result type.
1566
1567 /// Change the result type of a function type once it is deduced.
1569
1570 /// Get a function type and produce the equivalent function type with the
1571 /// specified exception specification. Type sugar that can be present on a
1572 /// declaration of a function with an exception specification is permitted
1573 /// and preserved. Other type sugar (for instance, typedefs) is not.
1575 QualType Orig, const FunctionProtoType::ExceptionSpecInfo &ESI) const;
1576
1577 /// Determine whether two function types are the same, ignoring
1578 /// exception specifications in cases where they're part of the type.
1580
1581 /// Change the exception specification on a function once it is
1582 /// delay-parsed, instantiated, or computed.
1585 bool AsWritten = false);
1586
1587 /// Get a function type and produce the equivalent function type where
1588 /// pointer size address spaces in the return type and parameter types are
1589 /// replaced with the default address space.
1591
1592 /// Determine whether two function types are the same, ignoring pointer sizes
1593 /// in the return type and parameter types.
1595
1596 /// Get or construct a function type that is equivalent to the input type
1597 /// except that the parameter ABI annotations are stripped.
1599
1600 /// Determine if two function types are the same, ignoring parameter ABI
1601 /// annotations.
1603
1604 /// Return the uniqued reference to the type for a complex
1605 /// number with the specified element type.
1610
1611 /// Return the uniqued reference to the type for a pointer to
1612 /// the specified type.
1617
1618 QualType
1619 getCountAttributedType(QualType T, Expr *CountExpr, bool CountInBytes,
1620 bool OrNull,
1621 ArrayRef<TypeCoupledDeclRefInfo> DependentDecls) const;
1622
1623 /// Return the uniqued reference to a type adjusted from the original
1624 /// type to a new type.
1630
1631 /// Return the uniqued reference to the decayed version of the given
1632 /// type. Can only be called on array and function types which decay to
1633 /// pointer types.
1638 /// Return the uniqued reference to a specified decay from the original
1639 /// type to the decayed type.
1640 QualType getDecayedType(QualType Orig, QualType Decayed) const;
1641
1642 /// Return the uniqued reference to a specified array parameter type from the
1643 /// original array type.
1645
1646 /// Return the uniqued reference to the atomic type for the specified
1647 /// type.
1649
1650 /// Return the uniqued reference to the type for a block of the
1651 /// specified type.
1653
1654 /// Gets the struct used to keep track of the descriptor for pointer to
1655 /// blocks.
1657
1658 /// Return a read_only pipe type for the specified type.
1660
1661 /// Return a write_only pipe type for the specified type.
1663
1664 /// Return a bit-precise integer type with the specified signedness and bit
1665 /// count.
1666 QualType getBitIntType(bool Unsigned, unsigned NumBits) const;
1667
1668 /// Return a dependent bit-precise integer type with the specified signedness
1669 /// and bit count.
1670 QualType getDependentBitIntType(bool Unsigned, Expr *BitsExpr) const;
1671
1673
1674 /// Gets the struct used to keep track of the extended descriptor for
1675 /// pointer to blocks.
1677
1678 /// Map an AST Type to an OpenCLTypeKind enum value.
1679 OpenCLTypeKind getOpenCLTypeKind(const Type *T) const;
1680
1681 /// Get address space for OpenCL type.
1682 LangAS getOpenCLTypeAddrSpace(const Type *T) const;
1683
1684 /// Returns default address space based on OpenCL version and enabled features
1686 return LangOpts.OpenCLGenericAddressSpace ? LangAS::opencl_generic
1688 }
1689
1691 cudaConfigureCallDecl = FD;
1692 }
1693
1695 return cudaConfigureCallDecl;
1696 }
1697
1699 cudaGetParameterBufferDecl = FD;
1700 }
1701
1703 return cudaGetParameterBufferDecl;
1704 }
1705
1706 void setcudaLaunchDeviceDecl(FunctionDecl *FD) { cudaLaunchDeviceDecl = FD; }
1707
1708 FunctionDecl *getcudaLaunchDeviceDecl() { return cudaLaunchDeviceDecl; }
1709
1710 /// Returns true iff we need copy/dispose helpers for the given type.
1711 bool BlockRequiresCopying(QualType Ty, const VarDecl *D);
1712
1713 /// Returns true, if given type has a known lifetime. HasByrefExtendedLayout
1714 /// is set to false in this case. If HasByrefExtendedLayout returns true,
1715 /// byref variable has extended lifetime.
1716 bool getByrefLifetime(QualType Ty,
1717 Qualifiers::ObjCLifetime &Lifetime,
1718 bool &HasByrefExtendedLayout) const;
1719
1720 /// Return the uniqued reference to the type for an lvalue reference
1721 /// to the specified type.
1722 QualType getLValueReferenceType(QualType T, bool SpelledAsLValue = true)
1723 const;
1724
1725 /// Return the uniqued reference to the type for an rvalue reference
1726 /// to the specified type.
1728
1729 /// Return the uniqued reference to the type for a member pointer to
1730 /// the specified type in the specified nested name.
1732 const CXXRecordDecl *Cls) const;
1733
1734 /// Return a non-unique reference to the type for a variable array of
1735 /// the specified element type.
1738 unsigned IndexTypeQuals) const;
1739
1740 /// Return a non-unique reference to the type for a dependently-sized
1741 /// array of the specified element type.
1742 ///
1743 /// FIXME: We will need these to be uniqued, or at least comparable, at some
1744 /// point.
1747 unsigned IndexTypeQuals) const;
1748
1749 /// Return a unique reference to the type for an incomplete array of
1750 /// the specified element type.
1752 unsigned IndexTypeQuals) const;
1753
1754 /// Return the unique reference to the type for a constant array of
1755 /// the specified element type.
1756 QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize,
1757 const Expr *SizeExpr, ArraySizeModifier ASM,
1758 unsigned IndexTypeQuals) const;
1759
1760 /// Return a type for a constant array for a string literal of the
1761 /// specified element type and length.
1762 QualType getStringLiteralArrayType(QualType EltTy, unsigned Length) const;
1763
1764 /// Returns a vla type where known sizes are replaced with [*].
1766
1767 // Convenience struct to return information about a builtin vector type.
1776
1777 /// Returns the element type, element count and number of vectors
1778 /// (in case of tuple) for a builtin vector type.
1779 BuiltinVectorTypeInfo
1780 getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const;
1781
1782 /// Return the unique reference to a scalable vector type of the specified
1783 /// element type and scalable number of elements.
1784 /// For RISC-V, number of fields is also provided when it fetching for
1785 /// tuple type.
1786 ///
1787 /// \pre \p EltTy must be a built-in type.
1788 QualType getScalableVectorType(QualType EltTy, unsigned NumElts,
1789 unsigned NumFields = 1) const;
1790
1791 /// Return a WebAssembly externref type.
1793
1794 /// Return the unique reference to a vector type of the specified
1795 /// element type and size.
1796 ///
1797 /// \pre \p VectorType must be a built-in type.
1798 QualType getVectorType(QualType VectorType, unsigned NumElts,
1799 VectorKind VecKind) const;
1800 /// Return the unique reference to the type for a dependently sized vector of
1801 /// the specified element type.
1803 SourceLocation AttrLoc,
1804 VectorKind VecKind) const;
1805
1806 /// Return the unique reference to an extended vector type
1807 /// of the specified element type and size.
1808 ///
1809 /// \pre \p VectorType must be a built-in type.
1810 QualType getExtVectorType(QualType VectorType, unsigned NumElts) const;
1811
1812 /// \pre Return a non-unique reference to the type for a dependently-sized
1813 /// vector of the specified element type.
1814 ///
1815 /// FIXME: We will need these to be uniqued, or at least comparable, at some
1816 /// point.
1818 Expr *SizeExpr,
1819 SourceLocation AttrLoc) const;
1820
1821 /// Return the unique reference to the matrix type of the specified element
1822 /// type and size
1823 ///
1824 /// \pre \p ElementType must be a valid matrix element type (see
1825 /// MatrixType::isValidElementType).
1826 QualType getConstantMatrixType(QualType ElementType, unsigned NumRows,
1827 unsigned NumColumns) const;
1828
1829 /// Return the unique reference to the matrix type of the specified element
1830 /// type and size
1831 QualType getDependentSizedMatrixType(QualType ElementType, Expr *RowExpr,
1832 Expr *ColumnExpr,
1833 SourceLocation AttrLoc) const;
1834
1836 Expr *AddrSpaceExpr,
1837 SourceLocation AttrLoc) const;
1838
1839 /// Return a K&R style C function type like 'int()'.
1841 const FunctionType::ExtInfo &Info) const;
1842
1846
1847 /// Return a normal function type with a typed argument list.
1849 const FunctionProtoType::ExtProtoInfo &EPI) const {
1850 return getFunctionTypeInternal(ResultTy, Args, EPI, false);
1851 }
1852
1854
1855private:
1856 /// Return a normal function type with a typed argument list.
1857 QualType getFunctionTypeInternal(QualType ResultTy, ArrayRef<QualType> Args,
1859 bool OnlyWantCanonical) const;
1860
1861public:
1863 NestedNameSpecifier Qualifier,
1864 const TypeDecl *Decl) const;
1865
1866 /// Return the unique reference to the type for the specified type
1867 /// declaration.
1868 QualType getTypeDeclType(const TypeDecl *Decl) const;
1869
1870 /// Use the normal 'getFooBarType' constructors to obtain these types.
1871 QualType getTypeDeclType(const TagDecl *) const = delete;
1872 QualType getTypeDeclType(const TypedefDecl *) const = delete;
1873 QualType getTypeDeclType(const TypeAliasDecl *) const = delete;
1875
1877
1879 NestedNameSpecifier Qualifier, const UsingShadowDecl *D,
1880 QualType UnderlyingType = QualType()) const;
1881
1882 /// Return the unique reference to the type for the specified
1883 /// typedef-name decl.
1884 /// FIXME: TypeMatchesDeclOrNone is a workaround for a serialization issue:
1885 /// The decl underlying type might still not be available.
1888 const TypedefNameDecl *Decl, QualType UnderlyingType = QualType(),
1889 std::optional<bool> TypeMatchesDeclOrNone = std::nullopt) const;
1890
1891 CanQualType getCanonicalTagType(const TagDecl *TD) const;
1893 NestedNameSpecifier Qualifier, const TagDecl *TD,
1894 bool OwnsTag) const;
1895
1896private:
1897 UnresolvedUsingType *getUnresolvedUsingTypeInternal(
1899 const UnresolvedUsingTypenameDecl *D, void *InsertPos,
1900 const Type *CanonicalType) const;
1901
1902 TagType *getTagTypeInternal(ElaboratedTypeKeyword Keyword,
1903 NestedNameSpecifier Qualifier, const TagDecl *Tag,
1904 bool OwnsTag, bool IsInjected,
1905 const Type *CanonicalType,
1906 bool WithFoldingSetNode) const;
1907
1908public:
1909 /// Compute BestType and BestPromotionType for an enum based on the highest
1910 /// number of negative and positive bits of its elements.
1911 /// Returns true if enum width is too large.
1912 bool computeBestEnumTypes(bool IsPacked, unsigned NumNegativeBits,
1913 unsigned NumPositiveBits, QualType &BestType,
1914 QualType &BestPromotionType);
1915
1916 /// Determine whether the given integral value is representable within
1917 /// the given type T.
1918 bool isRepresentableIntegerValue(llvm::APSInt &Value, QualType T);
1919
1920 /// Compute NumNegativeBits and NumPositiveBits for an enum based on
1921 /// the constant values of its enumerators.
1922 template <typename RangeT>
1923 bool computeEnumBits(RangeT EnumConstants, unsigned &NumNegativeBits,
1924 unsigned &NumPositiveBits) {
1925 NumNegativeBits = 0;
1926 NumPositiveBits = 0;
1927 bool MembersRepresentableByInt = true;
1928 for (auto *Elem : EnumConstants) {
1929 EnumConstantDecl *ECD = cast_or_null<EnumConstantDecl>(Elem);
1930 if (!ECD)
1931 continue; // Already issued a diagnostic.
1932
1933 llvm::APSInt InitVal = ECD->getInitVal();
1934 if (InitVal.isUnsigned() || InitVal.isNonNegative()) {
1935 // If the enumerator is zero that should still be counted as a positive
1936 // bit since we need a bit to store the value zero.
1937 unsigned ActiveBits = InitVal.getActiveBits();
1938 NumPositiveBits = std::max({NumPositiveBits, ActiveBits, 1u});
1939 } else {
1940 NumNegativeBits =
1941 std::max(NumNegativeBits, InitVal.getSignificantBits());
1942 }
1943
1944 MembersRepresentableByInt &= isRepresentableIntegerValue(InitVal, IntTy);
1945 }
1946
1947 // If we have an empty set of enumerators we still need one bit.
1948 // From [dcl.enum]p8
1949 // If the enumerator-list is empty, the values of the enumeration are as if
1950 // the enumeration had a single enumerator with value 0
1951 if (!NumPositiveBits && !NumNegativeBits)
1952 NumPositiveBits = 1;
1953
1954 return MembersRepresentableByInt;
1955 }
1956
1960 NestedNameSpecifier Qualifier,
1961 const UnresolvedUsingTypenameDecl *D) const;
1962
1963 QualType getAttributedType(attr::Kind attrKind, QualType modifiedType,
1964 QualType equivalentType,
1965 const Attr *attr = nullptr) const;
1966
1967 QualType getAttributedType(const Attr *attr, QualType modifiedType,
1968 QualType equivalentType) const;
1969
1970 QualType getAttributedType(NullabilityKind nullability, QualType modifiedType,
1971 QualType equivalentType);
1972
1973 QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr,
1974 QualType Wrapped) const;
1975
1976 QualType getOverflowBehaviorType(const OverflowBehaviorAttr *Attr,
1977 QualType Wrapped) const;
1978
1979 QualType
1980 getOverflowBehaviorType(OverflowBehaviorType::OverflowBehaviorKind Kind,
1981 QualType Wrapped) const;
1982
1984 QualType Wrapped, QualType Contained,
1985 const HLSLAttributedResourceType::Attributes &Attrs);
1986
1987 QualType getHLSLInlineSpirvType(uint32_t Opcode, uint32_t Size,
1988 uint32_t Alignment,
1989 ArrayRef<SpirvOperand> Operands);
1990
1992 Decl *AssociatedDecl, unsigned Index,
1993 UnsignedOrNone PackIndex,
1994 bool Final) const;
1996 unsigned Index, bool Final,
1997 const TemplateArgument &ArgPack);
1999
2000 QualType
2001 getTemplateTypeParmType(int Depth, int Index, bool ParameterPack,
2002 TemplateTypeParmDecl *ParmDecl = nullptr) const;
2003
2006 ArrayRef<TemplateArgument> CanonicalArgs) const;
2007
2008 QualType
2010 ArrayRef<TemplateArgument> SpecifiedArgs,
2011 ArrayRef<TemplateArgument> CanonicalArgs,
2012 QualType Underlying = QualType()) const;
2013
2014 QualType
2016 ArrayRef<TemplateArgumentLoc> SpecifiedArgs,
2017 ArrayRef<TemplateArgument> CanonicalArgs,
2018 QualType Canon = QualType()) const;
2019
2021 ElaboratedTypeKeyword Keyword, SourceLocation ElaboratedKeywordLoc,
2022 NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKeywordLoc,
2024 const TemplateArgumentListInfo &SpecifiedArgs,
2025 ArrayRef<TemplateArgument> CanonicalArgs,
2026 QualType Canon = QualType()) const;
2027
2028 QualType getParenType(QualType NamedType) const;
2029
2031 const IdentifierInfo *MacroII) const;
2032
2035 const IdentifierInfo *Name) const;
2036
2038
2039 /// Form a pack expansion type with the given pattern.
2040 /// \param NumExpansions The number of expansions for the pack, if known.
2041 /// \param ExpectPackInType If \c false, we should not expect \p Pattern to
2042 /// contain an unexpanded pack. This only makes sense if the pack
2043 /// expansion is used in a context where the arity is inferred from
2044 /// elsewhere, such as if the pattern contains a placeholder type or
2045 /// if this is the canonical type of another pack expansion type.
2047 bool ExpectPackInType = true) const;
2048
2050 ObjCInterfaceDecl *PrevDecl = nullptr) const;
2051
2052 /// Legacy interface: cannot provide type arguments or __kindof.
2054 ObjCProtocolDecl * const *Protocols,
2055 unsigned NumProtocols) const;
2056
2058 ArrayRef<QualType> typeArgs,
2060 bool isKindOf) const;
2061
2063 ArrayRef<ObjCProtocolDecl *> protocols) const;
2065 ObjCTypeParamDecl *New) const;
2066
2068
2069 /// QIdProtocolsAdoptObjCObjectProtocols - Checks that protocols in
2070 /// QT's qualified-id protocol list adopt all protocols in IDecl's list
2071 /// of protocols.
2073 ObjCInterfaceDecl *IDecl);
2074
2075 /// Return a ObjCObjectPointerType type for the given ObjCObjectType.
2077
2078 /// C23 feature and GCC extension.
2079 QualType getTypeOfExprType(Expr *E, TypeOfKind Kind) const;
2080 QualType getTypeOfType(QualType QT, TypeOfKind Kind) const;
2081
2082 QualType getReferenceQualifiedType(const Expr *e) const;
2083
2084 /// C++11 decltype.
2085 QualType getDecltypeType(Expr *e, QualType UnderlyingType) const;
2086
2087 QualType getPackIndexingType(QualType Pattern, Expr *IndexExpr,
2088 bool FullySubstituted = false,
2089 ArrayRef<QualType> Expansions = {},
2090 UnsignedOrNone Index = std::nullopt) const;
2091
2092 /// Unary type transforms
2093 QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType,
2094 UnaryTransformType::UTTKind UKind) const;
2095
2096 /// C++11 deduced auto type.
2097 QualType
2098 getAutoType(DeducedKind DK, QualType DeducedAsType, AutoTypeKeyword Keyword,
2099 TemplateDecl *TypeConstraintConcept = nullptr,
2100 ArrayRef<TemplateArgument> TypeConstraintArgs = {}) const;
2101
2102 /// C++11 deduction pattern for 'auto' type.
2103 QualType getAutoDeductType() const;
2104
2105 /// C++11 deduction pattern for 'auto &&' type.
2106 QualType getAutoRRefDeductType() const;
2107
2108 /// Remove any type constraints from a template parameter type, for
2109 /// equivalence comparison of template parameters.
2110 QualType getUnconstrainedType(QualType T) const;
2111
2112 /// C++17 deduced class template specialization type.
2114 QualType DeducedAsType,
2116 TemplateName Template) const;
2117
2118 /// Return the unique type for "size_t" (C99 7.17), defined in
2119 /// <stddef.h>.
2120 ///
2121 /// The sizeof operator requires this (C99 6.5.3.4p4).
2122 QualType getSizeType() const;
2123
2125
2126 /// Return the unique signed counterpart of
2127 /// the integer type corresponding to size_t.
2128 QualType getSignedSizeType() const;
2129
2130 /// Return the unique type for "intmax_t" (C99 7.18.1.5), defined in
2131 /// <stdint.h>.
2132 CanQualType getIntMaxType() const;
2133
2134 /// Return the unique type for "uintmax_t" (C99 7.18.1.5), defined in
2135 /// <stdint.h>.
2137
2138 /// Return the unique wchar_t type available in C++ (and available as
2139 /// __wchar_t as a Microsoft extension).
2140 QualType getWCharType() const { return WCharTy; }
2141
2142 /// Return the type of wide characters. In C++, this returns the
2143 /// unique wchar_t type. In C99, this returns a type compatible with the type
2144 /// defined in <stddef.h> as defined by the target.
2146
2147 /// Return the type of "signed wchar_t".
2148 ///
2149 /// Used when in C++, as a GCC extension.
2151
2152 /// Return the type of "unsigned wchar_t".
2153 ///
2154 /// Used when in C++, as a GCC extension.
2156
2157 /// In C99, this returns a type compatible with the type
2158 /// defined in <stddef.h> as defined by the target.
2159 QualType getWIntType() const { return WIntTy; }
2160
2161 /// Return a type compatible with "intptr_t" (C99 7.18.1.4),
2162 /// as defined by the target.
2163 QualType getIntPtrType() const;
2164
2165 /// Return a type compatible with "uintptr_t" (C99 7.18.1.4),
2166 /// as defined by the target.
2167 QualType getUIntPtrType() const;
2168
2169 /// Return the unique type for "ptrdiff_t" (C99 7.17) defined in
2170 /// <stddef.h>. Pointer - pointer requires this (C99 6.5.6p9).
2172
2173 /// Return the unique unsigned counterpart of "ptrdiff_t"
2174 /// integer type. The standard (C11 7.21.6.1p7) refers to this type
2175 /// in the definition of %tu format specifier.
2177
2178 /// Return the unique type for "pid_t" defined in
2179 /// <sys/types.h>. We need this to compute the correct type for vfork().
2180 QualType getProcessIDType() const;
2181
2182 /// Return the C structure type used to represent constant CFStrings.
2184
2185 /// Returns the C struct type for objc_super
2186 QualType getObjCSuperType() const;
2187 void setObjCSuperType(QualType ST) { ObjCSuperType = ST; }
2188
2189 /// Get the structure type used to representation CFStrings, or NULL
2190 /// if it hasn't yet been built.
2192 if (CFConstantStringTypeDecl)
2194 /*Qualifier=*/std::nullopt,
2195 CFConstantStringTypeDecl);
2196 return QualType();
2197 }
2201
2202 // This setter/getter represents the ObjC type for an NSConstantString.
2205 return ObjCConstantStringType;
2206 }
2207
2209 return ObjCNSStringType;
2210 }
2211
2213 ObjCNSStringType = T;
2214 }
2215
2216 /// Retrieve the type that \c id has been defined to, which may be
2217 /// different from the built-in \c id if \c id has been typedef'd.
2219 if (ObjCIdRedefinitionType.isNull())
2220 return getObjCIdType();
2221 return ObjCIdRedefinitionType;
2222 }
2223
2224 /// Set the user-written type that redefines \c id.
2226 ObjCIdRedefinitionType = RedefType;
2227 }
2228
2229 /// Retrieve the type that \c Class has been defined to, which may be
2230 /// different from the built-in \c Class if \c Class has been typedef'd.
2232 if (ObjCClassRedefinitionType.isNull())
2233 return getObjCClassType();
2234 return ObjCClassRedefinitionType;
2235 }
2236
2237 /// Set the user-written type that redefines 'SEL'.
2239 ObjCClassRedefinitionType = RedefType;
2240 }
2241
2242 /// Retrieve the type that 'SEL' has been defined to, which may be
2243 /// different from the built-in 'SEL' if 'SEL' has been typedef'd.
2245 if (ObjCSelRedefinitionType.isNull())
2246 return getObjCSelType();
2247 return ObjCSelRedefinitionType;
2248 }
2249
2250 /// Set the user-written type that redefines 'SEL'.
2252 ObjCSelRedefinitionType = RedefType;
2253 }
2254
2255 /// Retrieve the identifier 'NSObject'.
2257 if (!NSObjectName) {
2258 NSObjectName = &Idents.get("NSObject");
2259 }
2260
2261 return NSObjectName;
2262 }
2263
2264 /// Retrieve the identifier 'NSCopying'.
2266 if (!NSCopyingName) {
2267 NSCopyingName = &Idents.get("NSCopying");
2268 }
2269
2270 return NSCopyingName;
2271 }
2272
2274
2276
2277 /// Retrieve the identifier 'bool'.
2279 if (!BoolName)
2280 BoolName = &Idents.get("bool");
2281 return BoolName;
2282 }
2283
2284#define BuiltinTemplate(BTName) \
2285 IdentifierInfo *get##BTName##Name() const { \
2286 if (!Name##BTName) \
2287 Name##BTName = &Idents.get(#BTName); \
2288 return Name##BTName; \
2289 }
2290#include "clang/Basic/BuiltinTemplates.inc"
2291
2292 /// Retrieve the Objective-C "instancetype" type.
2295 /*Qualifier=*/std::nullopt,
2297 }
2298
2299 /// Retrieve the typedef declaration corresponding to the Objective-C
2300 /// "instancetype" type.
2302
2303 /// Set the type for the C FILE type.
2304 void setFILEDecl(TypeDecl *FILEDecl) { this->FILEDecl = FILEDecl; }
2305
2306 /// Retrieve the C FILE type.
2308 if (FILEDecl)
2310 /*Qualifier=*/std::nullopt, FILEDecl);
2311 return QualType();
2312 }
2313
2314 /// Set the type for the C jmp_buf type.
2315 void setjmp_bufDecl(TypeDecl *jmp_bufDecl) {
2316 this->jmp_bufDecl = jmp_bufDecl;
2317 }
2318
2319 /// Retrieve the C jmp_buf type.
2321 if (jmp_bufDecl)
2323 /*Qualifier=*/std::nullopt, jmp_bufDecl);
2324 return QualType();
2325 }
2326
2327 /// Set the type for the C sigjmp_buf type.
2328 void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl) {
2329 this->sigjmp_bufDecl = sigjmp_bufDecl;
2330 }
2331
2332 /// Retrieve the C sigjmp_buf type.
2334 if (sigjmp_bufDecl)
2336 /*Qualifier=*/std::nullopt, sigjmp_bufDecl);
2337 return QualType();
2338 }
2339
2340 /// Set the type for the C ucontext_t type.
2341 void setucontext_tDecl(TypeDecl *ucontext_tDecl) {
2342 this->ucontext_tDecl = ucontext_tDecl;
2343 }
2344
2345 /// Retrieve the C ucontext_t type.
2347 if (ucontext_tDecl)
2349 /*Qualifier=*/std::nullopt, ucontext_tDecl);
2350 return QualType();
2351 }
2352
2353 /// The result type of logical operations, '<', '>', '!=', etc.
2355 return getLangOpts().CPlusPlus ? BoolTy : IntTy;
2356 }
2357
2358 /// Emit the Objective-CC type encoding for the given type \p T into
2359 /// \p S.
2360 ///
2361 /// If \p Field is specified then record field names are also encoded.
2362 void getObjCEncodingForType(QualType T, std::string &S,
2363 const FieldDecl *Field=nullptr,
2364 QualType *NotEncodedT=nullptr) const;
2365
2366 /// Emit the Objective-C property type encoding for the given
2367 /// type \p T into \p S.
2368 void getObjCEncodingForPropertyType(QualType T, std::string &S) const;
2369
2371
2372 /// Put the string version of the type qualifiers \p QT into \p S.
2374 std::string &S) const;
2375
2376 /// Emit the encoded type for the function \p Decl into \p S.
2377 ///
2378 /// This is in the same format as Objective-C method encodings.
2379 ///
2380 /// \returns true if an error occurred (e.g., because one of the parameter
2381 /// types is incomplete), false otherwise.
2382 std::string getObjCEncodingForFunctionDecl(const FunctionDecl *Decl) const;
2383
2384 /// Emit the encoded type for the method declaration \p Decl into
2385 /// \p S.
2387 bool Extended = false) const;
2388
2389 /// Return the encoded type for this block declaration.
2390 std::string getObjCEncodingForBlock(const BlockExpr *blockExpr) const;
2391
2392 /// getObjCEncodingForPropertyDecl - Return the encoded type for
2393 /// this method declaration. If non-NULL, Container must be either
2394 /// an ObjCCategoryImplDecl or ObjCImplementationDecl; it should
2395 /// only be NULL when getting encodings for protocol properties.
2397 const Decl *Container) const;
2398
2400 ObjCProtocolDecl *rProto) const;
2401
2403 const ObjCPropertyDecl *PD,
2404 const Decl *Container) const;
2405
2406 /// Return the size of type \p T for Objective-C encoding purpose,
2407 /// in characters.
2409
2410 /// Retrieve the typedef corresponding to the predefined \c id type
2411 /// in Objective-C.
2412 TypedefDecl *getObjCIdDecl() const;
2413
2414 /// Represents the Objective-CC \c id type.
2415 ///
2416 /// This is set up lazily, by Sema. \c id is always a (typedef for a)
2417 /// pointer type, a pointer to a struct.
2420 /*Qualifier=*/std::nullopt, getObjCIdDecl());
2421 }
2422
2423 /// Retrieve the typedef corresponding to the predefined 'SEL' type
2424 /// in Objective-C.
2425 TypedefDecl *getObjCSelDecl() const;
2426
2427 /// Retrieve the type that corresponds to the predefined Objective-C
2428 /// 'SEL' type.
2431 /*Qualifier=*/std::nullopt, getObjCSelDecl());
2432 }
2433
2435
2436 /// Retrieve the typedef declaration corresponding to the predefined
2437 /// Objective-C 'Class' type.
2439
2440 /// Represents the Objective-C \c Class type.
2441 ///
2442 /// This is set up lazily, by Sema. \c Class is always a (typedef for a)
2443 /// pointer type, a pointer to a struct.
2446 /*Qualifier=*/std::nullopt, getObjCClassDecl());
2447 }
2448
2449 /// Retrieve the Objective-C class declaration corresponding to
2450 /// the predefined \c Protocol class.
2452
2453 /// Retrieve declaration of 'BOOL' typedef
2455 return BOOLDecl;
2456 }
2457
2458 /// Save declaration of 'BOOL' typedef
2460 BOOLDecl = TD;
2461 }
2462
2463 /// type of 'BOOL' type.
2466 /*Qualifier=*/std::nullopt, getBOOLDecl());
2467 }
2468
2469 /// Retrieve the type of the Objective-C \c Protocol class.
2473
2474 /// Retrieve the C type declaration corresponding to the predefined
2475 /// \c __builtin_va_list type.
2477
2478 /// Retrieve the type of the \c __builtin_va_list type.
2481 /*Qualifier=*/std::nullopt, getBuiltinVaListDecl());
2482 }
2483
2484 /// Retrieve the C type declaration corresponding to the predefined
2485 /// \c __va_list_tag type used to help define the \c __builtin_va_list type
2486 /// for some targets.
2487 Decl *getVaListTagDecl() const;
2488
2489 /// Retrieve the C type declaration corresponding to the predefined
2490 /// \c __builtin_ms_va_list type.
2492
2493 /// Retrieve the type of the \c __builtin_ms_va_list type.
2496 /*Qualifier=*/std::nullopt, getBuiltinMSVaListDecl());
2497 }
2498
2499 /// Retrieve the implicitly-predeclared 'struct _GUID' declaration.
2501
2502 /// Retrieve the implicitly-predeclared 'struct _GUID' type.
2504 assert(MSGuidTagDecl && "asked for GUID type but MS extensions disabled");
2506 }
2507
2508 /// Retrieve the implicitly-predeclared 'struct type_info' declaration.
2510 // Lazily create this type on demand - it's only needed for MS builds.
2511 if (!MSTypeInfoTagDecl)
2513 return MSTypeInfoTagDecl;
2514 }
2515
2516 /// Return whether a declaration to a builtin is allowed to be
2517 /// overloaded/redeclared.
2518 bool canBuiltinBeRedeclared(const FunctionDecl *) const;
2519
2520 /// Return a type with additional \c const, \c volatile, or
2521 /// \c restrict qualifiers.
2522 QualType getCVRQualifiedType(QualType T, unsigned CVR) const {
2524 }
2525
2526 /// Un-split a SplitQualType.
2528 return getQualifiedType(split.Ty, split.Quals);
2529 }
2530
2531 /// Return a type with additional qualifiers.
2533 if (!Qs.hasNonFastQualifiers())
2535 QualifierCollector Qc(Qs);
2536 const Type *Ptr = Qc.strip(T);
2537 return getExtQualType(Ptr, Qc);
2538 }
2539
2540 /// Return a type with additional qualifiers.
2542 if (!Qs.hasNonFastQualifiers())
2543 return QualType(T, Qs.getFastQualifiers());
2544 return getExtQualType(T, Qs);
2545 }
2546
2547 /// Return a type with the given lifetime qualifier.
2548 ///
2549 /// \pre Neither type.ObjCLifetime() nor \p lifetime may be \c OCL_None.
2551 Qualifiers::ObjCLifetime lifetime) {
2552 assert(type.getObjCLifetime() == Qualifiers::OCL_None);
2553 assert(lifetime != Qualifiers::OCL_None);
2554
2555 Qualifiers qs;
2556 qs.addObjCLifetime(lifetime);
2557 return getQualifiedType(type, qs);
2558 }
2559
2560 /// getUnqualifiedObjCPointerType - Returns version of
2561 /// Objective-C pointer type with lifetime qualifier removed.
2563 if (!type.getTypePtr()->isObjCObjectPointerType() ||
2564 !type.getQualifiers().hasObjCLifetime())
2565 return type;
2566 Qualifiers Qs = type.getQualifiers();
2567 Qs.removeObjCLifetime();
2568 return getQualifiedType(type.getUnqualifiedType(), Qs);
2569 }
2570
2571 /// \brief Return a type with the given __ptrauth qualifier.
2573 assert(!Ty.getPointerAuth());
2574 assert(PointerAuth);
2575
2576 Qualifiers Qs;
2577 Qs.setPointerAuth(PointerAuth);
2578 return getQualifiedType(Ty, Qs);
2579 }
2580
2581 unsigned char getFixedPointScale(QualType Ty) const;
2582 unsigned char getFixedPointIBits(QualType Ty) const;
2583 llvm::FixedPointSemantics getFixedPointSemantics(QualType Ty) const;
2584 llvm::APFixedPoint getFixedPointMax(QualType Ty) const;
2585 llvm::APFixedPoint getFixedPointMin(QualType Ty) const;
2586
2588 SourceLocation NameLoc) const;
2589
2591 UnresolvedSetIterator End) const;
2593
2595 bool TemplateKeyword,
2596 TemplateName Template) const;
2599
2601 Decl *AssociatedDecl,
2602 unsigned Index,
2603 UnsignedOrNone PackIndex,
2604 bool Final) const;
2606 Decl *AssociatedDecl,
2607 unsigned Index,
2608 bool Final) const;
2609
2610 /// Represents a TemplateName which had some of its default arguments
2611 /// deduced. This both represents this default argument deduction as sugar,
2612 /// and provides the support for it's equivalences through canonicalization.
2613 /// For example DeducedTemplateNames which have the same set of default
2614 /// arguments are equivalent, and are also equivalent to the underlying
2615 /// template when the deduced template arguments are the same.
2617 DefaultArguments DefaultArgs) const;
2618
2620 /// No error
2622
2623 /// Missing a type
2625
2626 /// Missing a type from <stdio.h>
2628
2629 /// Missing a type from <setjmp.h>
2631
2632 /// Missing a type from <ucontext.h>
2634 };
2635
2636 QualType DecodeTypeStr(const char *&Str, const ASTContext &Context,
2638 bool &RequireICE, bool AllowTypeModifiers) const;
2639
2640 /// Return the type for the specified builtin.
2641 ///
2642 /// If \p IntegerConstantArgs is non-null, it is filled in with a bitmask of
2643 /// arguments to the builtin that are required to be integer constant
2644 /// expressions.
2646 unsigned *IntegerConstantArgs = nullptr) const;
2647
2648 /// Types and expressions required to build C++2a three-way comparisons
2649 /// using operator<=>, including the values return by builtin <=> operators.
2651
2652private:
2653 CanQualType getFromTargetType(unsigned Type) const;
2654 TypeInfo getTypeInfoImpl(const Type *T) const;
2655
2656 //===--------------------------------------------------------------------===//
2657 // Type Predicates.
2658 //===--------------------------------------------------------------------===//
2659
2660public:
2661 /// Return one of the GCNone, Weak or Strong Objective-C garbage
2662 /// collection attributes.
2664
2665 /// Return true if the given vector types are of the same unqualified
2666 /// type or if they are equivalent to the same GCC vector type.
2667 ///
2668 /// \note This ignores whether they are target-specific (AltiVec or Neon)
2669 /// types.
2670 bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec);
2671
2672 /// Return true if two OverflowBehaviorTypes are compatible for assignment.
2673 /// This checks both the underlying type compatibility and the overflow
2674 /// behavior kind (trap vs wrap).
2676
2677 enum class OBTAssignResult {
2678 Compatible, // No OBT issues
2679 IncompatibleKinds, // __ob_trap vs __ob_wrap (error)
2680 Discards, // OBT -> non-OBT on integer types (warning)
2681 NotApplicable // Not both integers, fall through to normal checking
2682 };
2683
2684 /// Check overflow behavior type compatibility for assignments.
2685 /// Returns detailed information about OBT compatibility for assignment
2686 /// checking.
2688
2689 /// Return true if the given types are an RISC-V vector builtin type and a
2690 /// VectorType that is a fixed-length representation of the RISC-V vector
2691 /// builtin type for a specific vector-length.
2692 bool areCompatibleRVVTypes(QualType FirstType, QualType SecondType);
2693
2694 /// Return true if the given vector types are lax-compatible RISC-V vector
2695 /// types as defined by -flax-vector-conversions=, which permits implicit
2696 /// conversions between vectors with different number of elements and/or
2697 /// incompatible element types, false otherwise.
2698 bool areLaxCompatibleRVVTypes(QualType FirstType, QualType SecondType);
2699
2700 /// Return true if the type has been explicitly qualified with ObjC ownership.
2701 /// A type may be implicitly qualified with ownership under ObjC ARC, and in
2702 /// some cases the compiler treats these differently.
2704
2705 /// Return true if this is an \c NSObject object with its \c NSObject
2706 /// attribute set.
2708 return Ty->isObjCNSObjectType();
2709 }
2710
2711 //===--------------------------------------------------------------------===//
2712 // Type Sizing and Analysis
2713 //===--------------------------------------------------------------------===//
2714
2715 /// Return the APFloat 'semantics' for the specified scalar floating
2716 /// point type.
2717 const llvm::fltSemantics &getFloatTypeSemantics(QualType T) const;
2718
2719 /// Get the size and alignment of the specified complete type in bits.
2720 TypeInfo getTypeInfo(const Type *T) const;
2721 TypeInfo getTypeInfo(QualType T) const { return getTypeInfo(T.getTypePtr()); }
2722
2723 /// Get default simd alignment of the specified complete type in bits.
2724 unsigned getOpenMPDefaultSimdAlign(QualType T) const;
2725
2726 /// Return the size of the specified (complete) type \p T, in bits.
2727 uint64_t getTypeSize(QualType T) const { return getTypeInfo(T).Width; }
2728 uint64_t getTypeSize(const Type *T) const { return getTypeInfo(T).Width; }
2729
2730 /// Return the size of the character type, in bits.
2731 uint64_t getCharWidth() const {
2732 return getTypeSize(CharTy);
2733 }
2734
2735 /// Convert a size in bits to a size in characters.
2736 CharUnits toCharUnitsFromBits(int64_t BitSize) const;
2737
2738 /// Convert a size in characters to a size in bits.
2739 int64_t toBits(CharUnits CharSize) const;
2740
2741 /// Return the size of the specified (complete) type \p T, in
2742 /// characters.
2744 CharUnits getTypeSizeInChars(const Type *T) const;
2745
2746 std::optional<CharUnits> getTypeSizeInCharsIfKnown(QualType Ty) const {
2747 if (Ty->isIncompleteType() || Ty->isDependentType() ||
2748 Ty->isUndeducedType() || Ty->isSizelessType())
2749 return std::nullopt;
2750 return getTypeSizeInChars(Ty);
2751 }
2752
2753 std::optional<CharUnits> getTypeSizeInCharsIfKnown(const Type *Ty) const {
2754 return getTypeSizeInCharsIfKnown(QualType(Ty, 0));
2755 }
2756
2757 /// Return the ABI-specified alignment of a (complete) type \p T, in
2758 /// bits.
2759 unsigned getTypeAlign(QualType T) const { return getTypeInfo(T).Align; }
2760 unsigned getTypeAlign(const Type *T) const { return getTypeInfo(T).Align; }
2761
2762 /// Return the ABI-specified natural alignment of a (complete) type \p T,
2763 /// before alignment adjustments, in bits.
2764 ///
2765 /// This alignment is currently used only by ARM and AArch64 when passing
2766 /// arguments of a composite type.
2768 return getTypeUnadjustedAlign(T.getTypePtr());
2769 }
2770 unsigned getTypeUnadjustedAlign(const Type *T) const;
2771
2772 /// Return the alignment of a type, in bits, or 0 if
2773 /// the type is incomplete and we cannot determine the alignment (for
2774 /// example, from alignment attributes). The returned alignment is the
2775 /// Preferred alignment if NeedsPreferredAlignment is true, otherwise is the
2776 /// ABI alignment.
2777 unsigned getTypeAlignIfKnown(QualType T,
2778 bool NeedsPreferredAlignment = false) const;
2779
2780 /// Return the ABI-specified alignment of a (complete) type \p T, in
2781 /// characters.
2783 CharUnits getTypeAlignInChars(const Type *T) const;
2784
2785 /// Return the PreferredAlignment of a (complete) type \p T, in
2786 /// characters.
2790
2791 /// getTypeUnadjustedAlignInChars - Return the ABI-specified alignment of a type,
2792 /// in characters, before alignment adjustments. This method does not work on
2793 /// incomplete types.
2796
2797 // getTypeInfoDataSizeInChars - Return the size of a type, in chars. If the
2798 // type is a record, its data size is returned.
2800
2801 TypeInfoChars getTypeInfoInChars(const Type *T) const;
2803
2804 /// Determine if the alignment the type has was required using an
2805 /// alignment attribute.
2806 bool isAlignmentRequired(const Type *T) const;
2807 bool isAlignmentRequired(QualType T) const;
2808
2809 /// More type predicates useful for type checking/promotion
2810 bool isPromotableIntegerType(QualType T) const; // C99 6.3.1.1p2
2811
2812 /// Return the "preferred" alignment of the specified type \p T for
2813 /// the current target, in bits.
2814 ///
2815 /// This can be different than the ABI alignment in cases where it is
2816 /// beneficial for performance or backwards compatibility preserving to
2817 /// overalign a data type. (Note: despite the name, the preferred alignment
2818 /// is ABI-impacting, and not an optimization.)
2820 return getPreferredTypeAlign(T.getTypePtr());
2821 }
2822 unsigned getPreferredTypeAlign(const Type *T) const;
2823
2824 /// Return the default alignment for __attribute__((aligned)) on
2825 /// this target, to be used if no alignment value is specified.
2827
2828 /// Return the alignment in bits that should be given to a
2829 /// global variable with type \p T. If \p VD is non-null it will be
2830 /// considered specifically for the query.
2831 unsigned getAlignOfGlobalVar(QualType T, const VarDecl *VD) const;
2832
2833 /// Return the alignment in characters that should be given to a
2834 /// global variable with type \p T. If \p VD is non-null it will be
2835 /// considered specifically for the query.
2837
2838 /// Return the minimum alignment as specified by the target. If \p VD is
2839 /// non-null it may be used to identify external or weak variables.
2840 unsigned getMinGlobalAlignOfVar(uint64_t Size, const VarDecl *VD) const;
2841
2842 /// Return a conservative estimate of the alignment of the specified
2843 /// decl \p D.
2844 ///
2845 /// \pre \p D must not be a bitfield type, as bitfields do not have a valid
2846 /// alignment.
2847 ///
2848 /// If \p ForAlignof, references are treated like their underlying type
2849 /// and large arrays don't get any special treatment. If not \p ForAlignof
2850 /// it computes the value expected by CodeGen: references are treated like
2851 /// pointers and large arrays get extra alignment.
2852 CharUnits getDeclAlign(const Decl *D, bool ForAlignof = false) const;
2853
2854 /// Return the alignment (in bytes) of the thrown exception object. This is
2855 /// only meaningful for targets that allocate C++ exceptions in a system
2856 /// runtime, such as those using the Itanium C++ ABI.
2858
2859 /// Return whether unannotated records are treated as if they have
2860 /// [[gnu::ms_struct]].
2861 bool defaultsToMsStruct() const;
2862
2863 /// Get or compute information about the layout of the specified
2864 /// record (struct/union/class) \p D, which indicates its size and field
2865 /// position information.
2866 const ASTRecordLayout &getASTRecordLayout(const RecordDecl *D) const;
2867
2868 /// Get or compute information about the layout of the specified
2869 /// Objective-C interface.
2871 const;
2872
2873 void DumpRecordLayout(const RecordDecl *RD, raw_ostream &OS,
2874 bool Simple = false) const;
2875
2876 /// Get our current best idea for the key function of the
2877 /// given record decl, or nullptr if there isn't one.
2878 ///
2879 /// The key function is, according to the Itanium C++ ABI section 5.2.3:
2880 /// ...the first non-pure virtual function that is not inline at the
2881 /// point of class definition.
2882 ///
2883 /// Other ABIs use the same idea. However, the ARM C++ ABI ignores
2884 /// virtual functions that are defined 'inline', which means that
2885 /// the result of this computation can change.
2887
2888 /// Observe that the given method cannot be a key function.
2889 /// Checks the key-function cache for the method's class and clears it
2890 /// if matches the given declaration.
2891 ///
2892 /// This is used in ABIs where out-of-line definitions marked
2893 /// inline are not considered to be key functions.
2894 ///
2895 /// \param method should be the declaration from the class definition
2896 void setNonKeyFunction(const CXXMethodDecl *method);
2897
2898 /// Loading virtual member pointers using the virtual inheritance model
2899 /// always results in an adjustment using the vbtable even if the index is
2900 /// zero.
2901 ///
2902 /// This is usually OK because the first slot in the vbtable points
2903 /// backwards to the top of the MDC. However, the MDC might be reusing a
2904 /// vbptr from an nv-base. In this case, the first slot in the vbtable
2905 /// points to the start of the nv-base which introduced the vbptr and *not*
2906 /// the MDC. Modify the NonVirtualBaseAdjustment to account for this.
2908
2909 /// Get the offset of a FieldDecl or IndirectFieldDecl, in bits.
2910 uint64_t getFieldOffset(const ValueDecl *FD) const;
2911
2912 /// Get the offset of an ObjCIvarDecl in bits.
2913 uint64_t lookupFieldBitOffset(const ObjCInterfaceDecl *OID,
2914 const ObjCIvarDecl *Ivar) const;
2915
2916 /// Find the 'this' offset for the member path in a pointer-to-member
2917 /// APValue.
2919
2920 bool isNearlyEmpty(const CXXRecordDecl *RD) const;
2921
2923
2924 /// If \p T is null pointer, assume the target in ASTContext.
2925 MangleContext *createMangleContext(const TargetInfo *T = nullptr);
2926
2927 /// Creates a device mangle context to correctly mangle lambdas in a mixed
2928 /// architecture compile by setting the lambda mangling number source to the
2929 /// DeviceLambdaManglingNumber. Currently this asserts that the TargetInfo
2930 /// (from the AuxTargetInfo) is a an itanium target.
2932
2934
2935 void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass,
2937
2938 unsigned CountNonClassIvars(const ObjCInterfaceDecl *OI) const;
2939 void CollectInheritedProtocols(const Decl *CDecl,
2941
2942 /// Return true if the specified type has unique object representations
2943 /// according to (C++17 [meta.unary.prop]p9)
2944 bool
2946 bool CheckIfTriviallyCopyable = true) const;
2947
2948 //===--------------------------------------------------------------------===//
2949 // Type Operators
2950 //===--------------------------------------------------------------------===//
2951
2952 /// Return the canonical (structural) type corresponding to the
2953 /// specified potentially non-canonical type \p T.
2954 ///
2955 /// The non-canonical version of a type may have many "decorated" versions of
2956 /// types. Decorators can include typedefs, 'typeof' operators, etc. The
2957 /// returned type is guaranteed to be free of any of these, allowing two
2958 /// canonical types to be compared for exact equality with a simple pointer
2959 /// comparison.
2961 return CanQualType::CreateUnsafe(T.getCanonicalType());
2962 }
2963
2964 static const Type *getCanonicalType(const Type *T) {
2966 }
2967
2968 /// Return the canonical parameter type corresponding to the specific
2969 /// potentially non-canonical one.
2970 ///
2971 /// Qualifiers are stripped off, functions are turned into function
2972 /// pointers, and arrays decay one level into pointers.
2974
2975 /// Determine whether the given types \p T1 and \p T2 are equivalent.
2976 static bool hasSameType(QualType T1, QualType T2) {
2977 return getCanonicalType(T1) == getCanonicalType(T2);
2978 }
2979 static bool hasSameType(const Type *T1, const Type *T2) {
2980 return getCanonicalType(T1) == getCanonicalType(T2);
2981 }
2982
2983 /// Determine whether the given expressions \p X and \p Y are equivalent.
2984 bool hasSameExpr(const Expr *X, const Expr *Y) const;
2985
2986 /// Return this type as a completely-unqualified array type,
2987 /// capturing the qualifiers in \p Quals.
2988 ///
2989 /// This will remove the minimal amount of sugaring from the types, similar
2990 /// to the behavior of QualType::getUnqualifiedType().
2991 ///
2992 /// \param T is the qualified type, which may be an ArrayType
2993 ///
2994 /// \param Quals will receive the full set of qualifiers that were
2995 /// applied to the array.
2996 ///
2997 /// \returns if this is an array type, the completely unqualified array type
2998 /// that corresponds to it. Otherwise, returns T.getUnqualifiedType().
3001 Qualifiers Quals;
3002 return getUnqualifiedArrayType(T, Quals);
3003 }
3004
3005 /// Determine whether the given types are equivalent after
3006 /// cvr-qualifiers have been removed.
3008 return getCanonicalType(T1).getTypePtr() ==
3010 }
3011
3013 bool IsParam) const {
3014 auto SubTnullability = SubT->getNullability();
3015 auto SuperTnullability = SuperT->getNullability();
3016 if (SubTnullability.has_value() == SuperTnullability.has_value()) {
3017 // Neither has nullability; return true
3018 if (!SubTnullability)
3019 return true;
3020 // Both have nullability qualifier.
3021 if (*SubTnullability == *SuperTnullability ||
3022 *SubTnullability == NullabilityKind::Unspecified ||
3023 *SuperTnullability == NullabilityKind::Unspecified)
3024 return true;
3025
3026 if (IsParam) {
3027 // Ok for the superclass method parameter to be "nonnull" and the subclass
3028 // method parameter to be "nullable"
3029 return (*SuperTnullability == NullabilityKind::NonNull &&
3030 *SubTnullability == NullabilityKind::Nullable);
3031 }
3032 // For the return type, it's okay for the superclass method to specify
3033 // "nullable" and the subclass method specify "nonnull"
3034 return (*SuperTnullability == NullabilityKind::Nullable &&
3035 *SubTnullability == NullabilityKind::NonNull);
3036 }
3037 return true;
3038 }
3039
3040 bool ObjCMethodsAreEqual(const ObjCMethodDecl *MethodDecl,
3041 const ObjCMethodDecl *MethodImp);
3042
3043 bool UnwrapSimilarTypes(QualType &T1, QualType &T2,
3044 bool AllowPiMismatch = true) const;
3046 bool AllowPiMismatch = true) const;
3047
3048 /// Determine if two types are similar, according to the C++ rules. That is,
3049 /// determine if they are the same other than qualifiers on the initial
3050 /// sequence of pointer / pointer-to-member / array (and in Clang, object
3051 /// pointer) types and their element types.
3052 ///
3053 /// Clang offers a number of qualifiers in addition to the C++ qualifiers;
3054 /// those qualifiers are also ignored in the 'similarity' check.
3055 bool hasSimilarType(QualType T1, QualType T2) const;
3056
3057 /// Determine if two types are similar, ignoring only CVR qualifiers.
3058 bool hasCvrSimilarType(QualType T1, QualType T2);
3059
3060 /// Retrieves the default calling convention for the current context.
3061 ///
3062 /// The context's default calling convention may differ from the current
3063 /// target's default calling convention if the -fdefault-calling-conv option
3064 /// is used; to get the target's default calling convention, e.g. for built-in
3065 /// functions, call getTargetInfo().getDefaultCallingConv() instead.
3067 bool IsCXXMethod) const;
3068
3069 /// Retrieves the "canonical" template name that refers to a
3070 /// given template.
3071 ///
3072 /// The canonical template name is the simplest expression that can
3073 /// be used to refer to a given template. For most templates, this
3074 /// expression is just the template declaration itself. For example,
3075 /// the template std::vector can be referred to via a variety of
3076 /// names---std::vector, \::std::vector, vector (if vector is in
3077 /// scope), etc.---but all of these names map down to the same
3078 /// TemplateDecl, which is used to form the canonical template name.
3079 ///
3080 /// Dependent template names are more interesting. Here, the
3081 /// template name could be something like T::template apply or
3082 /// std::allocator<T>::template rebind, where the nested name
3083 /// specifier itself is dependent. In this case, the canonical
3084 /// template name uses the shortest form of the dependent
3085 /// nested-name-specifier, which itself contains all canonical
3086 /// types, values, and templates.
3088 bool IgnoreDeduced = false) const;
3089
3090 /// Return the default argument of a template parameter, if one exists.
3091 const TemplateArgument *
3093
3094 /// Determine whether the given template names refer to the same
3095 /// template.
3096 bool hasSameTemplateName(const TemplateName &X, const TemplateName &Y,
3097 bool IgnoreDeduced = false) const;
3098
3099 /// Determine whether the two declarations refer to the same entity.
3100 bool isSameEntity(const NamedDecl *X, const NamedDecl *Y) const;
3101
3102 /// Determine whether two template parameter lists are similar enough
3103 /// that they may be used in declarations of the same template.
3105 const TemplateParameterList *Y) const;
3106
3107 /// Determine whether two template parameters are similar enough
3108 /// that they may be used in declarations of the same template.
3109 bool isSameTemplateParameter(const NamedDecl *X, const NamedDecl *Y) const;
3110
3111 /// Determine whether two 'requires' expressions are similar enough that they
3112 /// may be used in re-declarations.
3113 ///
3114 /// Use of 'requires' isn't mandatory, works with constraints expressed in
3115 /// other ways too.
3117 const AssociatedConstraint &ACY) const;
3118
3119 /// Determine whether two 'requires' expressions are similar enough that they
3120 /// may be used in re-declarations.
3121 ///
3122 /// Use of 'requires' isn't mandatory, works with constraints expressed in
3123 /// other ways too.
3124 bool isSameConstraintExpr(const Expr *XCE, const Expr *YCE) const;
3125
3126 /// Determine whether two type contraint are similar enough that they could
3127 /// used in declarations of the same template.
3128 bool isSameTypeConstraint(const TypeConstraint *XTC,
3129 const TypeConstraint *YTC) const;
3130
3131 /// Determine whether two default template arguments are similar enough
3132 /// that they may be used in declarations of the same template.
3134 const NamedDecl *Y) const;
3135
3136 /// Retrieve the "canonical" template argument.
3137 ///
3138 /// The canonical template argument is the simplest template argument
3139 /// (which may be a type, value, expression, or declaration) that
3140 /// expresses the value of the argument.
3142 const;
3143
3144 /// Canonicalize the given template argument list.
3145 ///
3146 /// Returns true if any arguments were non-canonical, false otherwise.
3147 bool
3149
3150 /// Canonicalize the given TemplateTemplateParmDecl.
3153
3155 TemplateTemplateParmDecl *TTP) const;
3157 TemplateTemplateParmDecl *CanonTTP) const;
3158
3159 /// Determine whether the given template arguments \p Arg1 and \p Arg2 are
3160 /// equivalent.
3162 const TemplateArgument &Arg2) const;
3163
3164 /// Type Query functions. If the type is an instance of the specified class,
3165 /// return the Type pointer for the underlying maximally pretty type. This
3166 /// is a member of ASTContext because this may need to do some amount of
3167 /// canonicalization, e.g. to move type qualifiers into the element type.
3168 const ArrayType *getAsArrayType(QualType T) const;
3170 return dyn_cast_or_null<ConstantArrayType>(getAsArrayType(T));
3171 }
3173 return dyn_cast_or_null<VariableArrayType>(getAsArrayType(T));
3174 }
3176 return dyn_cast_or_null<IncompleteArrayType>(getAsArrayType(T));
3177 }
3179 const {
3180 return dyn_cast_or_null<DependentSizedArrayType>(getAsArrayType(T));
3181 }
3182
3183 /// Return the innermost element type of an array type.
3184 ///
3185 /// For example, will return "int" for int[m][n]
3186 QualType getBaseElementType(const ArrayType *VAT) const;
3187
3188 /// Return the innermost element type of a type (which needn't
3189 /// actually be an array type).
3191
3192 /// Return number of constant array elements.
3193 uint64_t getConstantArrayElementCount(const ConstantArrayType *CA) const;
3194
3195 /// Return number of elements initialized in an ArrayInitLoopExpr.
3196 uint64_t
3198
3199 /// Perform adjustment on the parameter type of a function.
3200 ///
3201 /// This routine adjusts the given parameter type @p T to the actual
3202 /// parameter type used by semantic analysis (C99 6.7.5.3p[7,8],
3203 /// C++ [dcl.fct]p3). The adjusted parameter type is returned.
3205
3206 /// Retrieve the parameter type as adjusted for use in the signature
3207 /// of a function, decaying array and function types and removing top-level
3208 /// cv-qualifiers.
3210
3212
3213 /// Return the properly qualified result of decaying the specified
3214 /// array type to a pointer.
3215 ///
3216 /// This operation is non-trivial when handling typedefs etc. The canonical
3217 /// type of \p T must be an array type, this returns a pointer to a properly
3218 /// qualified element of the array.
3219 ///
3220 /// See C99 6.7.5.3p7 and C99 6.3.2.1p3.
3222
3223 /// Return the type that \p PromotableType will promote to: C99
3224 /// 6.3.1.1p2, assuming that \p PromotableType is a promotable integer type.
3225 QualType getPromotedIntegerType(QualType PromotableType) const;
3226
3227 /// Recurses in pointer/array types until it finds an Objective-C
3228 /// retainable type and returns its ownership.
3230
3231 /// Whether this is a promotable bitfield reference according
3232 /// to C99 6.3.1.1p2, bullet 2 (and GCC extensions).
3233 ///
3234 /// \returns the type this bit-field will promote to, or NULL if no
3235 /// promotion occurs.
3237
3238 /// Return the highest ranked integer type, see C99 6.3.1.8p1.
3239 ///
3240 /// If \p LHS > \p RHS, returns 1. If \p LHS == \p RHS, returns 0. If
3241 /// \p LHS < \p RHS, return -1.
3242 int getIntegerTypeOrder(QualType LHS, QualType RHS) const;
3243
3244 /// Compare the rank of the two specified floating point types,
3245 /// ignoring the domain of the type (i.e. 'double' == '_Complex double').
3246 ///
3247 /// If \p LHS > \p RHS, returns 1. If \p LHS == \p RHS, returns 0. If
3248 /// \p LHS < \p RHS, return -1.
3249 int getFloatingTypeOrder(QualType LHS, QualType RHS) const;
3250
3251 /// Compare the rank of two floating point types as above, but compare equal
3252 /// if both types have the same floating-point semantics on the target (i.e.
3253 /// long double and double on AArch64 will return 0).
3255
3256 unsigned getTargetAddressSpace(LangAS AS) const;
3257
3258 LangAS getLangASForBuiltinAddressSpace(unsigned AS) const;
3259
3260 /// Get target-dependent integer value for null pointer which is used for
3261 /// constant folding.
3262 uint64_t getTargetNullPointerValue(QualType QT) const;
3263
3265 return AddrSpaceMapMangling || isTargetAddressSpace(AS);
3266 }
3267
3268 bool hasAnyFunctionEffects() const { return AnyFunctionEffects; }
3269
3270 // Merges two exception specifications, such that the resulting
3271 // exception spec is the union of both. For example, if either
3272 // of them can throw something, the result can throw it as well.
3276 SmallVectorImpl<QualType> &ExceptionTypeStorage,
3277 bool AcceptDependent) const;
3278
3279 // For two "same" types, return a type which has
3280 // the common sugar between them. If Unqualified is true,
3281 // both types need only be the same unqualified type.
3282 // The result will drop the qualifiers which do not occur
3283 // in both types.
3285 bool Unqualified = false) const;
3286
3287private:
3288 // Helper for integer ordering
3289 unsigned getIntegerRank(const Type *T) const;
3290
3291public:
3292 //===--------------------------------------------------------------------===//
3293 // Type Compatibility Predicates
3294 //===--------------------------------------------------------------------===//
3295
3296 /// Compatibility predicates used to check assignment expressions.
3298 bool CompareUnqualified = false); // C99 6.2.7p1
3299
3302
3303 bool isObjCIdType(QualType T) const { return T == getObjCIdType(); }
3304
3305 bool isObjCClassType(QualType T) const { return T == getObjCClassType(); }
3306
3307 bool isObjCSelType(QualType T) const { return T == getObjCSelType(); }
3308
3310 const ObjCObjectPointerType *RHS,
3311 bool ForCompare);
3312
3314 const ObjCObjectPointerType *RHS);
3315
3316 // Check the safety of assignment from LHS to RHS
3318 const ObjCObjectPointerType *RHSOPT);
3320 const ObjCObjectType *RHS);
3322 const ObjCObjectPointerType *LHSOPT,
3323 const ObjCObjectPointerType *RHSOPT,
3324 bool BlockReturnType);
3327 const ObjCObjectPointerType *RHSOPT);
3329
3330 // Functions for calculating composite types
3331 QualType mergeTypes(QualType, QualType, bool OfBlockPointer = false,
3332 bool Unqualified = false, bool BlockReturnType = false,
3333 bool IsConditionalOperator = false);
3334 QualType mergeFunctionTypes(QualType, QualType, bool OfBlockPointer = false,
3335 bool Unqualified = false, bool AllowCXX = false,
3336 bool IsConditionalOperator = false);
3338 bool OfBlockPointer = false,
3339 bool Unqualified = false);
3341 bool OfBlockPointer=false,
3342 bool Unqualified = false);
3344
3346
3347 /// This function merges the ExtParameterInfo lists of two functions. It
3348 /// returns true if the lists are compatible. The merged list is returned in
3349 /// NewParamInfos.
3350 ///
3351 /// \param FirstFnType The type of the first function.
3352 ///
3353 /// \param SecondFnType The type of the second function.
3354 ///
3355 /// \param CanUseFirst This flag is set to true if the first function's
3356 /// ExtParameterInfo list can be used as the composite list of
3357 /// ExtParameterInfo.
3358 ///
3359 /// \param CanUseSecond This flag is set to true if the second function's
3360 /// ExtParameterInfo list can be used as the composite list of
3361 /// ExtParameterInfo.
3362 ///
3363 /// \param NewParamInfos The composite list of ExtParameterInfo. The list is
3364 /// empty if none of the flags are set.
3365 ///
3367 const FunctionProtoType *FirstFnType,
3368 const FunctionProtoType *SecondFnType,
3369 bool &CanUseFirst, bool &CanUseSecond,
3371
3372 void ResetObjCLayout(const ObjCInterfaceDecl *D);
3373
3375 const ObjCInterfaceDecl *SubClass) {
3376 ObjCSubClasses[D].push_back(SubClass);
3377 }
3378
3379 //===--------------------------------------------------------------------===//
3380 // Integer Predicates
3381 //===--------------------------------------------------------------------===//
3382
3383 // The width of an integer, as defined in C99 6.2.6.2. This is the number
3384 // of bits in an integer type excluding any padding bits.
3385 unsigned getIntWidth(QualType T) const;
3386
3387 // Per C99 6.2.5p6, for every signed integer type, there is a corresponding
3388 // unsigned integer type. This method takes a signed type, and returns the
3389 // corresponding unsigned integer type.
3390 // With the introduction of fixed point types in ISO N1169, this method also
3391 // accepts fixed point types and returns the corresponding unsigned type for
3392 // a given fixed point type.
3394
3395 // Per C99 6.2.5p6, for every signed integer type, there is a corresponding
3396 // unsigned integer type. This method takes an unsigned type, and returns the
3397 // corresponding signed integer type.
3398 // With the introduction of fixed point types in ISO N1169, this method also
3399 // accepts fixed point types and returns the corresponding signed type for
3400 // a given fixed point type.
3402
3403 // Per ISO N1169, this method accepts fixed point types and returns the
3404 // corresponding saturated type for a given fixed point type.
3406
3407 // Per ISO N1169, this method accepts fixed point types and returns the
3408 // corresponding non-saturated type for a given fixed point type.
3410
3411 // This method accepts fixed point types and returns the corresponding signed
3412 // type. Unlike getCorrespondingUnsignedType(), this only accepts unsigned
3413 // fixed point types because there are unsigned integer types like bool and
3414 // char8_t that don't have signed equivalents.
3416
3417 //===--------------------------------------------------------------------===//
3418 // Integer Values
3419 //===--------------------------------------------------------------------===//
3420
3421 /// Make an APSInt of the appropriate width and signedness for the
3422 /// given \p Value and integer \p Type.
3423 llvm::APSInt MakeIntValue(uint64_t Value, QualType Type) const {
3424 // If Type is a signed integer type larger than 64 bits, we need to be sure
3425 // to sign extend Res appropriately.
3426 llvm::APSInt Res(64, !Type->isSignedIntegerOrEnumerationType());
3427 Res = Value;
3428 unsigned Width = getIntWidth(Type);
3429 if (Width != Res.getBitWidth())
3430 return Res.extOrTrunc(Width);
3431 return Res;
3432 }
3433
3434 bool isSentinelNullExpr(const Expr *E);
3435
3436 /// Get the implementation of the ObjCInterfaceDecl \p D, or nullptr if
3437 /// none exists.
3439
3440 /// Get the implementation of the ObjCCategoryDecl \p D, or nullptr if
3441 /// none exists.
3443
3444 /// Return true if there is at least one \@implementation in the TU.
3446 return !ObjCImpls.empty();
3447 }
3448
3449 /// Set the implementation of ObjCInterfaceDecl.
3451 ObjCImplementationDecl *ImplD);
3452
3453 /// Set the implementation of ObjCCategoryDecl.
3455 ObjCCategoryImplDecl *ImplD);
3456
3457 /// Get the duplicate declaration of a ObjCMethod in the same
3458 /// interface, or null if none exists.
3459 const ObjCMethodDecl *
3461
3463 const ObjCMethodDecl *Redecl);
3464
3465 /// Returns the Objective-C interface that \p ND belongs to if it is
3466 /// an Objective-C method/property/ivar etc. that is part of an interface,
3467 /// otherwise returns null.
3469
3470 /// Set the copy initialization expression of a block var decl. \p CanThrow
3471 /// indicates whether the copy expression can throw or not.
3472 void setBlockVarCopyInit(const VarDecl* VD, Expr *CopyExpr, bool CanThrow);
3473
3474 /// Get the copy initialization expression of the VarDecl \p VD, or
3475 /// nullptr if none exists.
3477
3478 /// Allocate an uninitialized TypeSourceInfo.
3479 ///
3480 /// The caller should initialize the memory held by TypeSourceInfo using
3481 /// the TypeLoc wrappers.
3482 ///
3483 /// \param T the type that will be the basis for type source info. This type
3484 /// should refer to how the declarator was written in source code, not to
3485 /// what type semantic analysis resolved the declarator to.
3486 ///
3487 /// \param Size the size of the type info to create, or 0 if the size
3488 /// should be calculated based on the type.
3489 TypeSourceInfo *CreateTypeSourceInfo(QualType T, unsigned Size = 0) const;
3490
3491 /// Allocate a TypeSourceInfo where all locations have been
3492 /// initialized to a given location, which defaults to the empty
3493 /// location.
3496 SourceLocation Loc = SourceLocation()) const;
3497
3498 /// Add a deallocation callback that will be invoked when the
3499 /// ASTContext is destroyed.
3500 ///
3501 /// \param Callback A callback function that will be invoked on destruction.
3502 ///
3503 /// \param Data Pointer data that will be provided to the callback function
3504 /// when it is called.
3505 void AddDeallocation(void (*Callback)(void *), void *Data) const;
3506
3507 /// If T isn't trivially destructible, calls AddDeallocation to register it
3508 /// for destruction.
3509 template <typename T> void addDestruction(T *Ptr) const {
3510 if (!std::is_trivially_destructible<T>::value) {
3511 auto DestroyPtr = [](void *V) { static_cast<T *>(V)->~T(); };
3512 AddDeallocation(DestroyPtr, Ptr);
3513 }
3514 }
3515
3518
3519 /// Determines if the decl can be CodeGen'ed or deserialized from PCH
3520 /// lazily, only when used; this is only relevant for function or file scoped
3521 /// var definitions.
3522 ///
3523 /// \returns true if the function/var must be CodeGen'ed/deserialized even if
3524 /// it is not used.
3525 bool DeclMustBeEmitted(const Decl *D);
3526
3527 /// Visits all versions of a multiversioned function with the passed
3528 /// predicate.
3530 const FunctionDecl *FD,
3531 llvm::function_ref<void(FunctionDecl *)> Pred) const;
3532
3533 const CXXConstructorDecl *
3535
3537 CXXConstructorDecl *CD);
3538
3540
3542
3544
3546
3547 void setManglingNumber(const NamedDecl *ND, unsigned Number);
3548 unsigned getManglingNumber(const NamedDecl *ND,
3549 bool ForAuxTarget = false) const;
3550
3551 void setStaticLocalNumber(const VarDecl *VD, unsigned Number);
3552 unsigned getStaticLocalNumber(const VarDecl *VD) const;
3553
3555 return !TypeAwareOperatorNewAndDeletes.empty();
3556 }
3557 void setIsDestroyingOperatorDelete(const FunctionDecl *FD, bool IsDestroying);
3558 bool isDestroyingOperatorDelete(const FunctionDecl *FD) const;
3560 bool IsTypeAware);
3561 bool isTypeAwareOperatorNewOrDelete(const FunctionDecl *FD) const;
3562
3564
3566 FunctionDecl *OperatorDelete,
3567 OperatorDeleteKind K) const;
3569 OperatorDeleteKind K) const;
3571 OperatorDeleteKind K) const;
3574
3575 /// Retrieve the context for computing mangling numbers in the given
3576 /// DeclContext.
3580 const Decl *D);
3581
3582 std::unique_ptr<MangleNumberingContext> createMangleNumberingContext() const;
3583
3584 /// Used by ParmVarDecl to store on the side the
3585 /// index of the parameter when it exceeds the size of the normal bitfield.
3586 void setParameterIndex(const ParmVarDecl *D, unsigned index);
3587
3588 /// Used by ParmVarDecl to retrieve on the side the
3589 /// index of the parameter when it exceeds the size of the normal bitfield.
3590 unsigned getParameterIndex(const ParmVarDecl *D) const;
3591
3592 /// Return a string representing the human readable name for the specified
3593 /// function declaration or file name. Used by SourceLocExpr and
3594 /// PredefinedExpr to cache evaluated results.
3596
3597 /// Return the next version number to be used for a string literal evaluated
3598 /// as part of constant evaluation.
3599 unsigned getNextStringLiteralVersion() { return NextStringLiteralVersion++; }
3600
3601 /// Return a declaration for the global GUID object representing the given
3602 /// GUID value.
3604
3605 /// Return a declaration for a uniquified anonymous global constant
3606 /// corresponding to a given APValue.
3609
3610 /// Return the template parameter object of the given type with the given
3611 /// value.
3613 const APValue &V) const;
3614
3615 /// Parses the target attributes passed in, and returns only the ones that are
3616 /// valid feature names.
3617 ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD) const;
3618
3619 void getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap,
3620 const FunctionDecl *) const;
3621 void getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap,
3622 GlobalDecl GD) const;
3623
3624 /// Generates and stores SYCL kernel metadata for the provided
3625 /// SYCL kernel entry point function. The provided function must have
3626 /// an attached sycl_kernel_entry_point attribute that specifies a unique
3627 /// type for the name of a SYCL kernel. Callers are required to detect
3628 /// conflicting SYCL kernel names and issue a diagnostic prior to calling
3629 /// this function.
3631
3632 /// Given a type used as a SYCL kernel name, returns a reference to the
3633 /// metadata generated from the corresponding SYCL kernel entry point.
3634 /// Aborts if the provided type is not a registered SYCL kernel name.
3636
3637 /// Returns a pointer to the metadata generated from the corresponding
3638 /// SYCLkernel entry point if the provided type corresponds to a registered
3639 /// SYCL kernel name. Returns a null pointer otherwise.
3641
3642 //===--------------------------------------------------------------------===//
3643 // Statistics
3644 //===--------------------------------------------------------------------===//
3645
3646 /// The number of implicitly-declared default constructors.
3648
3649 /// The number of implicitly-declared default constructors for
3650 /// which declarations were built.
3652
3653 /// The number of implicitly-declared copy constructors.
3655
3656 /// The number of implicitly-declared copy constructors for
3657 /// which declarations were built.
3659
3660 /// The number of implicitly-declared move constructors.
3662
3663 /// The number of implicitly-declared move constructors for
3664 /// which declarations were built.
3666
3667 /// The number of implicitly-declared copy assignment operators.
3669
3670 /// The number of implicitly-declared copy assignment operators for
3671 /// which declarations were built.
3673
3674 /// The number of implicitly-declared move assignment operators.
3676
3677 /// The number of implicitly-declared move assignment operators for
3678 /// which declarations were built.
3680
3681 /// The number of implicitly-declared destructors.
3683
3684 /// The number of implicitly-declared destructors for which
3685 /// declarations were built.
3687
3688public:
3689 /// Initialize built-in types.
3690 ///
3691 /// This routine may only be invoked once for a given ASTContext object.
3692 /// It is normally invoked after ASTContext construction.
3693 ///
3694 /// \param Target The target
3695 void InitBuiltinTypes(const TargetInfo &Target,
3696 const TargetInfo *AuxTarget = nullptr);
3697
3698private:
3699 void InitBuiltinType(CanQualType &R, BuiltinType::Kind K);
3700
3701 class ObjCEncOptions {
3702 unsigned Bits;
3703
3704 ObjCEncOptions(unsigned Bits) : Bits(Bits) {}
3705
3706 public:
3707 ObjCEncOptions() : Bits(0) {}
3708
3709#define OPT_LIST(V) \
3710 V(ExpandPointedToStructures, 0) \
3711 V(ExpandStructures, 1) \
3712 V(IsOutermostType, 2) \
3713 V(EncodingProperty, 3) \
3714 V(IsStructField, 4) \
3715 V(EncodeBlockParameters, 5) \
3716 V(EncodeClassNames, 6) \
3717
3718#define V(N,I) ObjCEncOptions& set##N() { Bits |= 1 << I; return *this; }
3719OPT_LIST(V)
3720#undef V
3721
3722#define V(N,I) bool N() const { return Bits & 1 << I; }
3723OPT_LIST(V)
3724#undef V
3725
3726#undef OPT_LIST
3727
3728 [[nodiscard]] ObjCEncOptions keepingOnly(ObjCEncOptions Mask) const {
3729 return Bits & Mask.Bits;
3730 }
3731
3732 [[nodiscard]] ObjCEncOptions forComponentType() const {
3733 ObjCEncOptions Mask = ObjCEncOptions()
3734 .setIsOutermostType()
3735 .setIsStructField();
3736 return Bits & ~Mask.Bits;
3737 }
3738 };
3739
3740 // Return the Objective-C type encoding for a given type.
3741 void getObjCEncodingForTypeImpl(QualType t, std::string &S,
3742 ObjCEncOptions Options,
3743 const FieldDecl *Field,
3744 QualType *NotEncodedT = nullptr) const;
3745
3746 // Adds the encoding of the structure's members.
3747 void getObjCEncodingForStructureImpl(RecordDecl *RD, std::string &S,
3748 const FieldDecl *Field,
3749 bool includeVBases = true,
3750 QualType *NotEncodedT=nullptr) const;
3751
3752public:
3753 // Adds the encoding of a method parameter or return type.
3755 QualType T, std::string& S,
3756 bool Extended) const;
3757
3758 /// Returns true if this is an inline-initialized static data member
3759 /// which is treated as a definition for MSVC compatibility.
3760 bool isMSStaticDataMemberInlineDefinition(const VarDecl *VD) const;
3761
3763 /// Not an inline variable.
3764 None,
3765
3766 /// Weak definition of inline variable.
3768
3769 /// Weak for now, might become strong later in this TU.
3771
3772 /// Strong definition.
3774 };
3775
3776 /// Determine whether a definition of this inline variable should
3777 /// be treated as a weak or strong definition. For compatibility with
3778 /// C++14 and before, for a constexpr static data member, if there is an
3779 /// out-of-line declaration of the member, we may promote it from weak to
3780 /// strong.
3783
3784private:
3786 friend class DeclContext;
3787
3788 const ASTRecordLayout &getObjCLayout(const ObjCInterfaceDecl *D) const;
3789
3790 /// A set of deallocations that should be performed when the
3791 /// ASTContext is destroyed.
3792 // FIXME: We really should have a better mechanism in the ASTContext to
3793 // manage running destructors for types which do variable sized allocation
3794 // within the AST. In some places we thread the AST bump pointer allocator
3795 // into the datastructures which avoids this mess during deallocation but is
3796 // wasteful of memory, and here we require a lot of error prone book keeping
3797 // in order to track and run destructors while we're tearing things down.
3798 using DeallocationFunctionsAndArguments =
3799 llvm::SmallVector<std::pair<void (*)(void *), void *>, 16>;
3800 mutable DeallocationFunctionsAndArguments Deallocations;
3801
3802 // FIXME: This currently contains the set of StoredDeclMaps used
3803 // by DeclContext objects. This probably should not be in ASTContext,
3804 // but we include it here so that ASTContext can quickly deallocate them.
3805 llvm::PointerIntPair<StoredDeclsMap *, 1> LastSDM;
3806
3807 std::vector<Decl *> TraversalScope;
3808
3809 std::unique_ptr<VTableContextBase> VTContext;
3810
3811 void ReleaseDeclContextMaps();
3812
3813public:
3814 enum PragmaSectionFlag : unsigned {
3821 PSF_Invalid = 0x80000000U,
3822 };
3823
3835
3836 llvm::StringMap<SectionInfo> SectionInfos;
3837
3838 /// Return a new OMPTraitInfo object owned by this context.
3840
3841 /// Whether a C++ static variable or CUDA/HIP kernel may be externalized.
3842 bool mayExternalize(const Decl *D) const;
3843
3844 /// Whether a C++ static variable or CUDA/HIP kernel should be externalized.
3845 bool shouldExternalize(const Decl *D) const;
3846
3847 /// Resolve the root record to be used to derive the vtable pointer
3848 /// authentication policy for the specified record.
3849 const CXXRecordDecl *
3850 baseForVTableAuthentication(const CXXRecordDecl *ThisClass) const;
3851
3852 bool useAbbreviatedThunkName(GlobalDecl VirtualMethodDecl,
3853 StringRef MangledName);
3854
3855 StringRef getCUIDHash() const;
3856
3857 /// Returns a list of PFP fields for the given type, including subfields in
3858 /// bases or other fields, except for fields contained within fields of union
3859 /// type.
3860 std::vector<PFPField> findPFPFields(QualType Ty) const;
3861
3862 bool hasPFPFields(QualType Ty) const;
3863 bool isPFPField(const FieldDecl *Field) const;
3864
3865 /// Returns whether this record's PFP fields (if any) are trivially
3866 /// copyable (i.e. may be memcpy'd). This may also return true if the
3867 /// record does not have any PFP fields, so it may be necessary for the caller
3868 /// to check for PFP fields, e.g. by calling hasPFPFields().
3869 bool arePFPFieldsTriviallyCopyable(const RecordDecl *RD) const;
3870
3871 llvm::SetVector<const FieldDecl *> PFPFieldsWithEvaluatedOffset;
3874
3875private:
3876 /// All OMPTraitInfo objects live in this collection, one per
3877 /// `pragma omp [begin] declare variant` directive.
3878 SmallVector<std::unique_ptr<OMPTraitInfo>, 4> OMPTraitInfoVector;
3879
3880 llvm::DenseMap<GlobalDecl, llvm::StringSet<>> ThunksToBeAbbreviated;
3881};
3882
3883/// Insertion operator for diagnostics.
3885 const ASTContext::SectionInfo &Section);
3886
3887/// Utility function for constructing a nullary selector.
3888inline Selector GetNullarySelector(StringRef name, ASTContext &Ctx) {
3889 const IdentifierInfo *II = &Ctx.Idents.get(name);
3890 return Ctx.Selectors.getSelector(0, &II);
3891}
3892
3893/// Utility function for constructing an unary selector.
3894inline Selector GetUnarySelector(StringRef name, ASTContext &Ctx) {
3895 const IdentifierInfo *II = &Ctx.Idents.get(name);
3896 return Ctx.Selectors.getSelector(1, &II);
3897}
3898
3899} // namespace clang
3900
3901// operator new and delete aren't allowed inside namespaces.
3902
3903/// Placement new for using the ASTContext's allocator.
3904///
3905/// This placement form of operator new uses the ASTContext's allocator for
3906/// obtaining memory.
3907///
3908/// IMPORTANT: These are also declared in clang/AST/ASTContextAllocate.h!
3909/// Any changes here need to also be made there.
3910///
3911/// We intentionally avoid using a nothrow specification here so that the calls
3912/// to this operator will not perform a null check on the result -- the
3913/// underlying allocator never returns null pointers.
3914///
3915/// Usage looks like this (assuming there's an ASTContext 'Context' in scope):
3916/// @code
3917/// // Default alignment (8)
3918/// IntegerLiteral *Ex = new (Context) IntegerLiteral(arguments);
3919/// // Specific alignment
3920/// IntegerLiteral *Ex2 = new (Context, 4) IntegerLiteral(arguments);
3921/// @endcode
3922/// Memory allocated through this placement new operator does not need to be
3923/// explicitly freed, as ASTContext will free all of this memory when it gets
3924/// destroyed. Please note that you cannot use delete on the pointer.
3925///
3926/// @param Bytes The number of bytes to allocate. Calculated by the compiler.
3927/// @param C The ASTContext that provides the allocator.
3928/// @param Alignment The alignment of the allocated memory (if the underlying
3929/// allocator supports it).
3930/// @return The allocated memory. Could be nullptr.
3931inline void *operator new(size_t Bytes, const clang::ASTContext &C,
3932 size_t Alignment /* = 8 */) {
3933 return C.Allocate(Bytes, Alignment);
3934}
3935
3936/// Placement delete companion to the new above.
3937///
3938/// This operator is just a companion to the new above. There is no way of
3939/// invoking it directly; see the new operator for more details. This operator
3940/// is called implicitly by the compiler if a placement new expression using
3941/// the ASTContext throws in the object constructor.
3942inline void operator delete(void *Ptr, const clang::ASTContext &C, size_t) {
3943 C.Deallocate(Ptr);
3944}
3945
3946/// This placement form of operator new[] uses the ASTContext's allocator for
3947/// obtaining memory.
3948///
3949/// We intentionally avoid using a nothrow specification here so that the calls
3950/// to this operator will not perform a null check on the result -- the
3951/// underlying allocator never returns null pointers.
3952///
3953/// Usage looks like this (assuming there's an ASTContext 'Context' in scope):
3954/// @code
3955/// // Default alignment (8)
3956/// char *data = new (Context) char[10];
3957/// // Specific alignment
3958/// char *data = new (Context, 4) char[10];
3959/// @endcode
3960/// Memory allocated through this placement new[] operator does not need to be
3961/// explicitly freed, as ASTContext will free all of this memory when it gets
3962/// destroyed. Please note that you cannot use delete on the pointer.
3963///
3964/// @param Bytes The number of bytes to allocate. Calculated by the compiler.
3965/// @param C The ASTContext that provides the allocator.
3966/// @param Alignment The alignment of the allocated memory (if the underlying
3967/// allocator supports it).
3968/// @return The allocated memory. Could be nullptr.
3969inline void *operator new[](size_t Bytes, const clang::ASTContext& C,
3970 size_t Alignment /* = 8 */) {
3971 return C.Allocate(Bytes, Alignment);
3972}
3973
3974/// Placement delete[] companion to the new[] above.
3975///
3976/// This operator is just a companion to the new[] above. There is no way of
3977/// invoking it directly; see the new[] operator for more details. This operator
3978/// is called implicitly by the compiler if a placement new[] expression using
3979/// the ASTContext throws in the object constructor.
3980inline void operator delete[](void *Ptr, const clang::ASTContext &C, size_t) {
3981 C.Deallocate(Ptr);
3982}
3983
3984/// Create the representation of a LazyGenerationalUpdatePtr.
3985template <typename Owner, typename T,
3986 void (clang::ExternalASTSource::*Update)(Owner)>
3989 const clang::ASTContext &Ctx, T Value) {
3990 // Note, this is implemented here so that ExternalASTSource.h doesn't need to
3991 // include ASTContext.h. We explicitly instantiate it for all relevant types
3992 // in ASTContext.cpp.
3993 if (auto *Source = Ctx.getExternalSource())
3994 return new (Ctx) LazyData(Source, Value);
3995 return Value;
3996}
3997template <> struct llvm::DenseMapInfo<llvm::FoldingSetNodeID> {
3998 static FoldingSetNodeID getEmptyKey() { return FoldingSetNodeID{}; }
3999
4000 static FoldingSetNodeID getTombstoneKey() {
4001 FoldingSetNodeID ID;
4002 for (size_t I = 0; I < sizeof(ID) / sizeof(unsigned); ++I) {
4003 ID.AddInteger(std::numeric_limits<unsigned>::max());
4004 }
4005 return ID;
4006 }
4007
4008 static unsigned getHashValue(const FoldingSetNodeID &Val) {
4009 return Val.ComputeHash();
4010 }
4011
4012 static bool isEqual(const FoldingSetNodeID &LHS,
4013 const FoldingSetNodeID &RHS) {
4014 return LHS == RHS;
4015 }
4016};
4017
4018#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:2848
clang::CharUnits operator*(clang::CharUnits::QuantityType Scale, const clang::CharUnits &CU)
Definition CharUnits.h:225
#define X(type, name)
Definition Value.h:97
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
#define SM(sm)
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:227
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:122
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:227
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:866
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.
LangAS getOpenCLTypeAddrSpace(const Type *T) const
Get address space for OpenCL type.
friend class ASTWriter
Definition ASTContext.h:581
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
void InitBuiltinTypes(const TargetInfo &Target, const TargetInfo *AuxTarget=nullptr)
Initialize built-in types.
ParentMapContext & getParentMapContext()
Returns the dynamic AST node parent map context.
QualType getParenType(QualType NamedType) const
size_t getSideTableAllocatedMemory() const
Return the total memory used for various side tables.
MemberSpecializationInfo * getInstantiatedFromStaticDataMember(const VarDecl *Var)
If this variable is an instantiated static data member of a class template specialization,...
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
CanQualType ARCUnbridgedCastTy
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
const SmallVectorImpl< Type * > & getTypes() const
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
Definition ASTContext.h:980
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...
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:906
DeclListNode * AllocateDeclListNode(clang::NamedDecl *ND)
Allocates a DeclListNode or returns one from the ListNodeFreeList pool.
Definition ASTContext.h:895
bool isPFPField(const FieldDecl *Field) const
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 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:809
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:721
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
QualType getUnsignedPointerDiffType() const
Return the unique unsigned counterpart of "ptrdiff_t" integer type.
QualType getucontext_tType() const
Retrieve the C ucontext_t type.
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.
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.
QualType getRealTypeForBitwidth(unsigned DestWidth, FloatModeKind ExplicitType) const
getRealTypeForBitwidth - sets floating point QualTy according to specified bitwidth.
ArrayRef< Decl * > getTraversalScope() const
Definition ASTContext.h:851
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:810
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:584
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
Definition ASTContext.h:984
bool propertyTypesAreCompatible(QualType, QualType)
void setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst, UsingShadowDecl *Pattern)
CanQualType DoubleTy
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
Definition ASTContext.h:976
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...
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:885
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
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:805
Builtin::Context & BuiltinInfo
Definition ASTContext.h:807
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
Definition ASTContext.h:959
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:710
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:806
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.
Definition ASTContext.h:994
bool isSameDefaultTemplateArgument(const NamedDecl *X, const NamedDecl *Y) const
Determine whether two default template arguments are similar enough that they may be used in declarat...
QualType applyObjCProtocolQualifiers(QualType type, ArrayRef< ObjCProtocolDecl * > protocols, bool &hasError, bool allowOnPointerType=false) const
Apply Objective-C protocol qualifiers to the given type.
QualType getMacroQualifiedType(QualType UnderlyingTy, const IdentifierInfo *MacroII) const
QualType removePtrSizeAddrSpace(QualType T) const
Remove the existing address space on the type if it is a pointer size address space and return the ty...
bool areLaxCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given vector types are lax-compatible RISC-V vector types as defined by -flax-vect...
void setObjCSuperType(QualType ST)
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:920
static bool hasSameType(const Type *T1, const Type *T2)
CanQualType Ibm128Ty
void setASTMutationListener(ASTMutationListener *Listener)
Attach an AST mutation listener to the AST context.
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:927
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:580
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 getAutoType(DeducedKind DK, QualType DeducedAsType, AutoTypeKeyword Keyword, TemplateDecl *TypeConstraintConcept=nullptr, ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
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 cacheRawCommentForDecl(const Decl &OriginalD, const RawComment &Comment) const
Attaches Comment to OriginalD and to its redeclaration chain and removes the redeclaration chain from...
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:875
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
friend class ASTDeclReader
Definition ASTContext.h:579
QualType getCFConstantStringType() const
Return the C structure type used to represent constant CFStrings.
void eraseDeclAttrs(const Decl *D)
Erase the attributes corresponding to the given declaration.
const NoSanitizeList & getNoSanitizeList() const
Definition ASTContext.h:969
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
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:925
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:583
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:808
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.
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.
Definition ASTContext.h:997
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.
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:228
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:811
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:867
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:858
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)
llvm::FixedPointSemantics getFixedPointSemantics(QualType Ty) const
CanQualType SatUnsignedShortAccumTy
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false, bool IsConditionalOperator=false)
const RawComment * getRawCommentForAnyRedecl(const Decl *D, const Decl **OriginalDecl=nullptr) const
Return the documentation comment attached to a given declaration.
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:575
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)
llvm::DenseMap< const Decl *, const RawComment * > DeclRawComments
Mapping from declaration to directly attached comment.
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:879
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...
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:913
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
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.
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
RawComment * getRawCommentForDeclNoCache(const Decl *D) const
Return the documentation comment attached to a given declaration, without looking into cache.
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()
DiagnosticsEngine & getDiagnostics() const
llvm::StringRef backupStr(llvm::StringRef S) const
Definition ASTContext.h:887
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
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:924
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.
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
friend class DeclarationNameTable
void getFunctionFeatureMap(llvm::StringMap< bool > &FeatureMap, const FunctionDecl *) const
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
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.
uint64_t getConstantArrayElementCount(const ConstantArrayType *CA) const
Return number of constant array elements.
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.
uint64_t getArrayInitLoopExprElementCount(const ArrayInitLoopExpr *AILE) const
Return number of elements initialized in an ArrayInitLoopExpr.
unsigned getTargetAddressSpace(LangAS AS) const
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:882
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...
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
uint16_t getPointerAuthVTablePointerDiscriminator(const CXXRecordDecl *RD)
Return the "other" discriminator used for the pointer auth schema used for vtable pointers in instanc...
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
bool canonicalizeTemplateArguments(MutableArrayRef< TemplateArgument > Args) const
Canonicalize the given template argument list.
QualType getTypeOfExprType(Expr *E, TypeOfKind Kind) const
C23 feature and GCC extension.
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
Definition ASTContext.h:965
QualType getConstantMatrixType(QualType ElementType, unsigned NumRows, unsigned NumColumns) const
Return the unique reference to the matrix type of the specified element type and size.
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...
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:862
void AddDeallocation(void(*Callback)(void *), void *Data) const
Add a deallocation callback that will be invoked when the ASTContext is destroyed.
AttrVec & getDeclAttrs(const Decl *D)
Retrieve the attributes for the given declaration.
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
RawComment * getRawCommentForDeclNoCacheImpl(const Decl *D, const SourceLocation RepresentativeLocForDecl, const std::map< unsigned, RawComment * > &CommentsInFile) const
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)
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:5968
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition TypeBase.h:3784
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Definition Expr.h:6928
Attr - This represents one attribute.
Definition Attr.h:46
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition Expr.h:6672
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:3226
Holds information about both target-independent and target-specific builtins, allowing easy queries b...
Definition Builtins.h:236
Implements C++ ABI-specific semantic analysis functions.
Definition CXXABI.h:29
Represents a C++ constructor within a class.
Definition DeclCXX.h:2620
Represents a C++ destructor within a class.
Definition DeclCXX.h:2882
Represents a static or instance method of a struct/union/class.
Definition DeclCXX.h:2132
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.
CharUnits - 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:3822
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition DeclBase.h:1462
A list storing NamedDecls in the lookup tables.
Definition DeclBase.h:1342
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
The name of a declaration.
Represents a ValueDecl that came out of a declarator.
Definition Decl.h:780
Represents an array type in C++ whose size is a value-dependent expression.
Definition TypeBase.h:4073
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:233
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:3441
llvm::APSInt getInitVal() const
Definition Decl.h:3461
Represents an explicit instantiation of a template entity in source code.
This represents one expression.
Definition Expr.h:112
Declaration context for names declared as extern "C" in C++.
Definition Decl.h:247
Abstract interface for external sources of AST nodes.
Represents a member of a struct/union/class.
Definition Decl.h:3178
A SourceLocation and its associated SourceManager.
Represents a function declaration or definition.
Definition Decl.h:2018
Represents a prototype with parameter type info, e.g.
Definition TypeBase.h:5369
A class which abstracts out some details necessary for making a call.
Definition TypeBase.h:4676
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition TypeBase.h:4565
GlobalDecl - represents a global declaration.
Definition GlobalDecl.h:57
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:5071
Represents a C array with an unspecified size.
Definition TypeBase.h:3971
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:4403
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:301
This represents a decl that may have a name.
Definition Decl.h:274
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:2329
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
Definition DeclObjC.h:2545
ObjCContainerDecl - Represents a container for method declarations.
Definition DeclObjC.h:948
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition DeclObjC.h:2597
Represents an ObjC class declaration.
Definition DeclObjC.h:1154
ObjCIvarDecl - Represents an ObjC instance variable.
Definition DeclObjC.h:1952
ObjCMethodDecl - Represents an instance or class method declaration.
Definition DeclObjC.h:140
Represents a pointer to an Objective C object.
Definition TypeBase.h:8063
Represents one property declaration in an Objective-C interface.
Definition DeclObjC.h:731
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition DeclObjC.h:2805
Represents an Objective-C protocol declaration.
Definition DeclObjC.h:2084
Represents the declaration of an Objective-C type parameter.
Definition DeclObjC.h:578
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type,...
Definition Expr.h:2530
Represents a parameter to a function.
Definition Decl.h:1808
Pointer-authentication qualifiers.
Definition TypeBase.h:152
PredefinedSugarKind Kind
Definition TypeBase.h:8356
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
A (possibly-)qualified type.
Definition TypeBase.h:937
QualType withFastQualifiers(unsigned TQs) const
Definition TypeBase.h:1216
PointerAuthQualifier getPointerAuth() const
Definition TypeBase.h:1468
QualType withConst() const
Definition TypeBase.h:1174
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition TypeBase.h:8445
A qualifier set is used to build a set of qualifiers.
Definition TypeBase.h:8385
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
Definition TypeBase.h:8392
The collection of all-type qualifiers we support.
Definition TypeBase.h:331
@ OCL_None
There is no lifetime qualification on this type.
Definition TypeBase.h:350
void removeObjCLifetime()
Definition TypeBase.h:551
bool hasNonFastQualifiers() const
Return true if the set contains any qualifiers which require an ExtQuals node to be allocated.
Definition TypeBase.h:638
unsigned getFastQualifiers() const
Definition TypeBase.h:619
static Qualifiers fromCVRMask(unsigned CVR)
Definition TypeBase.h:435
void setPointerAuth(PointerAuthQualifier Q)
Definition TypeBase.h:606
void addObjCLifetime(ObjCLifetime type)
Definition TypeBase.h:552
This class represents all comments included in the translation unit, sorted in order of appearance in...
Represents a struct/union/class.
Definition Decl.h:4343
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
Definition Decl.h:5348
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:1802
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3735
TagTypeKind TagKind
Definition Decl.h:3740
Kind
The basic C++ ABI kind.
Exposes information about the current target.
Definition TargetInfo.h:227
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.
The top declaration context.
Definition Decl.h:105
static TranslationUnitDecl * Create(ASTContext &C)
Definition Decl.cpp:5484
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Definition Decl.h:3706
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Definition ASTConcept.h:227
Represents a declaration of a type.
Definition Decl.h:3531
A container of type source information.
Definition TypeBase.h:8416
The base class of the type hierarchy.
Definition TypeBase.h:1875
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:2661
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
Definition Type.cpp:2289
bool isObjCNSObjectType() const
Definition Type.cpp:5405
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition TypeBase.h:2844
QualType getCanonicalTypeInternal() const
Definition TypeBase.h:3181
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
Definition TypeBase.h:9191
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
Definition Type.cpp:2527
NullabilityKindOrNone getNullability() const
Determine the nullability of the given type.
Definition Type.cpp:5148
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Definition Decl.h:3685
Base class for declarations which introduce a typedef-name.
Definition Decl.h:3580
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition Expr.h:2247
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
Definition DeclCXX.h:4460
The iterator over UnresolvedSets.
Represents the dependent type named by a dependently-scoped typename using declaration,...
Definition TypeBase.h:6085
Represents a dependent using declaration which was marked with typename.
Definition DeclCXX.h:4042
Represents a C++ using-enum-declaration.
Definition DeclCXX.h:3797
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition DeclCXX.h:3404
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:712
Represents a variable declaration or definition.
Definition Decl.h:924
Declaration of a variable template.
Represents a C array with a specified size that is not an integer-constant-expression.
Definition TypeBase.h:4028
Represents a GCC generic vector type.
Definition TypeBase.h:4237
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:1104
Holds all information required to evaluate constexpr code in a module.
Definition Context.h:47
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:56
The JSON file list parser is used to communicate input to InstallAPI.
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:1834
bool isTargetAddressSpace(LangAS AS)
OpenCLTypeKind
OpenCL type kinds.
Definition TargetInfo.h:213
NullabilityKind
Describes the nullability of a particular type.
Definition Specifiers.h:349
@ Nullable
Values of this type can be null.
Definition Specifiers.h:353
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
Definition Specifiers.h:358
@ NonNull
Values of this type can never be null.
Definition Specifiers.h:351
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
Definition Parser.h:61
TypeOfKind
The kind of 'typeof' expression we're after.
Definition TypeBase.h:918
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:905
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition TypeBase.h:3781
OptionalUnsigned< unsigned > UnsignedOrNone
@ Template
We are parsing a template declaration.
Definition Parser.h:81
Selector GetNullarySelector(StringRef name, ASTContext &Ctx)
Utility function for constructing a nullary selector.
@ Class
The "class" keyword.
Definition TypeBase.h:6004
BuiltinTemplateKind
Kinds of BuiltinTemplateDecl.
Definition Builtins.h:491
@ Keyword
The name has been typo-corrected to a keyword.
Definition Sema.h:562
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:1807
FloatModeKind
Definition TargetInfo.h:75
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
Definition ASTContext.h:151
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:189
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition Specifiers.h:279
U cast(CodeGen::Address addr)
Definition Address.h:327
AlignRequirementKind
Definition ASTContext.h:178
@ None
The alignment was not explicit in code.
Definition ASTContext.h:180
@ RequiredByEnum
The alignment comes from an alignment attribute on a enum type.
Definition ASTContext.h:189
@ RequiredByTypedef
The alignment comes from an alignment attribute on a typedef.
Definition ASTContext.h:183
@ RequiredByRecord
The alignment comes from an alignment attribute on a record type.
Definition ASTContext.h:186
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition TypeBase.h:5968
@ None
No keyword precedes the qualified type name.
Definition TypeBase.h:5989
@ Other
Other implicit parameter.
Definition Decl.h:1763
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
BuiltinVectorTypeInfo(QualType ElementType, llvm::ElementCount EC, unsigned NumVectors)
CUDAConstantEvalContextRAII(ASTContext &Ctx_, bool NoWrongSidedVars)
Definition ASTContext.h:823
BuiltinVectorTypeInfo(QualType ElementType, llvm::ElementCount EC, unsigned NumVectors)
CUDAConstantEvalContextRAII(ASTContext &Ctx_, bool NoWrongSidedVars)
Definition ASTContext.h:823
bool NoWrongSidedVars
Do not allow wrong-sided variables in constant expressions.
Definition ASTContext.h:818
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:6718
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:5426
Extra information about a function prototype.
Definition TypeBase.h:5454
A cache of the value of this pointer, in the most recent generation in which we queried it.
static ValueType makeValue(const ASTContext &Ctx, T Value)
Create the representation of a LazyGenerationalUpdatePtr.
llvm::PointerUnion< T, LazyData * > ValueType
Parts of a decomposed MSGuidDecl.
Definition DeclCXX.h:4378
FieldDecl * Field
Definition ASTContext.h:222
CharUnits Offset
Definition ASTContext.h:221
Contains information gathered from parsing the contents of TargetAttr.
Definition TargetInfo.h:60
Describes how types, statements, expressions, and declarations should be printed.
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
Definition TypeBase.h:870
const Type * Ty
The locally-unqualified type.
Definition TypeBase.h:872
Qualifiers Quals
The local qualifiers.
Definition TypeBase.h:875
AlignRequirementKind AlignRequirement
Definition ASTContext.h:209
TypeInfoChars(CharUnits Width, CharUnits Align, AlignRequirementKind AlignRequirement)
Definition ASTContext.h:212
bool isAlignRequired()
Definition ASTContext.h:201
AlignRequirementKind AlignRequirement
Definition ASTContext.h:195
TypeInfo(uint64_t Width, unsigned Align, AlignRequirementKind AlignRequirement)
Definition ASTContext.h:198
static ScalableVecTyKey getTombstoneKey()
Definition ASTContext.h:74
static ScalableVecTyKey getEmptyKey()
Definition ASTContext.h:71
static bool isEqual(const ScalableVecTyKey &LHS, const ScalableVecTyKey &RHS)
Definition ASTContext.h:81
static unsigned getHashValue(const ScalableVecTyKey &Val)
Definition ASTContext.h:77
static bool isEqual(const FoldingSetNodeID &LHS, const FoldingSetNodeID &RHS)
static FoldingSetNodeID getTombstoneKey()
static unsigned getHashValue(const FoldingSetNodeID &Val)
clang::QualType EltTy
Definition ASTContext.h:58
bool operator==(const ScalableVecTyKey &RHS) const
Definition ASTContext.h:62