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