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