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