clang 20.0.0git
ASTContext.h
Go to the documentation of this file.
1//===- ASTContext.h - Context to hold long-lived AST nodes ------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9/// \file
10/// Defines the clang::ASTContext interface.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_AST_ASTCONTEXT_H
15#define LLVM_CLANG_AST_ASTCONTEXT_H
16
17#include "clang/AST/ASTFwd.h"
21#include "clang/AST/Decl.h"
28#include "clang/Basic/LLVM.h"
31#include "llvm/ADT/DenseMap.h"
32#include "llvm/ADT/DenseSet.h"
33#include "llvm/ADT/FoldingSet.h"
34#include "llvm/ADT/IntrusiveRefCntPtr.h"
35#include "llvm/ADT/MapVector.h"
36#include "llvm/ADT/PointerIntPair.h"
37#include "llvm/ADT/PointerUnion.h"
38#include "llvm/ADT/SetVector.h"
39#include "llvm/ADT/SmallVector.h"
40#include "llvm/ADT/StringMap.h"
41#include "llvm/ADT/StringRef.h"
42#include "llvm/ADT/StringSet.h"
43#include "llvm/ADT/TinyPtrVector.h"
44#include "llvm/Support/TypeSize.h"
45#include <optional>
46
47namespace llvm {
48
49class APFixedPoint;
51struct fltSemantics;
52template <typename T, unsigned N> class SmallPtrSet;
53
54} // namespace llvm
55
56namespace clang {
57
58class APValue;
59class ASTMutationListener;
60class ASTRecordLayout;
61class AtomicExpr;
62class BlockExpr;
63struct BlockVarCopyInit;
64class BuiltinTemplateDecl;
65class CharUnits;
66class ConceptDecl;
67class CXXABI;
68class CXXConstructorDecl;
69class CXXMethodDecl;
70class CXXRecordDecl;
71class DiagnosticsEngine;
72class DynTypedNodeList;
73class Expr;
74enum class FloatModeKind;
75class GlobalDecl;
76class IdentifierTable;
77class LangOptions;
78class MangleContext;
79class MangleNumberingContext;
80class MemberSpecializationInfo;
81class Module;
82struct MSGuidDeclParts;
83class NestedNameSpecifier;
84class NoSanitizeList;
85class ObjCCategoryDecl;
86class ObjCCategoryImplDecl;
87class ObjCContainerDecl;
88class ObjCImplDecl;
89class ObjCImplementationDecl;
90class ObjCInterfaceDecl;
91class ObjCIvarDecl;
92class ObjCMethodDecl;
93class ObjCPropertyDecl;
94class ObjCPropertyImplDecl;
95class ObjCProtocolDecl;
96class ObjCTypeParamDecl;
97class OMPTraitInfo;
98class ParentMapContext;
99struct ParsedTargetAttr;
100class Preprocessor;
101class ProfileList;
102class StoredDeclsMap;
103class TargetAttr;
104class TargetInfo;
105class TemplateDecl;
106class TemplateParameterList;
107class TemplateTemplateParmDecl;
108class TemplateTypeParmDecl;
109class TypeConstraint;
110class UnresolvedSetIterator;
111class UsingShadowDecl;
112class VarTemplateDecl;
113class VTableContextBase;
114class XRayFunctionFilter;
115
116/// A simple array of base specifiers.
118
119namespace Builtin {
120
121class Context;
122
123} // namespace Builtin
124
126enum OpenCLTypeKind : uint8_t;
127
128namespace comments {
129
130class FullComment;
131
132} // namespace comments
133
134namespace interp {
135
136class Context;
137
138} // namespace interp
139
140namespace serialization {
141template <class> class AbstractTypeReader;
142} // namespace serialization
143
145 /// The alignment was not explicit in code.
146 None,
147
148 /// The alignment comes from an alignment attribute on a typedef.
150
151 /// The alignment comes from an alignment attribute on a record type.
153
154 /// The alignment comes from an alignment attribute on a enum type.
156};
157
158struct TypeInfo {
159 uint64_t Width = 0;
160 unsigned Align = 0;
162
164 TypeInfo(uint64_t Width, unsigned Align,
169 }
170};
171
176
183 }
184};
185
186/// Holds long-lived AST nodes (such as types and decls) that can be
187/// referred to throughout the semantic analysis of a file.
188class ASTContext : public RefCountedBase<ASTContext> {
190
191 mutable SmallVector<Type *, 0> Types;
192 mutable llvm::FoldingSet<ExtQuals> ExtQualNodes;
193 mutable llvm::FoldingSet<ComplexType> ComplexTypes;
194 mutable llvm::FoldingSet<PointerType> PointerTypes{GeneralTypesLog2InitSize};
195 mutable llvm::FoldingSet<AdjustedType> AdjustedTypes;
196 mutable llvm::FoldingSet<BlockPointerType> BlockPointerTypes;
197 mutable llvm::FoldingSet<LValueReferenceType> LValueReferenceTypes;
198 mutable llvm::FoldingSet<RValueReferenceType> RValueReferenceTypes;
199 mutable llvm::FoldingSet<MemberPointerType> MemberPointerTypes;
200 mutable llvm::ContextualFoldingSet<ConstantArrayType, ASTContext &>
201 ConstantArrayTypes;
202 mutable llvm::FoldingSet<IncompleteArrayType> IncompleteArrayTypes;
203 mutable std::vector<VariableArrayType*> VariableArrayTypes;
204 mutable llvm::ContextualFoldingSet<DependentSizedArrayType, ASTContext &>
205 DependentSizedArrayTypes;
206 mutable llvm::ContextualFoldingSet<DependentSizedExtVectorType, ASTContext &>
207 DependentSizedExtVectorTypes;
208 mutable llvm::ContextualFoldingSet<DependentAddressSpaceType, ASTContext &>
209 DependentAddressSpaceTypes;
210 mutable llvm::FoldingSet<VectorType> VectorTypes;
211 mutable llvm::ContextualFoldingSet<DependentVectorType, ASTContext &>
212 DependentVectorTypes;
213 mutable llvm::FoldingSet<ConstantMatrixType> MatrixTypes;
214 mutable llvm::ContextualFoldingSet<DependentSizedMatrixType, ASTContext &>
215 DependentSizedMatrixTypes;
216 mutable llvm::FoldingSet<FunctionNoProtoType> FunctionNoProtoTypes;
217 mutable llvm::ContextualFoldingSet<FunctionProtoType, ASTContext&>
218 FunctionProtoTypes;
219 mutable llvm::ContextualFoldingSet<DependentTypeOfExprType, ASTContext &>
220 DependentTypeOfExprTypes;
221 mutable llvm::ContextualFoldingSet<DependentDecltypeType, ASTContext &>
222 DependentDecltypeTypes;
223
224 mutable llvm::FoldingSet<PackIndexingType> DependentPackIndexingTypes;
225
226 mutable llvm::FoldingSet<TemplateTypeParmType> TemplateTypeParmTypes;
227 mutable llvm::FoldingSet<ObjCTypeParamType> ObjCTypeParamTypes;
228 mutable llvm::FoldingSet<SubstTemplateTypeParmType>
229 SubstTemplateTypeParmTypes;
230 mutable llvm::FoldingSet<SubstTemplateTypeParmPackType>
231 SubstTemplateTypeParmPackTypes;
232 mutable llvm::ContextualFoldingSet<TemplateSpecializationType, ASTContext&>
233 TemplateSpecializationTypes;
234 mutable llvm::FoldingSet<ParenType> ParenTypes{GeneralTypesLog2InitSize};
235 mutable llvm::FoldingSet<UsingType> UsingTypes;
236 mutable llvm::FoldingSet<TypedefType> TypedefTypes;
237 mutable llvm::FoldingSet<ElaboratedType> ElaboratedTypes{
238 GeneralTypesLog2InitSize};
239 mutable llvm::FoldingSet<DependentNameType> DependentNameTypes;
240 mutable llvm::ContextualFoldingSet<DependentTemplateSpecializationType,
241 ASTContext&>
242 DependentTemplateSpecializationTypes;
243 mutable llvm::FoldingSet<PackExpansionType> PackExpansionTypes;
244 mutable llvm::FoldingSet<ObjCObjectTypeImpl> ObjCObjectTypes;
245 mutable llvm::FoldingSet<ObjCObjectPointerType> ObjCObjectPointerTypes;
246 mutable llvm::FoldingSet<DependentUnaryTransformType>
247 DependentUnaryTransformTypes;
248 // An AutoType can have a dependency on another AutoType via its template
249 // arguments. Since both dependent and dependency are on the same set,
250 // we can end up in an infinite recursion when looking for a node if we used
251 // a `FoldingSet`, since both could end up in the same bucket.
252 mutable llvm::DenseMap<llvm::FoldingSetNodeID, AutoType *> AutoTypes;
253 mutable llvm::FoldingSet<DeducedTemplateSpecializationType>
254 DeducedTemplateSpecializationTypes;
255 mutable llvm::FoldingSet<AtomicType> AtomicTypes;
256 mutable llvm::FoldingSet<AttributedType> AttributedTypes;
257 mutable llvm::FoldingSet<PipeType> PipeTypes;
258 mutable llvm::FoldingSet<BitIntType> BitIntTypes;
259 mutable llvm::ContextualFoldingSet<DependentBitIntType, ASTContext &>
260 DependentBitIntTypes;
261 mutable llvm::FoldingSet<BTFTagAttributedType> BTFTagAttributedTypes;
262 llvm::FoldingSet<HLSLAttributedResourceType> HLSLAttributedResourceTypes;
263
264 mutable llvm::FoldingSet<CountAttributedType> CountAttributedTypes;
265
266 mutable llvm::FoldingSet<QualifiedTemplateName> QualifiedTemplateNames;
267 mutable llvm::FoldingSet<DependentTemplateName> DependentTemplateNames;
268 mutable llvm::FoldingSet<SubstTemplateTemplateParmStorage>
269 SubstTemplateTemplateParms;
270 mutable llvm::ContextualFoldingSet<SubstTemplateTemplateParmPackStorage,
271 ASTContext&>
272 SubstTemplateTemplateParmPacks;
273 mutable llvm::ContextualFoldingSet<DeducedTemplateStorage, ASTContext &>
274 DeducedTemplates;
275
276 mutable llvm::ContextualFoldingSet<ArrayParameterType, ASTContext &>
277 ArrayParameterTypes;
278
279 /// The set of nested name specifiers.
280 ///
281 /// This set is managed by the NestedNameSpecifier class.
282 mutable llvm::FoldingSet<NestedNameSpecifier> NestedNameSpecifiers;
283 mutable NestedNameSpecifier *GlobalNestedNameSpecifier = nullptr;
284
285 /// A cache mapping from RecordDecls to ASTRecordLayouts.
286 ///
287 /// This is lazily created. This is intentionally not serialized.
288 mutable llvm::DenseMap<const RecordDecl*, const ASTRecordLayout*>
289 ASTRecordLayouts;
290 mutable llvm::DenseMap<const ObjCContainerDecl*, const ASTRecordLayout*>
291 ObjCLayouts;
292
293 /// A cache from types to size and alignment information.
294 using TypeInfoMap = llvm::DenseMap<const Type *, struct TypeInfo>;
295 mutable TypeInfoMap MemoizedTypeInfo;
296
297 /// A cache from types to unadjusted alignment information. Only ARM and
298 /// AArch64 targets need this information, keeping it separate prevents
299 /// imposing overhead on TypeInfo size.
300 using UnadjustedAlignMap = llvm::DenseMap<const Type *, unsigned>;
301 mutable UnadjustedAlignMap MemoizedUnadjustedAlign;
302
303 /// A cache mapping from CXXRecordDecls to key functions.
304 llvm::DenseMap<const CXXRecordDecl*, LazyDeclPtr> KeyFunctions;
305
306 /// Mapping from ObjCContainers to their ObjCImplementations.
307 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*> ObjCImpls;
308
309 /// Mapping from ObjCMethod to its duplicate declaration in the same
310 /// interface.
311 llvm::DenseMap<const ObjCMethodDecl*,const ObjCMethodDecl*> ObjCMethodRedecls;
312
313 /// Mapping from __block VarDecls to BlockVarCopyInit.
314 llvm::DenseMap<const VarDecl *, BlockVarCopyInit> BlockVarCopyInits;
315
316 /// Mapping from GUIDs to the corresponding MSGuidDecl.
317 mutable llvm::FoldingSet<MSGuidDecl> MSGuidDecls;
318
319 /// Mapping from APValues to the corresponding UnnamedGlobalConstantDecl.
320 mutable llvm::FoldingSet<UnnamedGlobalConstantDecl>
321 UnnamedGlobalConstantDecls;
322
323 /// Mapping from APValues to the corresponding TemplateParamObjects.
324 mutable llvm::FoldingSet<TemplateParamObjectDecl> TemplateParamObjectDecls;
325
326 /// A cache mapping a string value to a StringLiteral object with the same
327 /// value.
328 ///
329 /// This is lazily created. This is intentionally not serialized.
330 mutable llvm::StringMap<StringLiteral *> StringLiteralCache;
331
332 /// The next string literal "version" to allocate during constant evaluation.
333 /// This is used to distinguish between repeated evaluations of the same
334 /// string literal.
335 ///
336 /// We don't need to serialize this because constants get re-evaluated in the
337 /// current file before they are compared locally.
338 unsigned NextStringLiteralVersion = 0;
339
340 /// MD5 hash of CUID. It is calculated when first used and cached by this
341 /// data member.
342 mutable std::string CUIDHash;
343
344 /// Representation of a "canonical" template template parameter that
345 /// is used in canonical template names.
346 class CanonicalTemplateTemplateParm : public llvm::FoldingSetNode {
347 TemplateTemplateParmDecl *Parm;
348
349 public:
350 CanonicalTemplateTemplateParm(TemplateTemplateParmDecl *Parm)
351 : Parm(Parm) {}
352
353 TemplateTemplateParmDecl *getParam() const { return Parm; }
354
355 void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &C) {
356 Profile(ID, C, Parm);
357 }
358
359 static void Profile(llvm::FoldingSetNodeID &ID,
360 const ASTContext &C,
361 TemplateTemplateParmDecl *Parm);
362 };
363 mutable llvm::ContextualFoldingSet<CanonicalTemplateTemplateParm,
364 const ASTContext&>
365 CanonTemplateTemplateParms;
366
367 TemplateTemplateParmDecl *
368 getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const;
369
370 /// The typedef for the __int128_t type.
371 mutable TypedefDecl *Int128Decl = nullptr;
372
373 /// The typedef for the __uint128_t type.
374 mutable TypedefDecl *UInt128Decl = nullptr;
375
376 /// The typedef for the target specific predefined
377 /// __builtin_va_list type.
378 mutable TypedefDecl *BuiltinVaListDecl = nullptr;
379
380 /// The typedef for the predefined \c __builtin_ms_va_list type.
381 mutable TypedefDecl *BuiltinMSVaListDecl = nullptr;
382
383 /// The typedef for the predefined \c id type.
384 mutable TypedefDecl *ObjCIdDecl = nullptr;
385
386 /// The typedef for the predefined \c SEL type.
387 mutable TypedefDecl *ObjCSelDecl = nullptr;
388
389 /// The typedef for the predefined \c Class type.
390 mutable TypedefDecl *ObjCClassDecl = nullptr;
391
392 /// The typedef for the predefined \c Protocol class in Objective-C.
393 mutable ObjCInterfaceDecl *ObjCProtocolClassDecl = nullptr;
394
395 /// The typedef for the predefined 'BOOL' type.
396 mutable TypedefDecl *BOOLDecl = nullptr;
397
398 // Typedefs which may be provided defining the structure of Objective-C
399 // pseudo-builtins
400 QualType ObjCIdRedefinitionType;
401 QualType ObjCClassRedefinitionType;
402 QualType ObjCSelRedefinitionType;
403
404 /// The identifier 'bool'.
405 mutable IdentifierInfo *BoolName = nullptr;
406
407 /// The identifier 'NSObject'.
408 mutable IdentifierInfo *NSObjectName = nullptr;
409
410 /// The identifier 'NSCopying'.
411 IdentifierInfo *NSCopyingName = nullptr;
412
413 /// The identifier '__make_integer_seq'.
414 mutable IdentifierInfo *MakeIntegerSeqName = nullptr;
415
416 /// The identifier '__type_pack_element'.
417 mutable IdentifierInfo *TypePackElementName = nullptr;
418
419 /// The identifier '__builtin_common_type'.
420 mutable IdentifierInfo *BuiltinCommonTypeName = nullptr;
421
422 QualType ObjCConstantStringType;
423 mutable RecordDecl *CFConstantStringTagDecl = nullptr;
424 mutable TypedefDecl *CFConstantStringTypeDecl = nullptr;
425
426 mutable QualType ObjCSuperType;
427
428 QualType ObjCNSStringType;
429
430 /// The typedef declaration for the Objective-C "instancetype" type.
431 TypedefDecl *ObjCInstanceTypeDecl = nullptr;
432
433 /// The type for the C FILE type.
434 TypeDecl *FILEDecl = nullptr;
435
436 /// The type for the C jmp_buf type.
437 TypeDecl *jmp_bufDecl = nullptr;
438
439 /// The type for the C sigjmp_buf type.
440 TypeDecl *sigjmp_bufDecl = nullptr;
441
442 /// The type for the C ucontext_t type.
443 TypeDecl *ucontext_tDecl = nullptr;
444
445 /// Type for the Block descriptor for Blocks CodeGen.
446 ///
447 /// Since this is only used for generation of debug info, it is not
448 /// serialized.
449 mutable RecordDecl *BlockDescriptorType = nullptr;
450
451 /// Type for the Block descriptor for Blocks CodeGen.
452 ///
453 /// Since this is only used for generation of debug info, it is not
454 /// serialized.
455 mutable RecordDecl *BlockDescriptorExtendedType = nullptr;
456
457 /// Declaration for the CUDA cudaConfigureCall function.
458 FunctionDecl *cudaConfigureCallDecl = nullptr;
459
460 /// Keeps track of all declaration attributes.
461 ///
462 /// Since so few decls have attrs, we keep them in a hash map instead of
463 /// wasting space in the Decl class.
464 llvm::DenseMap<const Decl*, AttrVec*> DeclAttrs;
465
466 /// A mapping from non-redeclarable declarations in modules that were
467 /// merged with other declarations to the canonical declaration that they were
468 /// merged into.
469 llvm::DenseMap<Decl*, Decl*> MergedDecls;
470
471 /// A mapping from a defining declaration to a list of modules (other
472 /// than the owning module of the declaration) that contain merged
473 /// definitions of that entity.
474 llvm::DenseMap<NamedDecl*, llvm::TinyPtrVector<Module*>> MergedDefModules;
475
476 /// Initializers for a module, in order. Each Decl will be either
477 /// something that has a semantic effect on startup (such as a variable with
478 /// a non-constant initializer), or an ImportDecl (which recursively triggers
479 /// initialization of another module).
480 struct PerModuleInitializers {
481 llvm::SmallVector<Decl*, 4> Initializers;
482 llvm::SmallVector<GlobalDeclID, 4> LazyInitializers;
483
484 void resolve(ASTContext &Ctx);
485 };
486 llvm::DenseMap<Module*, PerModuleInitializers*> ModuleInitializers;
487
488 /// This is the top-level (C++20) Named module we are building.
489 Module *CurrentCXXNamedModule = nullptr;
490
491 /// Help structures to decide whether two `const Module *` belongs
492 /// to the same conceptual module to avoid the expensive to string comparison
493 /// if possible.
494 ///
495 /// Not serialized intentionally.
496 llvm::StringMap<const Module *> PrimaryModuleNameMap;
497 llvm::DenseMap<const Module *, const Module *> SameModuleLookupSet;
498
499 static constexpr unsigned ConstantArrayTypesLog2InitSize = 8;
500 static constexpr unsigned GeneralTypesLog2InitSize = 9;
501 static constexpr unsigned FunctionProtoTypesLog2InitSize = 12;
502
503 ASTContext &this_() { return *this; }
504
505public:
506 /// A type synonym for the TemplateOrInstantiation mapping.
508 llvm::PointerUnion<VarTemplateDecl *, MemberSpecializationInfo *>;
509
510private:
511 friend class ASTDeclReader;
512 friend class ASTReader;
513 friend class ASTWriter;
514 template <class> friend class serialization::AbstractTypeReader;
515 friend class CXXRecordDecl;
516 friend class IncrementalParser;
517
518 /// A mapping to contain the template or declaration that
519 /// a variable declaration describes or was instantiated from,
520 /// respectively.
521 ///
522 /// For non-templates, this value will be NULL. For variable
523 /// declarations that describe a variable template, this will be a
524 /// pointer to a VarTemplateDecl. For static data members
525 /// of class template specializations, this will be the
526 /// MemberSpecializationInfo referring to the member variable that was
527 /// instantiated or specialized. Thus, the mapping will keep track of
528 /// the static data member templates from which static data members of
529 /// class template specializations were instantiated.
530 ///
531 /// Given the following example:
532 ///
533 /// \code
534 /// template<typename T>
535 /// struct X {
536 /// static T value;
537 /// };
538 ///
539 /// template<typename T>
540 /// T X<T>::value = T(17);
541 ///
542 /// int *x = &X<int>::value;
543 /// \endcode
544 ///
545 /// This mapping will contain an entry that maps from the VarDecl for
546 /// X<int>::value to the corresponding VarDecl for X<T>::value (within the
547 /// class template X) and will be marked TSK_ImplicitInstantiation.
548 llvm::DenseMap<const VarDecl *, TemplateOrSpecializationInfo>
549 TemplateOrInstantiation;
550
551 /// Keeps track of the declaration from which a using declaration was
552 /// created during instantiation.
553 ///
554 /// The source and target declarations are always a UsingDecl, an
555 /// UnresolvedUsingValueDecl, or an UnresolvedUsingTypenameDecl.
556 ///
557 /// For example:
558 /// \code
559 /// template<typename T>
560 /// struct A {
561 /// void f();
562 /// };
563 ///
564 /// template<typename T>
565 /// struct B : A<T> {
566 /// using A<T>::f;
567 /// };
568 ///
569 /// template struct B<int>;
570 /// \endcode
571 ///
572 /// This mapping will contain an entry that maps from the UsingDecl in
573 /// B<int> to the UnresolvedUsingDecl in B<T>.
574 llvm::DenseMap<NamedDecl *, NamedDecl *> InstantiatedFromUsingDecl;
575
576 /// Like InstantiatedFromUsingDecl, but for using-enum-declarations. Maps
577 /// from the instantiated using-enum to the templated decl from whence it
578 /// came.
579 /// Note that using-enum-declarations cannot be dependent and
580 /// thus will never be instantiated from an "unresolved"
581 /// version thereof (as with using-declarations), so each mapping is from
582 /// a (resolved) UsingEnumDecl to a (resolved) UsingEnumDecl.
583 llvm::DenseMap<UsingEnumDecl *, UsingEnumDecl *>
584 InstantiatedFromUsingEnumDecl;
585
586 /// Simlarly maps instantiated UsingShadowDecls to their origin.
587 llvm::DenseMap<UsingShadowDecl*, UsingShadowDecl*>
588 InstantiatedFromUsingShadowDecl;
589
590 llvm::DenseMap<FieldDecl *, FieldDecl *> InstantiatedFromUnnamedFieldDecl;
591
592 /// Mapping that stores the methods overridden by a given C++
593 /// member function.
594 ///
595 /// Since most C++ member functions aren't virtual and therefore
596 /// don't override anything, we store the overridden functions in
597 /// this map on the side rather than within the CXXMethodDecl structure.
598 using CXXMethodVector = llvm::TinyPtrVector<const CXXMethodDecl *>;
599 llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector> OverriddenMethods;
600
601 /// Mapping from each declaration context to its corresponding
602 /// mangling numbering context (used for constructs like lambdas which
603 /// need to be consistently numbered for the mangler).
604 llvm::DenseMap<const DeclContext *, std::unique_ptr<MangleNumberingContext>>
605 MangleNumberingContexts;
606 llvm::DenseMap<const Decl *, std::unique_ptr<MangleNumberingContext>>
607 ExtraMangleNumberingContexts;
608
609 /// Side-table of mangling numbers for declarations which rarely
610 /// need them (like static local vars).
611 llvm::MapVector<const NamedDecl *, unsigned> MangleNumbers;
612 llvm::MapVector<const VarDecl *, unsigned> StaticLocalNumbers;
613 /// Mapping the associated device lambda mangling number if present.
614 mutable llvm::DenseMap<const CXXRecordDecl *, unsigned>
615 DeviceLambdaManglingNumbers;
616
617 /// Mapping that stores parameterIndex values for ParmVarDecls when
618 /// that value exceeds the bitfield size of ParmVarDeclBits.ParameterIndex.
619 using ParameterIndexTable = llvm::DenseMap<const VarDecl *, unsigned>;
620 ParameterIndexTable ParamIndices;
621
622 ImportDecl *FirstLocalImport = nullptr;
623 ImportDecl *LastLocalImport = nullptr;
624
625 TranslationUnitDecl *TUDecl = nullptr;
626 mutable ExternCContextDecl *ExternCContext = nullptr;
627 mutable BuiltinTemplateDecl *MakeIntegerSeqDecl = nullptr;
628 mutable BuiltinTemplateDecl *TypePackElementDecl = nullptr;
629 mutable BuiltinTemplateDecl *BuiltinCommonTypeDecl = nullptr;
630
631 /// The associated SourceManager object.
632 SourceManager &SourceMgr;
633
634 /// The language options used to create the AST associated with
635 /// this ASTContext object.
636 LangOptions &LangOpts;
637
638 /// NoSanitizeList object that is used by sanitizers to decide which
639 /// entities should not be instrumented.
640 std::unique_ptr<NoSanitizeList> NoSanitizeL;
641
642 /// Function filtering mechanism to determine whether a given function
643 /// should be imbued with the XRay "always" or "never" attributes.
644 std::unique_ptr<XRayFunctionFilter> XRayFilter;
645
646 /// ProfileList object that is used by the profile instrumentation
647 /// to decide which entities should be instrumented.
648 std::unique_ptr<ProfileList> ProfList;
649
650 /// The allocator used to create AST objects.
651 ///
652 /// AST objects are never destructed; rather, all memory associated with the
653 /// AST objects will be released when the ASTContext itself is destroyed.
654 mutable llvm::BumpPtrAllocator BumpAlloc;
655
656 /// Allocator for partial diagnostics.
658
659 /// The current C++ ABI.
660 std::unique_ptr<CXXABI> ABI;
662
663 /// Address space map mangling must be used with language specific
664 /// address spaces (e.g. OpenCL/CUDA)
665 bool AddrSpaceMapMangling;
666
667 /// For performance, track whether any function effects are in use.
668 mutable bool AnyFunctionEffects = false;
669
670 const TargetInfo *Target = nullptr;
671 const TargetInfo *AuxTarget = nullptr;
673 std::unique_ptr<interp::Context> InterpContext;
674 std::unique_ptr<ParentMapContext> ParentMapCtx;
675
676 /// Keeps track of the deallocated DeclListNodes for future reuse.
677 DeclListNode *ListNodeFreeList = nullptr;
678
679public:
687
688 /// Returns the clang bytecode interpreter context.
690
692 /// Do not allow wrong-sided variables in constant expressions.
693 bool NoWrongSidedVars = false;
698 CUDAConstantEvalContextRAII(ASTContext &Ctx_, bool NoWrongSidedVars)
699 : Ctx(Ctx_), SavedCtx(Ctx_.CUDAConstantEvalCtx) {
700 Ctx_.CUDAConstantEvalCtx.NoWrongSidedVars = NoWrongSidedVars;
701 }
703 };
704
705 /// Returns the dynamic AST node parent map context.
707
708 // A traversal scope limits the parts of the AST visible to certain analyses.
709 // RecursiveASTVisitor only visits specified children of TranslationUnitDecl.
710 // getParents() will only observe reachable parent edges.
711 //
712 // The scope is defined by a set of "top-level" declarations which will be
713 // visible under the TranslationUnitDecl.
714 // Initially, it is the entire TU, represented by {getTranslationUnitDecl()}.
715 //
716 // After setTraversalScope({foo, bar}), the exposed AST looks like:
717 // TranslationUnitDecl
718 // - foo
719 // - ...
720 // - bar
721 // - ...
722 // All other siblings of foo and bar are pruned from the tree.
723 // (However they are still accessible via TranslationUnitDecl->decls())
724 //
725 // Changing the scope clears the parent cache, which is expensive to rebuild.
726 std::vector<Decl *> getTraversalScope() const { return TraversalScope; }
727 void setTraversalScope(const std::vector<Decl *> &);
728
729 /// Forwards to get node parents from the ParentMapContext. New callers should
730 /// use ParentMapContext::getParents() directly.
731 template <typename NodeT> DynTypedNodeList getParents(const NodeT &Node);
732
734 return PrintingPolicy;
735 }
736
738 PrintingPolicy = Policy;
739 }
740
741 SourceManager& getSourceManager() { return SourceMgr; }
742 const SourceManager& getSourceManager() const { return SourceMgr; }
743
744 // Cleans up some of the data structures. This allows us to do cleanup
745 // normally done in the destructor earlier. Renders much of the ASTContext
746 // unusable, mostly the actual AST nodes, so should be called when we no
747 // longer need access to the AST.
748 void cleanup();
749
750 llvm::BumpPtrAllocator &getAllocator() const {
751 return BumpAlloc;
752 }
753
754 void *Allocate(size_t Size, unsigned Align = 8) const {
755 return BumpAlloc.Allocate(Size, Align);
756 }
757 template <typename T> T *Allocate(size_t Num = 1) const {
758 return static_cast<T *>(Allocate(Num * sizeof(T), alignof(T)));
759 }
760 void Deallocate(void *Ptr) const {}
761
762 llvm::StringRef backupStr(llvm::StringRef S) const {
763 char *Buf = new (*this) char[S.size()];
764 std::copy(S.begin(), S.end(), Buf);
765 return llvm::StringRef(Buf, S.size());
766 }
767
768 /// Allocates a \c DeclListNode or returns one from the \c ListNodeFreeList
769 /// pool.
771 if (DeclListNode *Alloc = ListNodeFreeList) {
772 ListNodeFreeList = Alloc->Rest.dyn_cast<DeclListNode*>();
773 Alloc->D = ND;
774 Alloc->Rest = nullptr;
775 return Alloc;
776 }
777 return new (*this) DeclListNode(ND);
778 }
779 /// Deallcates a \c DeclListNode by returning it to the \c ListNodeFreeList
780 /// pool.
782 N->Rest = ListNodeFreeList;
783 ListNodeFreeList = N;
784 }
785
786 /// Return the total amount of physical memory allocated for representing
787 /// AST nodes and type information.
788 size_t getASTAllocatedMemory() const {
789 return BumpAlloc.getTotalMemory();
790 }
791
792 /// Return the total memory used for various side tables.
793 size_t getSideTableAllocatedMemory() const;
794
796 return DiagAllocator;
797 }
798
799 const TargetInfo &getTargetInfo() const { return *Target; }
800 const TargetInfo *getAuxTargetInfo() const { return AuxTarget; }
801
802 const QualType GetHigherPrecisionFPType(QualType ElementType) const {
803 const auto *CurrentBT = cast<BuiltinType>(ElementType);
804 switch (CurrentBT->getKind()) {
805 case BuiltinType::Kind::Half:
806 case BuiltinType::Kind::Float16:
807 return FloatTy;
808 case BuiltinType::Kind::Float:
809 case BuiltinType::Kind::BFloat16:
810 return DoubleTy;
811 case BuiltinType::Kind::Double:
812 return LongDoubleTy;
813 default:
814 return ElementType;
815 }
816 return ElementType;
817 }
818
819 /// getIntTypeForBitwidth -
820 /// sets integer QualTy according to specified details:
821 /// bitwidth, signed/unsigned.
822 /// Returns empty type if there is no appropriate target types.
823 QualType getIntTypeForBitwidth(unsigned DestWidth,
824 unsigned Signed) const;
825
826 /// getRealTypeForBitwidth -
827 /// sets floating point QualTy according to specified bitwidth.
828 /// Returns empty type if there is no appropriate target types.
829 QualType getRealTypeForBitwidth(unsigned DestWidth,
830 FloatModeKind ExplicitType) const;
831
832 bool AtomicUsesUnsupportedLibcall(const AtomicExpr *E) const;
833
834 const LangOptions& getLangOpts() const { return LangOpts; }
835
836 // If this condition is false, typo correction must be performed eagerly
837 // rather than delayed in many places, as it makes use of dependent types.
838 // the condition is false for clang's C-only codepath, as it doesn't support
839 // dependent types yet.
840 bool isDependenceAllowed() const {
841 return LangOpts.CPlusPlus || LangOpts.RecoveryAST;
842 }
843
844 const NoSanitizeList &getNoSanitizeList() const { return *NoSanitizeL; }
845
847 const QualType &Ty) const;
848
850 return *XRayFilter;
851 }
852
853 const ProfileList &getProfileList() const { return *ProfList; }
854
856
858 return FullSourceLoc(Loc,SourceMgr);
859 }
860
861 /// Return the C++ ABI kind that should be used. The C++ ABI can be overriden
862 /// at compile time with `-fc++-abi=`. If this is not provided, we instead use
863 /// the default ABI set by the target.
865
866 /// All comments in this translation unit.
868
869 /// True if comments are already loaded from ExternalASTSource.
870 mutable bool CommentsLoaded = false;
871
872 /// Mapping from declaration to directly attached comment.
873 ///
874 /// Raw comments are owned by Comments list. This mapping is populated
875 /// lazily.
876 mutable llvm::DenseMap<const Decl *, const RawComment *> DeclRawComments;
877
878 /// Mapping from canonical declaration to the first redeclaration in chain
879 /// that has a comment attached.
880 ///
881 /// Raw comments are owned by Comments list. This mapping is populated
882 /// lazily.
883 mutable llvm::DenseMap<const Decl *, const Decl *> RedeclChainComments;
884
885 /// Keeps track of redeclaration chains that don't have any comment attached.
886 /// Mapping from canonical declaration to redeclaration chain that has no
887 /// comments attached to any redeclaration. Specifically it's mapping to
888 /// the last redeclaration we've checked.
889 ///
890 /// Shall not contain declarations that have comments attached to any
891 /// redeclaration in their chain.
892 mutable llvm::DenseMap<const Decl *, const Decl *> CommentlessRedeclChains;
893
894 /// Mapping from declarations to parsed comments attached to any
895 /// redeclaration.
896 mutable llvm::DenseMap<const Decl *, comments::FullComment *> ParsedComments;
897
898 /// Attaches \p Comment to \p OriginalD and to its redeclaration chain
899 /// and removes the redeclaration chain from the set of commentless chains.
900 ///
901 /// Don't do anything if a comment has already been attached to \p OriginalD
902 /// or its redeclaration chain.
903 void cacheRawCommentForDecl(const Decl &OriginalD,
904 const RawComment &Comment) const;
905
906 /// \returns searches \p CommentsInFile for doc comment for \p D.
907 ///
908 /// \p RepresentativeLocForDecl is used as a location for searching doc
909 /// comments. \p CommentsInFile is a mapping offset -> comment of files in the
910 /// same file where \p RepresentativeLocForDecl is.
912 const Decl *D, const SourceLocation RepresentativeLocForDecl,
913 const std::map<unsigned, RawComment *> &CommentsInFile) const;
914
915 /// Return the documentation comment attached to a given declaration,
916 /// without looking into cache.
918
919public:
920 void addComment(const RawComment &RC);
921
922 /// Return the documentation comment attached to a given declaration.
923 /// Returns nullptr if no comment is attached.
924 ///
925 /// \param OriginalDecl if not nullptr, is set to declaration AST node that
926 /// had the comment, if the comment we found comes from a redeclaration.
927 const RawComment *
929 const Decl **OriginalDecl = nullptr) const;
930
931 /// Searches existing comments for doc comments that should be attached to \p
932 /// Decls. If any doc comment is found, it is parsed.
933 ///
934 /// Requirement: All \p Decls are in the same file.
935 ///
936 /// If the last comment in the file is already attached we assume
937 /// there are not comments left to be attached to \p Decls.
939 const Preprocessor *PP);
940
941 /// Return parsed documentation comment attached to a given declaration.
942 /// Returns nullptr if no comment is attached.
943 ///
944 /// \param PP the Preprocessor used with this TU. Could be nullptr if
945 /// preprocessor is not available.
947 const Preprocessor *PP) const;
948
949 /// Return parsed documentation comment attached to a given declaration.
950 /// Returns nullptr if no comment is attached. Does not look at any
951 /// redeclarations of the declaration.
953
955 const Decl *D) const;
956
957private:
958 mutable comments::CommandTraits CommentCommandTraits;
959
960 /// Iterator that visits import declarations.
961 class import_iterator {
962 ImportDecl *Import = nullptr;
963
964 public:
965 using value_type = ImportDecl *;
966 using reference = ImportDecl *;
967 using pointer = ImportDecl *;
968 using difference_type = int;
969 using iterator_category = std::forward_iterator_tag;
970
971 import_iterator() = default;
972 explicit import_iterator(ImportDecl *Import) : Import(Import) {}
973
974 reference operator*() const { return Import; }
975 pointer operator->() const { return Import; }
976
977 import_iterator &operator++() {
979 return *this;
980 }
981
982 import_iterator operator++(int) {
983 import_iterator Other(*this);
984 ++(*this);
985 return Other;
986 }
987
988 friend bool operator==(import_iterator X, import_iterator Y) {
989 return X.Import == Y.Import;
990 }
991
992 friend bool operator!=(import_iterator X, import_iterator Y) {
993 return X.Import != Y.Import;
994 }
995 };
996
997public:
999 return CommentCommandTraits;
1000 }
1001
1002 /// Retrieve the attributes for the given declaration.
1003 AttrVec& getDeclAttrs(const Decl *D);
1004
1005 /// Erase the attributes corresponding to the given declaration.
1006 void eraseDeclAttrs(const Decl *D);
1007
1008 /// If this variable is an instantiated static data member of a
1009 /// class template specialization, returns the templated static data member
1010 /// from which it was instantiated.
1011 // FIXME: Remove ?
1013 const VarDecl *Var);
1014
1015 /// Note that the static data member \p Inst is an instantiation of
1016 /// the static data member template \p Tmpl of a class template.
1019 SourceLocation PointOfInstantiation = SourceLocation());
1020
1023
1026
1027 /// If the given using decl \p Inst is an instantiation of
1028 /// another (possibly unresolved) using decl, return it.
1030
1031 /// Remember that the using decl \p Inst is an instantiation
1032 /// of the using decl \p Pattern of a class template.
1033 void setInstantiatedFromUsingDecl(NamedDecl *Inst, NamedDecl *Pattern);
1034
1035 /// If the given using-enum decl \p Inst is an instantiation of
1036 /// another using-enum decl, return it.
1038
1039 /// Remember that the using enum decl \p Inst is an instantiation
1040 /// of the using enum decl \p Pattern of a class template.
1042 UsingEnumDecl *Pattern);
1043
1046 UsingShadowDecl *Pattern);
1047
1049
1051
1052 // Access to the set of methods overridden by the given C++ method.
1053 using overridden_cxx_method_iterator = CXXMethodVector::const_iterator;
1055 overridden_methods_begin(const CXXMethodDecl *Method) const;
1056
1058 overridden_methods_end(const CXXMethodDecl *Method) const;
1059
1060 unsigned overridden_methods_size(const CXXMethodDecl *Method) const;
1061
1063 llvm::iterator_range<overridden_cxx_method_iterator>;
1064
1066
1067 /// Note that the given C++ \p Method overrides the given \p
1068 /// Overridden method.
1069 void addOverriddenMethod(const CXXMethodDecl *Method,
1070 const CXXMethodDecl *Overridden);
1071
1072 /// Return C++ or ObjC overridden methods for the given \p Method.
1073 ///
1074 /// An ObjC method is considered to override any method in the class's
1075 /// base classes, its protocols, or its categories' protocols, that has
1076 /// the same selector and is of the same kind (class or instance).
1077 /// A method in an implementation is not considered as overriding the same
1078 /// method in the interface or its categories.
1080 const NamedDecl *Method,
1081 SmallVectorImpl<const NamedDecl *> &Overridden) const;
1082
1083 /// Notify the AST context that a new import declaration has been
1084 /// parsed or implicitly created within this translation unit.
1085 void addedLocalImportDecl(ImportDecl *Import);
1086
1088 return Import->getNextLocalImport();
1089 }
1090
1091 using import_range = llvm::iterator_range<import_iterator>;
1092
1094 return import_range(import_iterator(FirstLocalImport), import_iterator());
1095 }
1096
1098 Decl *Result = MergedDecls.lookup(D);
1099 return Result ? Result : D;
1100 }
1101 void setPrimaryMergedDecl(Decl *D, Decl *Primary) {
1102 MergedDecls[D] = Primary;
1103 }
1104
1105 /// Note that the definition \p ND has been merged into module \p M,
1106 /// and should be visible whenever \p M is visible.
1108 bool NotifyListeners = true);
1109
1110 /// Clean up the merged definition list. Call this if you might have
1111 /// added duplicates into the list.
1113
1114 /// Get the additional modules in which the definition \p Def has
1115 /// been merged.
1117
1118 /// Add a declaration to the list of declarations that are initialized
1119 /// for a module. This will typically be a global variable (with internal
1120 /// linkage) that runs module initializers, such as the iostream initializer,
1121 /// or an ImportDecl nominating another module that has initializers.
1123
1125
1126 /// Get the initializations to perform when importing a module, if any.
1128
1129 /// Set the (C++20) module we are building.
1131
1132 /// Get module under construction, nullptr if this is not a C++20 module.
1133 Module *getCurrentNamedModule() const { return CurrentCXXNamedModule; }
1134
1135 /// If the two module \p M1 and \p M2 are in the same module.
1136 ///
1137 /// FIXME: The signature may be confusing since `clang::Module` means to
1138 /// a module fragment or a module unit but not a C++20 module.
1139 bool isInSameModule(const Module *M1, const Module *M2);
1140
1142 return TUDecl->getMostRecentDecl();
1143 }
1145 assert(!TUDecl || TUKind == TU_Incremental);
1147 if (TraversalScope.empty() || TraversalScope.back() == TUDecl)
1148 TraversalScope = {NewTUDecl};
1149 if (TUDecl)
1150 NewTUDecl->setPreviousDecl(TUDecl);
1151 TUDecl = NewTUDecl;
1152 }
1153
1158
1159 // Builtin Types.
1163 CanQualType WCharTy; // [C++ 3.9.1p5].
1164 CanQualType WideCharTy; // Same as WCharTy in C++, integer type in C99.
1165 CanQualType WIntTy; // [C99 7.24.1], integer type unchanged by default promotions.
1166 CanQualType Char8Ty; // [C++20 proposal]
1167 CanQualType Char16Ty; // [C++0x 3.9.1p5], integer type in C99.
1168 CanQualType Char32Ty; // [C++0x 3.9.1p5], integer type in C99.
1174 LongAccumTy; // ISO/IEC JTC1 SC22 WG14 N1169 Extension
1184 CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
1186 CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
1194#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1195 CanQualType SingletonId;
1196#include "clang/Basic/OpenCLImageTypes.def"
1202#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1203 CanQualType Id##Ty;
1204#include "clang/Basic/OpenCLExtensionTypes.def"
1205#define SVE_TYPE(Name, Id, SingletonId) \
1206 CanQualType SingletonId;
1207#include "clang/Basic/AArch64SVEACLETypes.def"
1208#define PPC_VECTOR_TYPE(Name, Id, Size) \
1209 CanQualType Id##Ty;
1210#include "clang/Basic/PPCTypes.def"
1211#define RVV_TYPE(Name, Id, SingletonId) \
1212 CanQualType SingletonId;
1213#include "clang/Basic/RISCVVTypes.def"
1214#define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
1215#include "clang/Basic/WebAssemblyReferenceTypes.def"
1216#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
1217 CanQualType SingletonId;
1218#include "clang/Basic/AMDGPUTypes.def"
1219#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
1220#include "clang/Basic/HLSLIntangibleTypes.def"
1221
1222 // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand.
1223 mutable QualType AutoDeductTy; // Deduction against 'auto'.
1224 mutable QualType AutoRRefDeductTy; // Deduction against 'auto &&'.
1225
1226 // Decl used to help define __builtin_va_list for some targets.
1227 // The decl is built when constructing 'BuiltinVaListDecl'.
1228 mutable Decl *VaListTagDecl = nullptr;
1229
1230 // Implicitly-declared type 'struct _GUID'.
1231 mutable TagDecl *MSGuidTagDecl = nullptr;
1232
1233 /// Keep track of CUDA/HIP device-side variables ODR-used by host code.
1234 /// This does not include extern shared variables used by device host
1235 /// functions as addresses of shared variables are per warp, therefore
1236 /// cannot be accessed by host code.
1237 llvm::DenseSet<const VarDecl *> CUDADeviceVarODRUsedByHost;
1238
1239 /// Keep track of CUDA/HIP external kernels or device variables ODR-used by
1240 /// host code. SetVector is used to maintain the order.
1241 llvm::SetVector<const ValueDecl *> CUDAExternalDeviceDeclODRUsedByHost;
1242
1243 /// Keep track of CUDA/HIP implicit host device functions used on device side
1244 /// in device compilation.
1245 llvm::DenseSet<const FunctionDecl *> CUDAImplicitHostDeviceFunUsedByDevice;
1246
1247 /// Map of SYCL kernels indexed by the unique type used to name the kernel.
1248 /// Entries are not serialized but are recreated on deserialization of a
1249 /// sycl_kernel_entry_point attributed function declaration.
1250 llvm::DenseMap<CanQualType, SYCLKernelInfo> SYCLKernels;
1251
1252 /// For capturing lambdas with an explicit object parameter whose type is
1253 /// derived from the lambda type, we need to perform derived-to-base
1254 /// conversion so we can access the captures; the cast paths for that
1255 /// are stored here.
1256 llvm::DenseMap<const CXXMethodDecl *, CXXCastPath> LambdaCastPaths;
1257
1259 SelectorTable &sels, Builtin::Context &builtins,
1261 ASTContext(const ASTContext &) = delete;
1262 ASTContext &operator=(const ASTContext &) = delete;
1263 ~ASTContext();
1264
1265 /// Attach an external AST source to the AST context.
1266 ///
1267 /// The external AST source provides the ability to load parts of
1268 /// the abstract syntax tree as needed from some external storage,
1269 /// e.g., a precompiled header.
1271
1272 /// Retrieve a pointer to the external AST source associated
1273 /// with this AST context, if any.
1275 return ExternalSource.get();
1276 }
1277
1278 /// Attach an AST mutation listener to the AST context.
1279 ///
1280 /// The AST mutation listener provides the ability to track modifications to
1281 /// the abstract syntax tree entities committed after they were initially
1282 /// created.
1284 this->Listener = Listener;
1285 }
1286
1287 /// Retrieve a pointer to the AST mutation listener associated
1288 /// with this AST context, if any.
1290
1291 void PrintStats() const;
1292 const SmallVectorImpl<Type *>& getTypes() const { return Types; }
1293
1295 const IdentifierInfo *II) const;
1296
1297 /// Create a new implicit TU-level CXXRecordDecl or RecordDecl
1298 /// declaration.
1300 StringRef Name,
1301 RecordDecl::TagKind TK = RecordDecl::TagKind::Struct) const;
1302
1303 /// Create a new implicit TU-level typedef declaration.
1304 TypedefDecl *buildImplicitTypedef(QualType T, StringRef Name) const;
1305
1306 /// Retrieve the declaration for the 128-bit signed integer type.
1307 TypedefDecl *getInt128Decl() const;
1308
1309 /// Retrieve the declaration for the 128-bit unsigned integer type.
1310 TypedefDecl *getUInt128Decl() const;
1311
1312 //===--------------------------------------------------------------------===//
1313 // Type Constructors
1314 //===--------------------------------------------------------------------===//
1315
1316private:
1317 /// Return a type with extended qualifiers.
1318 QualType getExtQualType(const Type *Base, Qualifiers Quals) const;
1319
1320 QualType getTypeDeclTypeSlow(const TypeDecl *Decl) const;
1321
1322 QualType getPipeType(QualType T, bool ReadOnly) const;
1323
1324public:
1325 /// Return the uniqued reference to the type for an address space
1326 /// qualified type with the specified type and address space.
1327 ///
1328 /// The resulting type has a union of the qualifiers from T and the address
1329 /// space. If T already has an address space specifier, it is silently
1330 /// replaced.
1331 QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const;
1332
1333 /// Remove any existing address space on the type and returns the type
1334 /// with qualifiers intact (or that's the idea anyway)
1335 ///
1336 /// The return type should be T with all prior qualifiers minus the address
1337 /// space.
1339
1340 /// Return the "other" discriminator used for the pointer auth schema used for
1341 /// vtable pointers in instances of the requested type.
1342 uint16_t
1344
1345 /// Return the "other" type-specific discriminator for the given type.
1347
1348 /// Apply Objective-C protocol qualifiers to the given type.
1349 /// \param allowOnPointerType specifies if we can apply protocol
1350 /// qualifiers on ObjCObjectPointerType. It can be set to true when
1351 /// constructing the canonical type of a Objective-C type parameter.
1353 ArrayRef<ObjCProtocolDecl *> protocols, bool &hasError,
1354 bool allowOnPointerType = false) const;
1355
1356 /// Return the uniqued reference to the type for an Objective-C
1357 /// gc-qualified type.
1358 ///
1359 /// The resulting type has a union of the qualifiers from T and the gc
1360 /// attribute.
1362
1363 /// Remove the existing address space on the type if it is a pointer size
1364 /// address space and return the type with qualifiers intact.
1366
1367 /// Return the uniqued reference to the type for a \c restrict
1368 /// qualified type.
1369 ///
1370 /// The resulting type has a union of the qualifiers from \p T and
1371 /// \c restrict.
1373 return T.withFastQualifiers(Qualifiers::Restrict);
1374 }
1375
1376 /// Return the uniqued reference to the type for a \c volatile
1377 /// qualified type.
1378 ///
1379 /// The resulting type has a union of the qualifiers from \p T and
1380 /// \c volatile.
1382 return T.withFastQualifiers(Qualifiers::Volatile);
1383 }
1384
1385 /// Return the uniqued reference to the type for a \c const
1386 /// qualified type.
1387 ///
1388 /// The resulting type has a union of the qualifiers from \p T and \c const.
1389 ///
1390 /// It can be reasonably expected that this will always be equivalent to
1391 /// calling T.withConst().
1392 QualType getConstType(QualType T) const { return T.withConst(); }
1393
1394 /// Rebuild a type, preserving any existing type sugar. For function types,
1395 /// you probably want to just use \c adjustFunctionResultType and friends
1396 /// instead.
1398 llvm::function_ref<QualType(QualType)> Adjust) const;
1399
1400 /// Change the ExtInfo on a function type.
1402 FunctionType::ExtInfo EInfo);
1403
1404 /// Change the result type of a function type, preserving sugar such as
1405 /// attributed types.
1407 QualType NewResultType);
1408
1409 /// Adjust the given function result type.
1411
1412 /// Change the result type of a function type once it is deduced.
1414
1415 /// Get a function type and produce the equivalent function type with the
1416 /// specified exception specification. Type sugar that can be present on a
1417 /// declaration of a function with an exception specification is permitted
1418 /// and preserved. Other type sugar (for instance, typedefs) is not.
1420 QualType Orig, const FunctionProtoType::ExceptionSpecInfo &ESI) const;
1421
1422 /// Determine whether two function types are the same, ignoring
1423 /// exception specifications in cases where they're part of the type.
1425
1426 /// Change the exception specification on a function once it is
1427 /// delay-parsed, instantiated, or computed.
1430 bool AsWritten = false);
1431
1432 /// Get a function type and produce the equivalent function type where
1433 /// pointer size address spaces in the return type and parameter types are
1434 /// replaced with the default address space.
1436
1437 /// Determine whether two function types are the same, ignoring pointer sizes
1438 /// in the return type and parameter types.
1440
1441 /// Get or construct a function type that is equivalent to the input type
1442 /// except that the parameter ABI annotations are stripped.
1444
1445 /// Determine if two function types are the same, ignoring parameter ABI
1446 /// annotations.
1448
1449 /// Return the uniqued reference to the type for a complex
1450 /// number with the specified element type.
1454 }
1455
1456 /// Return the uniqued reference to the type for a pointer to
1457 /// the specified type.
1461 }
1462
1463 QualType
1464 getCountAttributedType(QualType T, Expr *CountExpr, bool CountInBytes,
1465 bool OrNull,
1466 ArrayRef<TypeCoupledDeclRefInfo> DependentDecls) const;
1467
1468 /// Return the uniqued reference to a type adjusted from the original
1469 /// type to a new type.
1470 QualType getAdjustedType(QualType Orig, QualType New) const;
1473 getAdjustedType((QualType)Orig, (QualType)New));
1474 }
1475
1476 /// Return the uniqued reference to the decayed version of the given
1477 /// type. Can only be called on array and function types which decay to
1478 /// pointer types.
1482 }
1483 /// Return the uniqued reference to a specified decay from the original
1484 /// type to the decayed type.
1485 QualType getDecayedType(QualType Orig, QualType Decayed) const;
1486
1487 /// Return the uniqued reference to a specified array parameter type from the
1488 /// original array type.
1490
1491 /// Return the uniqued reference to the atomic type for the specified
1492 /// type.
1494
1495 /// Return the uniqued reference to the type for a block of the
1496 /// specified type.
1498
1499 /// Gets the struct used to keep track of the descriptor for pointer to
1500 /// blocks.
1502
1503 /// Return a read_only pipe type for the specified type.
1505
1506 /// Return a write_only pipe type for the specified type.
1508
1509 /// Return a bit-precise integer type with the specified signedness and bit
1510 /// count.
1511 QualType getBitIntType(bool Unsigned, unsigned NumBits) const;
1512
1513 /// Return a dependent bit-precise integer type with the specified signedness
1514 /// and bit count.
1515 QualType getDependentBitIntType(bool Unsigned, Expr *BitsExpr) const;
1516
1517 /// Gets the struct used to keep track of the extended descriptor for
1518 /// pointer to blocks.
1520
1521 /// Map an AST Type to an OpenCLTypeKind enum value.
1522 OpenCLTypeKind getOpenCLTypeKind(const Type *T) const;
1523
1524 /// Get address space for OpenCL type.
1525 LangAS getOpenCLTypeAddrSpace(const Type *T) const;
1526
1527 /// Returns default address space based on OpenCL version and enabled features
1529 return LangOpts.OpenCLGenericAddressSpace ? LangAS::opencl_generic
1531 }
1532
1534 cudaConfigureCallDecl = FD;
1535 }
1536
1538 return cudaConfigureCallDecl;
1539 }
1540
1541 /// Returns true iff we need copy/dispose helpers for the given type.
1542 bool BlockRequiresCopying(QualType Ty, const VarDecl *D);
1543
1544 /// Returns true, if given type has a known lifetime. HasByrefExtendedLayout
1545 /// is set to false in this case. If HasByrefExtendedLayout returns true,
1546 /// byref variable has extended lifetime.
1547 bool getByrefLifetime(QualType Ty,
1548 Qualifiers::ObjCLifetime &Lifetime,
1549 bool &HasByrefExtendedLayout) const;
1550
1551 /// Return the uniqued reference to the type for an lvalue reference
1552 /// to the specified type.
1553 QualType getLValueReferenceType(QualType T, bool SpelledAsLValue = true)
1554 const;
1555
1556 /// Return the uniqued reference to the type for an rvalue reference
1557 /// to the specified type.
1559
1560 /// Return the uniqued reference to the type for a member pointer to
1561 /// the specified type in the specified class.
1562 ///
1563 /// The class \p Cls is a \c Type because it could be a dependent name.
1564 QualType getMemberPointerType(QualType T, const Type *Cls) const;
1565
1566 /// Return a non-unique reference to the type for a variable array of
1567 /// the specified element type.
1569 ArraySizeModifier ASM, unsigned IndexTypeQuals,
1570 SourceRange Brackets) const;
1571
1572 /// Return a non-unique reference to the type for a dependently-sized
1573 /// array of the specified element type.
1574 ///
1575 /// FIXME: We will need these to be uniqued, or at least comparable, at some
1576 /// point.
1579 unsigned IndexTypeQuals,
1580 SourceRange Brackets) const;
1581
1582 /// Return a unique reference to the type for an incomplete array of
1583 /// the specified element type.
1585 unsigned IndexTypeQuals) const;
1586
1587 /// Return the unique reference to the type for a constant array of
1588 /// the specified element type.
1589 QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize,
1590 const Expr *SizeExpr, ArraySizeModifier ASM,
1591 unsigned IndexTypeQuals) const;
1592
1593 /// Return a type for a constant array for a string literal of the
1594 /// specified element type and length.
1595 QualType getStringLiteralArrayType(QualType EltTy, unsigned Length) const;
1596
1597 /// Returns a vla type where known sizes are replaced with [*].
1599
1600 // Convenience struct to return information about a builtin vector type.
1603 llvm::ElementCount EC;
1604 unsigned NumVectors;
1606 unsigned NumVectors)
1608 };
1609
1610 /// Returns the element type, element count and number of vectors
1611 /// (in case of tuple) for a builtin vector type.
1612 BuiltinVectorTypeInfo
1613 getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const;
1614
1615 /// Return the unique reference to a scalable vector type of the specified
1616 /// element type and scalable number of elements.
1617 /// For RISC-V, number of fields is also provided when it fetching for
1618 /// tuple type.
1619 ///
1620 /// \pre \p EltTy must be a built-in type.
1621 QualType getScalableVectorType(QualType EltTy, unsigned NumElts,
1622 unsigned NumFields = 1) const;
1623
1624 /// Return a WebAssembly externref type.
1626
1627 /// Return the unique reference to a vector type of the specified
1628 /// element type and size.
1629 ///
1630 /// \pre \p VectorType must be a built-in type.
1631 QualType getVectorType(QualType VectorType, unsigned NumElts,
1632 VectorKind VecKind) const;
1633 /// Return the unique reference to the type for a dependently sized vector of
1634 /// the specified element type.
1636 SourceLocation AttrLoc,
1637 VectorKind VecKind) const;
1638
1639 /// Return the unique reference to an extended vector type
1640 /// of the specified element type and size.
1641 ///
1642 /// \pre \p VectorType must be a built-in type.
1643 QualType getExtVectorType(QualType VectorType, unsigned NumElts) const;
1644
1645 /// \pre Return a non-unique reference to the type for a dependently-sized
1646 /// vector of the specified element type.
1647 ///
1648 /// FIXME: We will need these to be uniqued, or at least comparable, at some
1649 /// point.
1651 Expr *SizeExpr,
1652 SourceLocation AttrLoc) const;
1653
1654 /// Return the unique reference to the matrix type of the specified element
1655 /// type and size
1656 ///
1657 /// \pre \p ElementType must be a valid matrix element type (see
1658 /// MatrixType::isValidElementType).
1659 QualType getConstantMatrixType(QualType ElementType, unsigned NumRows,
1660 unsigned NumColumns) const;
1661
1662 /// Return the unique reference to the matrix type of the specified element
1663 /// type and size
1664 QualType getDependentSizedMatrixType(QualType ElementType, Expr *RowExpr,
1665 Expr *ColumnExpr,
1666 SourceLocation AttrLoc) const;
1667
1669 Expr *AddrSpaceExpr,
1670 SourceLocation AttrLoc) const;
1671
1672 /// Return a K&R style C function type like 'int()'.
1674 const FunctionType::ExtInfo &Info) const;
1675
1678 }
1679
1680 /// Return a normal function type with a typed argument list.
1682 const FunctionProtoType::ExtProtoInfo &EPI) const {
1683 return getFunctionTypeInternal(ResultTy, Args, EPI, false);
1684 }
1685
1687
1688private:
1689 /// Return a normal function type with a typed argument list.
1690 QualType getFunctionTypeInternal(QualType ResultTy, ArrayRef<QualType> Args,
1692 bool OnlyWantCanonical) const;
1693 QualType
1694 getAutoTypeInternal(QualType DeducedType, AutoTypeKeyword Keyword,
1695 bool IsDependent, bool IsPack = false,
1696 ConceptDecl *TypeConstraintConcept = nullptr,
1697 ArrayRef<TemplateArgument> TypeConstraintArgs = {},
1698 bool IsCanon = false) const;
1699
1700public:
1701 /// Return the unique reference to the type for the specified type
1702 /// declaration.
1704 const TypeDecl *PrevDecl = nullptr) const {
1705 assert(Decl && "Passed null for Decl param");
1706 if (Decl->TypeForDecl) return QualType(Decl->TypeForDecl, 0);
1707
1708 if (PrevDecl) {
1709 assert(PrevDecl->TypeForDecl && "previous decl has no TypeForDecl");
1710 Decl->TypeForDecl = PrevDecl->TypeForDecl;
1711 return QualType(PrevDecl->TypeForDecl, 0);
1712 }
1713
1714 return getTypeDeclTypeSlow(Decl);
1715 }
1716
1718 QualType Underlying) const;
1719
1720 /// Return the unique reference to the type for the specified
1721 /// typedef-name decl.
1723 QualType Underlying = QualType()) const;
1724
1725 QualType getRecordType(const RecordDecl *Decl) const;
1726
1727 QualType getEnumType(const EnumDecl *Decl) const;
1728
1729 QualType
1731
1733
1734 QualType getAttributedType(attr::Kind attrKind, QualType modifiedType,
1735 QualType equivalentType,
1736 const Attr *attr = nullptr) const;
1737
1738 QualType getAttributedType(const Attr *attr, QualType modifiedType,
1739 QualType equivalentType) const;
1740
1741 QualType getAttributedType(NullabilityKind nullability, QualType modifiedType,
1742 QualType equivalentType);
1743
1744 QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr,
1745 QualType Wrapped) const;
1746
1748 QualType Wrapped, QualType Contained,
1750
1751 QualType
1752 getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl,
1753 unsigned Index,
1754 std::optional<unsigned> PackIndex,
1758 unsigned Index, bool Final,
1759 const TemplateArgument &ArgPack);
1760
1761 QualType
1762 getTemplateTypeParmType(unsigned Depth, unsigned Index,
1763 bool ParameterPack,
1764 TemplateTypeParmDecl *ParmDecl = nullptr) const;
1765
1768 QualType Canon = QualType()) const;
1769
1770 QualType
1772 ArrayRef<TemplateArgument> Args) const;
1773
1776 QualType Canon = QualType()) const;
1777
1780 const TemplateArgumentListInfo &Args,
1781 QualType Canon = QualType()) const;
1782
1783 QualType getParenType(QualType NamedType) const;
1784
1786 const IdentifierInfo *MacroII) const;
1787
1789 NestedNameSpecifier *NNS, QualType NamedType,
1790 TagDecl *OwnedTagDecl = nullptr) const;
1793 const IdentifierInfo *Name,
1794 QualType Canon = QualType()) const;
1795
1798 const IdentifierInfo *Name, ArrayRef<TemplateArgumentLoc> Args) const;
1801 const IdentifierInfo *Name, ArrayRef<TemplateArgument> Args) const;
1802
1804
1805 /// Form a pack expansion type with the given pattern.
1806 /// \param NumExpansions The number of expansions for the pack, if known.
1807 /// \param ExpectPackInType If \c false, we should not expect \p Pattern to
1808 /// contain an unexpanded pack. This only makes sense if the pack
1809 /// expansion is used in a context where the arity is inferred from
1810 /// elsewhere, such as if the pattern contains a placeholder type or
1811 /// if this is the canonical type of another pack expansion type.
1813 std::optional<unsigned> NumExpansions,
1814 bool ExpectPackInType = true) const;
1815
1817 ObjCInterfaceDecl *PrevDecl = nullptr) const;
1818
1819 /// Legacy interface: cannot provide type arguments or __kindof.
1821 ObjCProtocolDecl * const *Protocols,
1822 unsigned NumProtocols) const;
1823
1825 ArrayRef<QualType> typeArgs,
1827 bool isKindOf) const;
1828
1830 ArrayRef<ObjCProtocolDecl *> protocols) const;
1832 ObjCTypeParamDecl *New) const;
1833
1835
1836 /// QIdProtocolsAdoptObjCObjectProtocols - Checks that protocols in
1837 /// QT's qualified-id protocol list adopt all protocols in IDecl's list
1838 /// of protocols.
1840 ObjCInterfaceDecl *IDecl);
1841
1842 /// Return a ObjCObjectPointerType type for the given ObjCObjectType.
1844
1845 /// C23 feature and GCC extension.
1848
1849 QualType getReferenceQualifiedType(const Expr *e) const;
1850
1851 /// C++11 decltype.
1852 QualType getDecltypeType(Expr *e, QualType UnderlyingType) const;
1853
1854 QualType getPackIndexingType(QualType Pattern, Expr *IndexExpr,
1855 bool FullySubstituted = false,
1856 ArrayRef<QualType> Expansions = {},
1857 int Index = -1) const;
1858
1859 /// Unary type transforms
1860 QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType,
1861 UnaryTransformType::UTTKind UKind) const;
1862
1863 /// C++11 deduced auto type.
1864 QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword,
1865 bool IsDependent, bool IsPack = false,
1866 ConceptDecl *TypeConstraintConcept = nullptr,
1867 ArrayRef<TemplateArgument> TypeConstraintArgs ={}) const;
1868
1869 /// C++11 deduction pattern for 'auto' type.
1870 QualType getAutoDeductType() const;
1871
1872 /// C++11 deduction pattern for 'auto &&' type.
1873 QualType getAutoRRefDeductType() const;
1874
1875 /// Remove any type constraints from a template parameter type, for
1876 /// equivalence comparison of template parameters.
1877 QualType getUnconstrainedType(QualType T) const;
1878
1879 /// C++17 deduced class template specialization type.
1880 QualType getDeducedTemplateSpecializationType(TemplateName Template,
1881 QualType DeducedType,
1882 bool IsDependent) const;
1883
1884private:
1885 QualType getDeducedTemplateSpecializationTypeInternal(TemplateName Template,
1886 QualType DeducedType,
1887 bool IsDependent,
1888 QualType Canon) const;
1889
1890public:
1891 /// Return the unique reference to the type for the specified TagDecl
1892 /// (struct/union/class/enum) decl.
1893 QualType getTagDeclType(const TagDecl *Decl) const;
1894
1895 /// Return the unique type for "size_t" (C99 7.17), defined in
1896 /// <stddef.h>.
1897 ///
1898 /// The sizeof operator requires this (C99 6.5.3.4p4).
1899 CanQualType getSizeType() const;
1900
1901 /// Return the unique signed counterpart of
1902 /// the integer type corresponding to size_t.
1904
1905 /// Return the unique type for "intmax_t" (C99 7.18.1.5), defined in
1906 /// <stdint.h>.
1907 CanQualType getIntMaxType() const;
1908
1909 /// Return the unique type for "uintmax_t" (C99 7.18.1.5), defined in
1910 /// <stdint.h>.
1912
1913 /// Return the unique wchar_t type available in C++ (and available as
1914 /// __wchar_t as a Microsoft extension).
1915 QualType getWCharType() const { return WCharTy; }
1916
1917 /// Return the type of wide characters. In C++, this returns the
1918 /// unique wchar_t type. In C99, this returns a type compatible with the type
1919 /// defined in <stddef.h> as defined by the target.
1921
1922 /// Return the type of "signed wchar_t".
1923 ///
1924 /// Used when in C++, as a GCC extension.
1926
1927 /// Return the type of "unsigned wchar_t".
1928 ///
1929 /// Used when in C++, as a GCC extension.
1931
1932 /// In C99, this returns a type compatible with the type
1933 /// defined in <stddef.h> as defined by the target.
1934 QualType getWIntType() const { return WIntTy; }
1935
1936 /// Return a type compatible with "intptr_t" (C99 7.18.1.4),
1937 /// as defined by the target.
1938 QualType getIntPtrType() const;
1939
1940 /// Return a type compatible with "uintptr_t" (C99 7.18.1.4),
1941 /// as defined by the target.
1942 QualType getUIntPtrType() const;
1943
1944 /// Return the unique type for "ptrdiff_t" (C99 7.17) defined in
1945 /// <stddef.h>. Pointer - pointer requires this (C99 6.5.6p9).
1947
1948 /// Return the unique unsigned counterpart of "ptrdiff_t"
1949 /// integer type. The standard (C11 7.21.6.1p7) refers to this type
1950 /// in the definition of %tu format specifier.
1952
1953 /// Return the unique type for "pid_t" defined in
1954 /// <sys/types.h>. We need this to compute the correct type for vfork().
1955 QualType getProcessIDType() const;
1956
1957 /// Return the C structure type used to represent constant CFStrings.
1959
1960 /// Returns the C struct type for objc_super
1961 QualType getObjCSuperType() const;
1962 void setObjCSuperType(QualType ST) { ObjCSuperType = ST; }
1963
1964 /// Get the structure type used to representation CFStrings, or NULL
1965 /// if it hasn't yet been built.
1967 if (CFConstantStringTypeDecl)
1968 return getTypedefType(CFConstantStringTypeDecl);
1969 return QualType();
1970 }
1974
1975 // This setter/getter represents the ObjC type for an NSConstantString.
1978 return ObjCConstantStringType;
1979 }
1980
1982 return ObjCNSStringType;
1983 }
1984
1986 ObjCNSStringType = T;
1987 }
1988
1989 /// Retrieve the type that \c id has been defined to, which may be
1990 /// different from the built-in \c id if \c id has been typedef'd.
1992 if (ObjCIdRedefinitionType.isNull())
1993 return getObjCIdType();
1994 return ObjCIdRedefinitionType;
1995 }
1996
1997 /// Set the user-written type that redefines \c id.
1999 ObjCIdRedefinitionType = RedefType;
2000 }
2001
2002 /// Retrieve the type that \c Class has been defined to, which may be
2003 /// different from the built-in \c Class if \c Class has been typedef'd.
2005 if (ObjCClassRedefinitionType.isNull())
2006 return getObjCClassType();
2007 return ObjCClassRedefinitionType;
2008 }
2009
2010 /// Set the user-written type that redefines 'SEL'.
2012 ObjCClassRedefinitionType = RedefType;
2013 }
2014
2015 /// Retrieve the type that 'SEL' has been defined to, which may be
2016 /// different from the built-in 'SEL' if 'SEL' has been typedef'd.
2018 if (ObjCSelRedefinitionType.isNull())
2019 return getObjCSelType();
2020 return ObjCSelRedefinitionType;
2021 }
2022
2023 /// Set the user-written type that redefines 'SEL'.
2025 ObjCSelRedefinitionType = RedefType;
2026 }
2027
2028 /// Retrieve the identifier 'NSObject'.
2030 if (!NSObjectName) {
2031 NSObjectName = &Idents.get("NSObject");
2032 }
2033
2034 return NSObjectName;
2035 }
2036
2037 /// Retrieve the identifier 'NSCopying'.
2039 if (!NSCopyingName) {
2040 NSCopyingName = &Idents.get("NSCopying");
2041 }
2042
2043 return NSCopyingName;
2044 }
2045
2047
2049
2050 /// Retrieve the identifier 'bool'.
2052 if (!BoolName)
2053 BoolName = &Idents.get("bool");
2054 return BoolName;
2055 }
2056
2058 if (!MakeIntegerSeqName)
2059 MakeIntegerSeqName = &Idents.get("__make_integer_seq");
2060 return MakeIntegerSeqName;
2061 }
2062
2064 if (!TypePackElementName)
2065 TypePackElementName = &Idents.get("__type_pack_element");
2066 return TypePackElementName;
2067 }
2068
2070 if (!BuiltinCommonTypeName)
2071 BuiltinCommonTypeName = &Idents.get("__builtin_common_type");
2072 return BuiltinCommonTypeName;
2073 }
2074
2075 /// Retrieve the Objective-C "instancetype" type, if already known;
2076 /// otherwise, returns a NULL type;
2079 }
2080
2081 /// Retrieve the typedef declaration corresponding to the Objective-C
2082 /// "instancetype" type.
2084
2085 /// Set the type for the C FILE type.
2086 void setFILEDecl(TypeDecl *FILEDecl) { this->FILEDecl = FILEDecl; }
2087
2088 /// Retrieve the C FILE type.
2090 if (FILEDecl)
2091 return getTypeDeclType(FILEDecl);
2092 return QualType();
2093 }
2094
2095 /// Set the type for the C jmp_buf type.
2096 void setjmp_bufDecl(TypeDecl *jmp_bufDecl) {
2097 this->jmp_bufDecl = jmp_bufDecl;
2098 }
2099
2100 /// Retrieve the C jmp_buf type.
2102 if (jmp_bufDecl)
2103 return getTypeDeclType(jmp_bufDecl);
2104 return QualType();
2105 }
2106
2107 /// Set the type for the C sigjmp_buf type.
2108 void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl) {
2109 this->sigjmp_bufDecl = sigjmp_bufDecl;
2110 }
2111
2112 /// Retrieve the C sigjmp_buf type.
2114 if (sigjmp_bufDecl)
2115 return getTypeDeclType(sigjmp_bufDecl);
2116 return QualType();
2117 }
2118
2119 /// Set the type for the C ucontext_t type.
2120 void setucontext_tDecl(TypeDecl *ucontext_tDecl) {
2121 this->ucontext_tDecl = ucontext_tDecl;
2122 }
2123
2124 /// Retrieve the C ucontext_t type.
2126 if (ucontext_tDecl)
2127 return getTypeDeclType(ucontext_tDecl);
2128 return QualType();
2129 }
2130
2131 /// The result type of logical operations, '<', '>', '!=', etc.
2133 return getLangOpts().CPlusPlus ? BoolTy : IntTy;
2134 }
2135
2136 /// Emit the Objective-CC type encoding for the given type \p T into
2137 /// \p S.
2138 ///
2139 /// If \p Field is specified then record field names are also encoded.
2140 void getObjCEncodingForType(QualType T, std::string &S,
2141 const FieldDecl *Field=nullptr,
2142 QualType *NotEncodedT=nullptr) const;
2143
2144 /// Emit the Objective-C property type encoding for the given
2145 /// type \p T into \p S.
2146 void getObjCEncodingForPropertyType(QualType T, std::string &S) const;
2147
2149
2150 /// Put the string version of the type qualifiers \p QT into \p S.
2152 std::string &S) const;
2153
2154 /// Emit the encoded type for the function \p Decl into \p S.
2155 ///
2156 /// This is in the same format as Objective-C method encodings.
2157 ///
2158 /// \returns true if an error occurred (e.g., because one of the parameter
2159 /// types is incomplete), false otherwise.
2160 std::string getObjCEncodingForFunctionDecl(const FunctionDecl *Decl) const;
2161
2162 /// Emit the encoded type for the method declaration \p Decl into
2163 /// \p S.
2165 bool Extended = false) const;
2166
2167 /// Return the encoded type for this block declaration.
2168 std::string getObjCEncodingForBlock(const BlockExpr *blockExpr) const;
2169
2170 /// getObjCEncodingForPropertyDecl - Return the encoded type for
2171 /// this method declaration. If non-NULL, Container must be either
2172 /// an ObjCCategoryImplDecl or ObjCImplementationDecl; it should
2173 /// only be NULL when getting encodings for protocol properties.
2175 const Decl *Container) const;
2176
2178 ObjCProtocolDecl *rProto) const;
2179
2181 const ObjCPropertyDecl *PD,
2182 const Decl *Container) const;
2183
2184 /// Return the size of type \p T for Objective-C encoding purpose,
2185 /// in characters.
2187
2188 /// Retrieve the typedef corresponding to the predefined \c id type
2189 /// in Objective-C.
2190 TypedefDecl *getObjCIdDecl() const;
2191
2192 /// Represents the Objective-CC \c id type.
2193 ///
2194 /// This is set up lazily, by Sema. \c id is always a (typedef for a)
2195 /// pointer type, a pointer to a struct.
2198 }
2199
2200 /// Retrieve the typedef corresponding to the predefined 'SEL' type
2201 /// in Objective-C.
2202 TypedefDecl *getObjCSelDecl() const;
2203
2204 /// Retrieve the type that corresponds to the predefined Objective-C
2205 /// 'SEL' type.
2208 }
2209
2210 /// Retrieve the typedef declaration corresponding to the predefined
2211 /// Objective-C 'Class' type.
2213
2214 /// Represents the Objective-C \c Class type.
2215 ///
2216 /// This is set up lazily, by Sema. \c Class is always a (typedef for a)
2217 /// pointer type, a pointer to a struct.
2220 }
2221
2222 /// Retrieve the Objective-C class declaration corresponding to
2223 /// the predefined \c Protocol class.
2225
2226 /// Retrieve declaration of 'BOOL' typedef
2228 return BOOLDecl;
2229 }
2230
2231 /// Save declaration of 'BOOL' typedef
2233 BOOLDecl = TD;
2234 }
2235
2236 /// type of 'BOOL' type.
2238 return getTypeDeclType(getBOOLDecl());
2239 }
2240
2241 /// Retrieve the type of the Objective-C \c Protocol class.
2244 }
2245
2246 /// Retrieve the C type declaration corresponding to the predefined
2247 /// \c __builtin_va_list type.
2249
2250 /// Retrieve the type of the \c __builtin_va_list type.
2253 }
2254
2255 /// Retrieve the C type declaration corresponding to the predefined
2256 /// \c __va_list_tag type used to help define the \c __builtin_va_list type
2257 /// for some targets.
2258 Decl *getVaListTagDecl() const;
2259
2260 /// Retrieve the C type declaration corresponding to the predefined
2261 /// \c __builtin_ms_va_list type.
2263
2264 /// Retrieve the type of the \c __builtin_ms_va_list type.
2267 }
2268
2269 /// Retrieve the implicitly-predeclared 'struct _GUID' declaration.
2271
2272 /// Retrieve the implicitly-predeclared 'struct _GUID' type.
2274 assert(MSGuidTagDecl && "asked for GUID type but MS extensions disabled");
2276 }
2277
2278 /// Return whether a declaration to a builtin is allowed to be
2279 /// overloaded/redeclared.
2280 bool canBuiltinBeRedeclared(const FunctionDecl *) const;
2281
2282 /// Return a type with additional \c const, \c volatile, or
2283 /// \c restrict qualifiers.
2286 }
2287
2288 /// Un-split a SplitQualType.
2290 return getQualifiedType(split.Ty, split.Quals);
2291 }
2292
2293 /// Return a type with additional qualifiers.
2295 if (!Qs.hasNonFastQualifiers())
2296 return T.withFastQualifiers(Qs.getFastQualifiers());
2297 QualifierCollector Qc(Qs);
2298 const Type *Ptr = Qc.strip(T);
2299 return getExtQualType(Ptr, Qc);
2300 }
2301
2302 /// Return a type with additional qualifiers.
2304 if (!Qs.hasNonFastQualifiers())
2305 return QualType(T, Qs.getFastQualifiers());
2306 return getExtQualType(T, Qs);
2307 }
2308
2309 /// Return a type with the given lifetime qualifier.
2310 ///
2311 /// \pre Neither type.ObjCLifetime() nor \p lifetime may be \c OCL_None.
2313 Qualifiers::ObjCLifetime lifetime) {
2314 assert(type.getObjCLifetime() == Qualifiers::OCL_None);
2315 assert(lifetime != Qualifiers::OCL_None);
2316
2317 Qualifiers qs;
2318 qs.addObjCLifetime(lifetime);
2319 return getQualifiedType(type, qs);
2320 }
2321
2322 /// getUnqualifiedObjCPointerType - Returns version of
2323 /// Objective-C pointer type with lifetime qualifier removed.
2325 if (!type.getTypePtr()->isObjCObjectPointerType() ||
2326 !type.getQualifiers().hasObjCLifetime())
2327 return type;
2328 Qualifiers Qs = type.getQualifiers();
2329 Qs.removeObjCLifetime();
2330 return getQualifiedType(type.getUnqualifiedType(), Qs);
2331 }
2332
2333 /// \brief Return a type with the given __ptrauth qualifier.
2335 assert(!Ty.getPointerAuth());
2336 assert(PointerAuth);
2337
2338 Qualifiers Qs;
2339 Qs.setPointerAuth(PointerAuth);
2340 return getQualifiedType(Ty, Qs);
2341 }
2342
2343 unsigned char getFixedPointScale(QualType Ty) const;
2344 unsigned char getFixedPointIBits(QualType Ty) const;
2345 llvm::FixedPointSemantics getFixedPointSemantics(QualType Ty) const;
2346 llvm::APFixedPoint getFixedPointMax(QualType Ty) const;
2347 llvm::APFixedPoint getFixedPointMin(QualType Ty) const;
2348
2350 SourceLocation NameLoc) const;
2351
2353 UnresolvedSetIterator End) const;
2355
2357 bool TemplateKeyword,
2358 TemplateName Template) const;
2359
2361 const IdentifierInfo *Name) const;
2363 OverloadedOperatorKind Operator) const;
2365 getSubstTemplateTemplateParm(TemplateName replacement, Decl *AssociatedDecl,
2366 unsigned Index,
2367 std::optional<unsigned> PackIndex) const;
2369 Decl *AssociatedDecl,
2370 unsigned Index,
2371 bool Final) const;
2372
2373 /// Represents a TemplateName which had some of its default arguments
2374 /// deduced. This both represents this default argument deduction as sugar,
2375 /// and provides the support for it's equivalences through canonicalization.
2376 /// For example DeducedTemplateNames which have the same set of default
2377 /// arguments are equivalent, and are also equivalent to the underlying
2378 /// template when the deduced template arguments are the same.
2380 DefaultArguments DefaultArgs) const;
2381
2383 /// No error
2385
2386 /// Missing a type
2388
2389 /// Missing a type from <stdio.h>
2391
2392 /// Missing a type from <setjmp.h>
2394
2395 /// Missing a type from <ucontext.h>
2398
2399 QualType DecodeTypeStr(const char *&Str, const ASTContext &Context,
2401 bool &RequireICE, bool AllowTypeModifiers) const;
2402
2403 /// Return the type for the specified builtin.
2404 ///
2405 /// If \p IntegerConstantArgs is non-null, it is filled in with a bitmask of
2406 /// arguments to the builtin that are required to be integer constant
2407 /// expressions.
2409 unsigned *IntegerConstantArgs = nullptr) const;
2410
2411 /// Types and expressions required to build C++2a three-way comparisons
2412 /// using operator<=>, including the values return by builtin <=> operators.
2414
2415private:
2416 CanQualType getFromTargetType(unsigned Type) const;
2417 TypeInfo getTypeInfoImpl(const Type *T) const;
2418
2419 //===--------------------------------------------------------------------===//
2420 // Type Predicates.
2421 //===--------------------------------------------------------------------===//
2422
2423public:
2424 /// Return one of the GCNone, Weak or Strong Objective-C garbage
2425 /// collection attributes.
2427
2428 /// Return true if the given vector types are of the same unqualified
2429 /// type or if they are equivalent to the same GCC vector type.
2430 ///
2431 /// \note This ignores whether they are target-specific (AltiVec or Neon)
2432 /// types.
2433 bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec);
2434
2435 /// Return true if the given types are an SVE builtin and a VectorType that
2436 /// is a fixed-length representation of the SVE builtin for a specific
2437 /// vector-length.
2438 bool areCompatibleSveTypes(QualType FirstType, QualType SecondType);
2439
2440 /// Return true if the given vector types are lax-compatible SVE vector types,
2441 /// false otherwise.
2442 bool areLaxCompatibleSveTypes(QualType FirstType, QualType SecondType);
2443
2444 /// Return true if the given types are an RISC-V vector builtin type and a
2445 /// VectorType that is a fixed-length representation of the RISC-V vector
2446 /// builtin type for a specific vector-length.
2447 bool areCompatibleRVVTypes(QualType FirstType, QualType SecondType);
2448
2449 /// Return true if the given vector types are lax-compatible RISC-V vector
2450 /// types as defined by -flax-vector-conversions=, which permits implicit
2451 /// conversions between vectors with different number of elements and/or
2452 /// incompatible element types, false otherwise.
2453 bool areLaxCompatibleRVVTypes(QualType FirstType, QualType SecondType);
2454
2455 /// Return true if the type has been explicitly qualified with ObjC ownership.
2456 /// A type may be implicitly qualified with ownership under ObjC ARC, and in
2457 /// some cases the compiler treats these differently.
2459
2460 /// Return true if this is an \c NSObject object with its \c NSObject
2461 /// attribute set.
2463 return Ty->isObjCNSObjectType();
2464 }
2465
2466 //===--------------------------------------------------------------------===//
2467 // Type Sizing and Analysis
2468 //===--------------------------------------------------------------------===//
2469
2470 /// Return the APFloat 'semantics' for the specified scalar floating
2471 /// point type.
2472 const llvm::fltSemantics &getFloatTypeSemantics(QualType T) const;
2473
2474 /// Get the size and alignment of the specified complete type in bits.
2475 TypeInfo getTypeInfo(const Type *T) const;
2476 TypeInfo getTypeInfo(QualType T) const { return getTypeInfo(T.getTypePtr()); }
2477
2478 /// Get default simd alignment of the specified complete type in bits.
2479 unsigned getOpenMPDefaultSimdAlign(QualType T) const;
2480
2481 /// Return the size of the specified (complete) type \p T, in bits.
2482 uint64_t getTypeSize(QualType T) const { return getTypeInfo(T).Width; }
2483 uint64_t getTypeSize(const Type *T) const { return getTypeInfo(T).Width; }
2484
2485 /// Return the size of the character type, in bits.
2486 uint64_t getCharWidth() const {
2487 return getTypeSize(CharTy);
2488 }
2489
2490 /// Convert a size in bits to a size in characters.
2491 CharUnits toCharUnitsFromBits(int64_t BitSize) const;
2492
2493 /// Convert a size in characters to a size in bits.
2494 int64_t toBits(CharUnits CharSize) const;
2495
2496 /// Return the size of the specified (complete) type \p T, in
2497 /// characters.
2499 CharUnits getTypeSizeInChars(const Type *T) const;
2500
2501 std::optional<CharUnits> getTypeSizeInCharsIfKnown(QualType Ty) const {
2502 if (Ty->isIncompleteType() || Ty->isDependentType())
2503 return std::nullopt;
2504 return getTypeSizeInChars(Ty);
2505 }
2506
2507 std::optional<CharUnits> getTypeSizeInCharsIfKnown(const Type *Ty) const {
2508 return getTypeSizeInCharsIfKnown(QualType(Ty, 0));
2509 }
2510
2511 /// Return the ABI-specified alignment of a (complete) type \p T, in
2512 /// bits.
2513 unsigned getTypeAlign(QualType T) const { return getTypeInfo(T).Align; }
2514 unsigned getTypeAlign(const Type *T) const { return getTypeInfo(T).Align; }
2515
2516 /// Return the ABI-specified natural alignment of a (complete) type \p T,
2517 /// before alignment adjustments, in bits.
2518 ///
2519 /// This alignment is curently used only by ARM and AArch64 when passing
2520 /// arguments of a composite type.
2522 return getTypeUnadjustedAlign(T.getTypePtr());
2523 }
2524 unsigned getTypeUnadjustedAlign(const Type *T) const;
2525
2526 /// Return the alignment of a type, in bits, or 0 if
2527 /// the type is incomplete and we cannot determine the alignment (for
2528 /// example, from alignment attributes). The returned alignment is the
2529 /// Preferred alignment if NeedsPreferredAlignment is true, otherwise is the
2530 /// ABI alignment.
2532 bool NeedsPreferredAlignment = false) const;
2533
2534 /// Return the ABI-specified alignment of a (complete) type \p T, in
2535 /// characters.
2537 CharUnits getTypeAlignInChars(const Type *T) const;
2538
2539 /// Return the PreferredAlignment of a (complete) type \p T, in
2540 /// characters.
2543 }
2544
2545 /// getTypeUnadjustedAlignInChars - Return the ABI-specified alignment of a type,
2546 /// in characters, before alignment adjustments. This method does not work on
2547 /// incomplete types.
2550
2551 // getTypeInfoDataSizeInChars - Return the size of a type, in chars. If the
2552 // type is a record, its data size is returned.
2554
2555 TypeInfoChars getTypeInfoInChars(const Type *T) const;
2557
2558 /// Determine if the alignment the type has was required using an
2559 /// alignment attribute.
2560 bool isAlignmentRequired(const Type *T) const;
2561 bool isAlignmentRequired(QualType T) const;
2562
2563 /// More type predicates useful for type checking/promotion
2564 bool isPromotableIntegerType(QualType T) const; // C99 6.3.1.1p2
2565
2566 /// Return the "preferred" alignment of the specified type \p T for
2567 /// the current target, in bits.
2568 ///
2569 /// This can be different than the ABI alignment in cases where it is
2570 /// beneficial for performance or backwards compatibility preserving to
2571 /// overalign a data type. (Note: despite the name, the preferred alignment
2572 /// is ABI-impacting, and not an optimization.)
2574 return getPreferredTypeAlign(T.getTypePtr());
2575 }
2576 unsigned getPreferredTypeAlign(const Type *T) const;
2577
2578 /// Return the default alignment for __attribute__((aligned)) on
2579 /// this target, to be used if no alignment value is specified.
2581
2582 /// Return the alignment in bits that should be given to a
2583 /// global variable with type \p T. If \p VD is non-null it will be
2584 /// considered specifically for the query.
2585 unsigned getAlignOfGlobalVar(QualType T, const VarDecl *VD) const;
2586
2587 /// Return the alignment in characters that should be given to a
2588 /// global variable with type \p T. If \p VD is non-null it will be
2589 /// considered specifically for the query.
2591
2592 /// Return the minimum alignement as specified by the target. If \p VD is
2593 /// non-null it may be used to identify external or weak variables.
2594 unsigned getMinGlobalAlignOfVar(uint64_t Size, const VarDecl *VD) const;
2595
2596 /// Return a conservative estimate of the alignment of the specified
2597 /// decl \p D.
2598 ///
2599 /// \pre \p D must not be a bitfield type, as bitfields do not have a valid
2600 /// alignment.
2601 ///
2602 /// If \p ForAlignof, references are treated like their underlying type
2603 /// and large arrays don't get any special treatment. If not \p ForAlignof
2604 /// it computes the value expected by CodeGen: references are treated like
2605 /// pointers and large arrays get extra alignment.
2606 CharUnits getDeclAlign(const Decl *D, bool ForAlignof = false) const;
2607
2608 /// Return the alignment (in bytes) of the thrown exception object. This is
2609 /// only meaningful for targets that allocate C++ exceptions in a system
2610 /// runtime, such as those using the Itanium C++ ABI.
2612
2613 /// Get or compute information about the layout of the specified
2614 /// record (struct/union/class) \p D, which indicates its size and field
2615 /// position information.
2616 const ASTRecordLayout &getASTRecordLayout(const RecordDecl *D) const;
2617
2618 /// Get or compute information about the layout of the specified
2619 /// Objective-C interface.
2621 const;
2622
2623 void DumpRecordLayout(const RecordDecl *RD, raw_ostream &OS,
2624 bool Simple = false) const;
2625
2626 /// Get or compute information about the layout of the specified
2627 /// Objective-C implementation.
2628 ///
2629 /// This may differ from the interface if synthesized ivars are present.
2630 const ASTRecordLayout &
2632
2633 /// Get our current best idea for the key function of the
2634 /// given record decl, or nullptr if there isn't one.
2635 ///
2636 /// The key function is, according to the Itanium C++ ABI section 5.2.3:
2637 /// ...the first non-pure virtual function that is not inline at the
2638 /// point of class definition.
2639 ///
2640 /// Other ABIs use the same idea. However, the ARM C++ ABI ignores
2641 /// virtual functions that are defined 'inline', which means that
2642 /// the result of this computation can change.
2644
2645 /// Observe that the given method cannot be a key function.
2646 /// Checks the key-function cache for the method's class and clears it
2647 /// if matches the given declaration.
2648 ///
2649 /// This is used in ABIs where out-of-line definitions marked
2650 /// inline are not considered to be key functions.
2651 ///
2652 /// \param method should be the declaration from the class definition
2653 void setNonKeyFunction(const CXXMethodDecl *method);
2654
2655 /// Loading virtual member pointers using the virtual inheritance model
2656 /// always results in an adjustment using the vbtable even if the index is
2657 /// zero.
2658 ///
2659 /// This is usually OK because the first slot in the vbtable points
2660 /// backwards to the top of the MDC. However, the MDC might be reusing a
2661 /// vbptr from an nv-base. In this case, the first slot in the vbtable
2662 /// points to the start of the nv-base which introduced the vbptr and *not*
2663 /// the MDC. Modify the NonVirtualBaseAdjustment to account for this.
2665
2666 /// Get the offset of a FieldDecl or IndirectFieldDecl, in bits.
2667 uint64_t getFieldOffset(const ValueDecl *FD) const;
2668
2669 /// Get the offset of an ObjCIvarDecl in bits.
2670 uint64_t lookupFieldBitOffset(const ObjCInterfaceDecl *OID,
2672 const ObjCIvarDecl *Ivar) const;
2673
2674 /// Find the 'this' offset for the member path in a pointer-to-member
2675 /// APValue.
2677
2678 bool isNearlyEmpty(const CXXRecordDecl *RD) const;
2679
2681
2682 /// If \p T is null pointer, assume the target in ASTContext.
2683 MangleContext *createMangleContext(const TargetInfo *T = nullptr);
2684
2685 /// Creates a device mangle context to correctly mangle lambdas in a mixed
2686 /// architecture compile by setting the lambda mangling number source to the
2687 /// DeviceLambdaManglingNumber. Currently this asserts that the TargetInfo
2688 /// (from the AuxTargetInfo) is a an itanium target.
2690
2691 void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass,
2693
2694 unsigned CountNonClassIvars(const ObjCInterfaceDecl *OI) const;
2695 void CollectInheritedProtocols(const Decl *CDecl,
2697
2698 /// Return true if the specified type has unique object representations
2699 /// according to (C++17 [meta.unary.prop]p9)
2700 bool
2702 bool CheckIfTriviallyCopyable = true) const;
2703
2704 //===--------------------------------------------------------------------===//
2705 // Type Operators
2706 //===--------------------------------------------------------------------===//
2707
2708 /// Return the canonical (structural) type corresponding to the
2709 /// specified potentially non-canonical type \p T.
2710 ///
2711 /// The non-canonical version of a type may have many "decorated" versions of
2712 /// types. Decorators can include typedefs, 'typeof' operators, etc. The
2713 /// returned type is guaranteed to be free of any of these, allowing two
2714 /// canonical types to be compared for exact equality with a simple pointer
2715 /// comparison.
2717 return CanQualType::CreateUnsafe(T.getCanonicalType());
2718 }
2719
2720 const Type *getCanonicalType(const Type *T) const {
2722 }
2723
2724 /// Return the canonical parameter type corresponding to the specific
2725 /// potentially non-canonical one.
2726 ///
2727 /// Qualifiers are stripped off, functions are turned into function
2728 /// pointers, and arrays decay one level into pointers.
2730
2731 /// Determine whether the given types \p T1 and \p T2 are equivalent.
2732 bool hasSameType(QualType T1, QualType T2) const {
2733 return getCanonicalType(T1) == getCanonicalType(T2);
2734 }
2735 bool hasSameType(const Type *T1, const Type *T2) const {
2736 return getCanonicalType(T1) == getCanonicalType(T2);
2737 }
2738
2739 /// Determine whether the given expressions \p X and \p Y are equivalent.
2740 bool hasSameExpr(const Expr *X, const Expr *Y) const;
2741
2742 /// Return this type as a completely-unqualified array type,
2743 /// capturing the qualifiers in \p Quals.
2744 ///
2745 /// This will remove the minimal amount of sugaring from the types, similar
2746 /// to the behavior of QualType::getUnqualifiedType().
2747 ///
2748 /// \param T is the qualified type, which may be an ArrayType
2749 ///
2750 /// \param Quals will receive the full set of qualifiers that were
2751 /// applied to the array.
2752 ///
2753 /// \returns if this is an array type, the completely unqualified array type
2754 /// that corresponds to it. Otherwise, returns T.getUnqualifiedType().
2757 Qualifiers Quals;
2758 return getUnqualifiedArrayType(T, Quals);
2759 }
2760
2761 /// Determine whether the given types are equivalent after
2762 /// cvr-qualifiers have been removed.
2764 return getCanonicalType(T1).getTypePtr() ==
2766 }
2767
2769 bool IsParam) const {
2770 auto SubTnullability = SubT->getNullability();
2771 auto SuperTnullability = SuperT->getNullability();
2772 if (SubTnullability.has_value() == SuperTnullability.has_value()) {
2773 // Neither has nullability; return true
2774 if (!SubTnullability)
2775 return true;
2776 // Both have nullability qualifier.
2777 if (*SubTnullability == *SuperTnullability ||
2778 *SubTnullability == NullabilityKind::Unspecified ||
2779 *SuperTnullability == NullabilityKind::Unspecified)
2780 return true;
2781
2782 if (IsParam) {
2783 // Ok for the superclass method parameter to be "nonnull" and the subclass
2784 // method parameter to be "nullable"
2785 return (*SuperTnullability == NullabilityKind::NonNull &&
2786 *SubTnullability == NullabilityKind::Nullable);
2787 }
2788 // For the return type, it's okay for the superclass method to specify
2789 // "nullable" and the subclass method specify "nonnull"
2790 return (*SuperTnullability == NullabilityKind::Nullable &&
2791 *SubTnullability == NullabilityKind::NonNull);
2792 }
2793 return true;
2794 }
2795
2796 bool ObjCMethodsAreEqual(const ObjCMethodDecl *MethodDecl,
2797 const ObjCMethodDecl *MethodImp);
2798
2799 bool UnwrapSimilarTypes(QualType &T1, QualType &T2,
2800 bool AllowPiMismatch = true) const;
2802 bool AllowPiMismatch = true) const;
2803
2804 /// Determine if two types are similar, according to the C++ rules. That is,
2805 /// determine if they are the same other than qualifiers on the initial
2806 /// sequence of pointer / pointer-to-member / array (and in Clang, object
2807 /// pointer) types and their element types.
2808 ///
2809 /// Clang offers a number of qualifiers in addition to the C++ qualifiers;
2810 /// those qualifiers are also ignored in the 'similarity' check.
2811 bool hasSimilarType(QualType T1, QualType T2) const;
2812
2813 /// Determine if two types are similar, ignoring only CVR qualifiers.
2814 bool hasCvrSimilarType(QualType T1, QualType T2);
2815
2816 /// Retrieves the "canonical" nested name specifier for a
2817 /// given nested name specifier.
2818 ///
2819 /// The canonical nested name specifier is a nested name specifier
2820 /// that uniquely identifies a type or namespace within the type
2821 /// system. For example, given:
2822 ///
2823 /// \code
2824 /// namespace N {
2825 /// struct S {
2826 /// template<typename T> struct X { typename T* type; };
2827 /// };
2828 /// }
2829 ///
2830 /// template<typename T> struct Y {
2831 /// typename N::S::X<T>::type member;
2832 /// };
2833 /// \endcode
2834 ///
2835 /// Here, the nested-name-specifier for N::S::X<T>:: will be
2836 /// S::X<template-param-0-0>, since 'S' and 'X' are uniquely defined
2837 /// by declarations in the type system and the canonical type for
2838 /// the template type parameter 'T' is template-param-0-0.
2841
2842 /// Retrieves the default calling convention for the current target.
2844 bool IsCXXMethod,
2845 bool IsBuiltin = false) const;
2846
2847 /// Retrieves the "canonical" template name that refers to a
2848 /// given template.
2849 ///
2850 /// The canonical template name is the simplest expression that can
2851 /// be used to refer to a given template. For most templates, this
2852 /// expression is just the template declaration itself. For example,
2853 /// the template std::vector can be referred to via a variety of
2854 /// names---std::vector, \::std::vector, vector (if vector is in
2855 /// scope), etc.---but all of these names map down to the same
2856 /// TemplateDecl, which is used to form the canonical template name.
2857 ///
2858 /// Dependent template names are more interesting. Here, the
2859 /// template name could be something like T::template apply or
2860 /// std::allocator<T>::template rebind, where the nested name
2861 /// specifier itself is dependent. In this case, the canonical
2862 /// template name uses the shortest form of the dependent
2863 /// nested-name-specifier, which itself contains all canonical
2864 /// types, values, and templates.
2866 bool IgnoreDeduced = false) const;
2867
2868 /// Determine whether the given template names refer to the same
2869 /// template.
2870 bool hasSameTemplateName(const TemplateName &X, const TemplateName &Y,
2871 bool IgnoreDeduced = false) const;
2872
2873 /// Determine whether the two declarations refer to the same entity.
2874 bool isSameEntity(const NamedDecl *X, const NamedDecl *Y) const;
2875
2876 /// Determine whether two template parameter lists are similar enough
2877 /// that they may be used in declarations of the same template.
2879 const TemplateParameterList *Y) const;
2880
2881 /// Determine whether two template parameters are similar enough
2882 /// that they may be used in declarations of the same template.
2883 bool isSameTemplateParameter(const NamedDecl *X, const NamedDecl *Y) const;
2884
2885 /// Determine whether two 'requires' expressions are similar enough that they
2886 /// may be used in re-declarations.
2887 ///
2888 /// Use of 'requires' isn't mandatory, works with constraints expressed in
2889 /// other ways too.
2890 bool isSameConstraintExpr(const Expr *XCE, const Expr *YCE) const;
2891
2892 /// Determine whether two type contraint are similar enough that they could
2893 /// used in declarations of the same template.
2894 bool isSameTypeConstraint(const TypeConstraint *XTC,
2895 const TypeConstraint *YTC) const;
2896
2897 /// Determine whether two default template arguments are similar enough
2898 /// that they may be used in declarations of the same template.
2900 const NamedDecl *Y) const;
2901
2902 /// Retrieve the "canonical" template argument.
2903 ///
2904 /// The canonical template argument is the simplest template argument
2905 /// (which may be a type, value, expression, or declaration) that
2906 /// expresses the value of the argument.
2908 const;
2909
2910 /// Type Query functions. If the type is an instance of the specified class,
2911 /// return the Type pointer for the underlying maximally pretty type. This
2912 /// is a member of ASTContext because this may need to do some amount of
2913 /// canonicalization, e.g. to move type qualifiers into the element type.
2914 const ArrayType *getAsArrayType(QualType T) const;
2916 return dyn_cast_or_null<ConstantArrayType>(getAsArrayType(T));
2917 }
2919 return dyn_cast_or_null<VariableArrayType>(getAsArrayType(T));
2920 }
2922 return dyn_cast_or_null<IncompleteArrayType>(getAsArrayType(T));
2923 }
2925 const {
2926 return dyn_cast_or_null<DependentSizedArrayType>(getAsArrayType(T));
2927 }
2928
2929 /// Return the innermost element type of an array type.
2930 ///
2931 /// For example, will return "int" for int[m][n]
2932 QualType getBaseElementType(const ArrayType *VAT) const;
2933
2934 /// Return the innermost element type of a type (which needn't
2935 /// actually be an array type).
2937
2938 /// Return number of constant array elements.
2939 uint64_t getConstantArrayElementCount(const ConstantArrayType *CA) const;
2940
2941 /// Return number of elements initialized in an ArrayInitLoopExpr.
2942 uint64_t
2944
2945 /// Perform adjustment on the parameter type of a function.
2946 ///
2947 /// This routine adjusts the given parameter type @p T to the actual
2948 /// parameter type used by semantic analysis (C99 6.7.5.3p[7,8],
2949 /// C++ [dcl.fct]p3). The adjusted parameter type is returned.
2951
2952 /// Retrieve the parameter type as adjusted for use in the signature
2953 /// of a function, decaying array and function types and removing top-level
2954 /// cv-qualifiers.
2956
2958
2959 /// Return the properly qualified result of decaying the specified
2960 /// array type to a pointer.
2961 ///
2962 /// This operation is non-trivial when handling typedefs etc. The canonical
2963 /// type of \p T must be an array type, this returns a pointer to a properly
2964 /// qualified element of the array.
2965 ///
2966 /// See C99 6.7.5.3p7 and C99 6.3.2.1p3.
2968
2969 /// Return the type that \p PromotableType will promote to: C99
2970 /// 6.3.1.1p2, assuming that \p PromotableType is a promotable integer type.
2971 QualType getPromotedIntegerType(QualType PromotableType) const;
2972
2973 /// Recurses in pointer/array types until it finds an Objective-C
2974 /// retainable type and returns its ownership.
2976
2977 /// Whether this is a promotable bitfield reference according
2978 /// to C99 6.3.1.1p2, bullet 2 (and GCC extensions).
2979 ///
2980 /// \returns the type this bit-field will promote to, or NULL if no
2981 /// promotion occurs.
2983
2984 /// Return the highest ranked integer type, see C99 6.3.1.8p1.
2985 ///
2986 /// If \p LHS > \p RHS, returns 1. If \p LHS == \p RHS, returns 0. If
2987 /// \p LHS < \p RHS, return -1.
2988 int getIntegerTypeOrder(QualType LHS, QualType RHS) const;
2989
2990 /// Compare the rank of the two specified floating point types,
2991 /// ignoring the domain of the type (i.e. 'double' == '_Complex double').
2992 ///
2993 /// If \p LHS > \p RHS, returns 1. If \p LHS == \p RHS, returns 0. If
2994 /// \p LHS < \p RHS, return -1.
2995 int getFloatingTypeOrder(QualType LHS, QualType RHS) const;
2996
2997 /// Compare the rank of two floating point types as above, but compare equal
2998 /// if both types have the same floating-point semantics on the target (i.e.
2999 /// long double and double on AArch64 will return 0).
3001
3002 unsigned getTargetAddressSpace(LangAS AS) const;
3003
3004 LangAS getLangASForBuiltinAddressSpace(unsigned AS) const;
3005
3006 /// Get target-dependent integer value for null pointer which is used for
3007 /// constant folding.
3008 uint64_t getTargetNullPointerValue(QualType QT) const;
3009
3011 return AddrSpaceMapMangling || isTargetAddressSpace(AS);
3012 }
3013
3014 bool hasAnyFunctionEffects() const { return AnyFunctionEffects; }
3015
3016 // Merges two exception specifications, such that the resulting
3017 // exception spec is the union of both. For example, if either
3018 // of them can throw something, the result can throw it as well.
3022 SmallVectorImpl<QualType> &ExceptionTypeStorage,
3023 bool AcceptDependent);
3024
3025 // For two "same" types, return a type which has
3026 // the common sugar between them. If Unqualified is true,
3027 // both types need only be the same unqualified type.
3028 // The result will drop the qualifiers which do not occur
3029 // in both types.
3031 bool Unqualified = false);
3032
3033private:
3034 // Helper for integer ordering
3035 unsigned getIntegerRank(const Type *T) const;
3036
3037public:
3038 //===--------------------------------------------------------------------===//
3039 // Type Compatibility Predicates
3040 //===--------------------------------------------------------------------===//
3041
3042 /// Compatibility predicates used to check assignment expressions.
3044 bool CompareUnqualified = false); // C99 6.2.7p1
3045
3048
3050 if (const auto *ET = dyn_cast<ElaboratedType>(T))
3051 T = ET->getNamedType();
3052 return T == getObjCIdType();
3053 }
3054
3056 if (const auto *ET = dyn_cast<ElaboratedType>(T))
3057 T = ET->getNamedType();
3058 return T == getObjCClassType();
3059 }
3060
3062 if (const auto *ET = dyn_cast<ElaboratedType>(T))
3063 T = ET->getNamedType();
3064 return T == getObjCSelType();
3065 }
3066
3068 const ObjCObjectPointerType *RHS,
3069 bool ForCompare);
3070
3072 const ObjCObjectPointerType *RHS);
3073
3074 // Check the safety of assignment from LHS to RHS
3076 const ObjCObjectPointerType *RHSOPT);
3078 const ObjCObjectType *RHS);
3080 const ObjCObjectPointerType *LHSOPT,
3081 const ObjCObjectPointerType *RHSOPT,
3082 bool BlockReturnType);
3085 const ObjCObjectPointerType *RHSOPT);
3087
3088 // Functions for calculating composite types
3089 QualType mergeTypes(QualType, QualType, bool OfBlockPointer = false,
3090 bool Unqualified = false, bool BlockReturnType = false,
3091 bool IsConditionalOperator = false);
3092 QualType mergeFunctionTypes(QualType, QualType, bool OfBlockPointer = false,
3093 bool Unqualified = false, bool AllowCXX = false,
3094 bool IsConditionalOperator = false);
3096 bool OfBlockPointer = false,
3097 bool Unqualified = false);
3099 bool OfBlockPointer=false,
3100 bool Unqualified = false);
3101
3103
3104 /// This function merges the ExtParameterInfo lists of two functions. It
3105 /// returns true if the lists are compatible. The merged list is returned in
3106 /// NewParamInfos.
3107 ///
3108 /// \param FirstFnType The type of the first function.
3109 ///
3110 /// \param SecondFnType The type of the second function.
3111 ///
3112 /// \param CanUseFirst This flag is set to true if the first function's
3113 /// ExtParameterInfo list can be used as the composite list of
3114 /// ExtParameterInfo.
3115 ///
3116 /// \param CanUseSecond This flag is set to true if the second function's
3117 /// ExtParameterInfo list can be used as the composite list of
3118 /// ExtParameterInfo.
3119 ///
3120 /// \param NewParamInfos The composite list of ExtParameterInfo. The list is
3121 /// empty if none of the flags are set.
3122 ///
3124 const FunctionProtoType *FirstFnType,
3125 const FunctionProtoType *SecondFnType,
3126 bool &CanUseFirst, bool &CanUseSecond,
3128
3129 void ResetObjCLayout(const ObjCContainerDecl *CD);
3130
3131 //===--------------------------------------------------------------------===//
3132 // Integer Predicates
3133 //===--------------------------------------------------------------------===//
3134
3135 // The width of an integer, as defined in C99 6.2.6.2. This is the number
3136 // of bits in an integer type excluding any padding bits.
3137 unsigned getIntWidth(QualType T) const;
3138
3139 // Per C99 6.2.5p6, for every signed integer type, there is a corresponding
3140 // unsigned integer type. This method takes a signed type, and returns the
3141 // corresponding unsigned integer type.
3142 // With the introduction of fixed point types in ISO N1169, this method also
3143 // accepts fixed point types and returns the corresponding unsigned type for
3144 // a given fixed point type.
3146
3147 // Per C99 6.2.5p6, for every signed integer type, there is a corresponding
3148 // unsigned integer type. This method takes an unsigned type, and returns the
3149 // corresponding signed integer type.
3150 // With the introduction of fixed point types in ISO N1169, this method also
3151 // accepts fixed point types and returns the corresponding signed type for
3152 // a given fixed point type.
3154
3155 // Per ISO N1169, this method accepts fixed point types and returns the
3156 // corresponding saturated type for a given fixed point type.
3158
3159 // Per ISO N1169, this method accepts fixed point types and returns the
3160 // corresponding non-saturated type for a given fixed point type.
3162
3163 // This method accepts fixed point types and returns the corresponding signed
3164 // type. Unlike getCorrespondingUnsignedType(), this only accepts unsigned
3165 // fixed point types because there are unsigned integer types like bool and
3166 // char8_t that don't have signed equivalents.
3168
3169 //===--------------------------------------------------------------------===//
3170 // Integer Values
3171 //===--------------------------------------------------------------------===//
3172
3173 /// Make an APSInt of the appropriate width and signedness for the
3174 /// given \p Value and integer \p Type.
3175 llvm::APSInt MakeIntValue(uint64_t Value, QualType Type) const {
3176 // If Type is a signed integer type larger than 64 bits, we need to be sure
3177 // to sign extend Res appropriately.
3178 llvm::APSInt Res(64, !Type->isSignedIntegerOrEnumerationType());
3179 Res = Value;
3180 unsigned Width = getIntWidth(Type);
3181 if (Width != Res.getBitWidth())
3182 return Res.extOrTrunc(Width);
3183 return Res;
3184 }
3185
3186 bool isSentinelNullExpr(const Expr *E);
3187
3188 /// Get the implementation of the ObjCInterfaceDecl \p D, or nullptr if
3189 /// none exists.
3191
3192 /// Get the implementation of the ObjCCategoryDecl \p D, or nullptr if
3193 /// none exists.
3195
3196 /// Return true if there is at least one \@implementation in the TU.
3198 return !ObjCImpls.empty();
3199 }
3200
3201 /// Set the implementation of ObjCInterfaceDecl.
3203 ObjCImplementationDecl *ImplD);
3204
3205 /// Set the implementation of ObjCCategoryDecl.
3207 ObjCCategoryImplDecl *ImplD);
3208
3209 /// Get the duplicate declaration of a ObjCMethod in the same
3210 /// interface, or null if none exists.
3211 const ObjCMethodDecl *
3213
3215 const ObjCMethodDecl *Redecl);
3216
3217 /// Returns the Objective-C interface that \p ND belongs to if it is
3218 /// an Objective-C method/property/ivar etc. that is part of an interface,
3219 /// otherwise returns null.
3221
3222 /// Set the copy initialization expression of a block var decl. \p CanThrow
3223 /// indicates whether the copy expression can throw or not.
3224 void setBlockVarCopyInit(const VarDecl* VD, Expr *CopyExpr, bool CanThrow);
3225
3226 /// Get the copy initialization expression of the VarDecl \p VD, or
3227 /// nullptr if none exists.
3229
3230 /// Allocate an uninitialized TypeSourceInfo.
3231 ///
3232 /// The caller should initialize the memory held by TypeSourceInfo using
3233 /// the TypeLoc wrappers.
3234 ///
3235 /// \param T the type that will be the basis for type source info. This type
3236 /// should refer to how the declarator was written in source code, not to
3237 /// what type semantic analysis resolved the declarator to.
3238 ///
3239 /// \param Size the size of the type info to create, or 0 if the size
3240 /// should be calculated based on the type.
3241 TypeSourceInfo *CreateTypeSourceInfo(QualType T, unsigned Size = 0) const;
3242
3243 /// Allocate a TypeSourceInfo where all locations have been
3244 /// initialized to a given location, which defaults to the empty
3245 /// location.
3249
3250 /// Add a deallocation callback that will be invoked when the
3251 /// ASTContext is destroyed.
3252 ///
3253 /// \param Callback A callback function that will be invoked on destruction.
3254 ///
3255 /// \param Data Pointer data that will be provided to the callback function
3256 /// when it is called.
3257 void AddDeallocation(void (*Callback)(void *), void *Data) const;
3258
3259 /// If T isn't trivially destructible, calls AddDeallocation to register it
3260 /// for destruction.
3261 template <typename T> void addDestruction(T *Ptr) const {
3262 if (!std::is_trivially_destructible<T>::value) {
3263 auto DestroyPtr = [](void *V) { static_cast<T *>(V)->~T(); };
3264 AddDeallocation(DestroyPtr, Ptr);
3265 }
3266 }
3267
3270
3271 /// Determines if the decl can be CodeGen'ed or deserialized from PCH
3272 /// lazily, only when used; this is only relevant for function or file scoped
3273 /// var definitions.
3274 ///
3275 /// \returns true if the function/var must be CodeGen'ed/deserialized even if
3276 /// it is not used.
3277 bool DeclMustBeEmitted(const Decl *D);
3278
3279 /// Visits all versions of a multiversioned function with the passed
3280 /// predicate.
3282 const FunctionDecl *FD,
3283 llvm::function_ref<void(FunctionDecl *)> Pred) const;
3284
3285 const CXXConstructorDecl *
3287
3289 CXXConstructorDecl *CD);
3290
3292
3294
3296
3298
3299 void setManglingNumber(const NamedDecl *ND, unsigned Number);
3300 unsigned getManglingNumber(const NamedDecl *ND,
3301 bool ForAuxTarget = false) const;
3302
3303 void setStaticLocalNumber(const VarDecl *VD, unsigned Number);
3304 unsigned getStaticLocalNumber(const VarDecl *VD) const;
3305
3306 /// Retrieve the context for computing mangling numbers in the given
3307 /// DeclContext.
3311 const Decl *D);
3312
3313 std::unique_ptr<MangleNumberingContext> createMangleNumberingContext() const;
3314
3315 /// Used by ParmVarDecl to store on the side the
3316 /// index of the parameter when it exceeds the size of the normal bitfield.
3317 void setParameterIndex(const ParmVarDecl *D, unsigned index);
3318
3319 /// Used by ParmVarDecl to retrieve on the side the
3320 /// index of the parameter when it exceeds the size of the normal bitfield.
3321 unsigned getParameterIndex(const ParmVarDecl *D) const;
3322
3323 /// Return a string representing the human readable name for the specified
3324 /// function declaration or file name. Used by SourceLocExpr and
3325 /// PredefinedExpr to cache evaluated results.
3327
3328 /// Return the next version number to be used for a string literal evaluated
3329 /// as part of constant evaluation.
3330 unsigned getNextStringLiteralVersion() { return NextStringLiteralVersion++; }
3331
3332 /// Return a declaration for the global GUID object representing the given
3333 /// GUID value.
3335
3336 /// Return a declaration for a uniquified anonymous global constant
3337 /// corresponding to a given APValue.
3340
3341 /// Return the template parameter object of the given type with the given
3342 /// value.
3344 const APValue &V) const;
3345
3346 /// Parses the target attributes passed in, and returns only the ones that are
3347 /// valid feature names.
3348 ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD) const;
3349
3350 void getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap,
3351 const FunctionDecl *) const;
3352 void getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap,
3353 GlobalDecl GD) const;
3354
3355 /// Generates and stores SYCL kernel metadata for the provided
3356 /// SYCL kernel entry point function. The provided function must have
3357 /// an attached sycl_kernel_entry_point attribute that specifies a unique
3358 /// type for the name of a SYCL kernel. Callers are required to detect
3359 /// conflicting SYCL kernel names and issue a diagnostic prior to calling
3360 /// this function.
3362
3363 //===--------------------------------------------------------------------===//
3364 // Statistics
3365 //===--------------------------------------------------------------------===//
3366
3367 /// The number of implicitly-declared default constructors.
3369
3370 /// The number of implicitly-declared default constructors for
3371 /// which declarations were built.
3373
3374 /// The number of implicitly-declared copy constructors.
3376
3377 /// The number of implicitly-declared copy constructors for
3378 /// which declarations were built.
3380
3381 /// The number of implicitly-declared move constructors.
3383
3384 /// The number of implicitly-declared move constructors for
3385 /// which declarations were built.
3387
3388 /// The number of implicitly-declared copy assignment operators.
3390
3391 /// The number of implicitly-declared copy assignment operators for
3392 /// which declarations were built.
3394
3395 /// The number of implicitly-declared move assignment operators.
3397
3398 /// The number of implicitly-declared move assignment operators for
3399 /// which declarations were built.
3401
3402 /// The number of implicitly-declared destructors.
3404
3405 /// The number of implicitly-declared destructors for which
3406 /// declarations were built.
3408
3409public:
3410 /// Initialize built-in types.
3411 ///
3412 /// This routine may only be invoked once for a given ASTContext object.
3413 /// It is normally invoked after ASTContext construction.
3414 ///
3415 /// \param Target The target
3417 const TargetInfo *AuxTarget = nullptr);
3418
3419private:
3420 void InitBuiltinType(CanQualType &R, BuiltinType::Kind K);
3421
3422 class ObjCEncOptions {
3423 unsigned Bits;
3424
3425 ObjCEncOptions(unsigned Bits) : Bits(Bits) {}
3426
3427 public:
3428 ObjCEncOptions() : Bits(0) {}
3429
3430#define OPT_LIST(V) \
3431 V(ExpandPointedToStructures, 0) \
3432 V(ExpandStructures, 1) \
3433 V(IsOutermostType, 2) \
3434 V(EncodingProperty, 3) \
3435 V(IsStructField, 4) \
3436 V(EncodeBlockParameters, 5) \
3437 V(EncodeClassNames, 6) \
3438
3439#define V(N,I) ObjCEncOptions& set##N() { Bits |= 1 << I; return *this; }
3440OPT_LIST(V)
3441#undef V
3442
3443#define V(N,I) bool N() const { return Bits & 1 << I; }
3444OPT_LIST(V)
3445#undef V
3446
3447#undef OPT_LIST
3448
3449 [[nodiscard]] ObjCEncOptions keepingOnly(ObjCEncOptions Mask) const {
3450 return Bits & Mask.Bits;
3451 }
3452
3453 [[nodiscard]] ObjCEncOptions forComponentType() const {
3454 ObjCEncOptions Mask = ObjCEncOptions()
3455 .setIsOutermostType()
3456 .setIsStructField();
3457 return Bits & ~Mask.Bits;
3458 }
3459 };
3460
3461 // Return the Objective-C type encoding for a given type.
3462 void getObjCEncodingForTypeImpl(QualType t, std::string &S,
3463 ObjCEncOptions Options,
3464 const FieldDecl *Field,
3465 QualType *NotEncodedT = nullptr) const;
3466
3467 // Adds the encoding of the structure's members.
3468 void getObjCEncodingForStructureImpl(RecordDecl *RD, std::string &S,
3469 const FieldDecl *Field,
3470 bool includeVBases = true,
3471 QualType *NotEncodedT=nullptr) const;
3472
3473public:
3474 // Adds the encoding of a method parameter or return type.
3476 QualType T, std::string& S,
3477 bool Extended) const;
3478
3479 /// Returns true if this is an inline-initialized static data member
3480 /// which is treated as a definition for MSVC compatibility.
3481 bool isMSStaticDataMemberInlineDefinition(const VarDecl *VD) const;
3482
3484 /// Not an inline variable.
3485 None,
3486
3487 /// Weak definition of inline variable.
3488 Weak,
3489
3490 /// Weak for now, might become strong later in this TU.
3492
3493 /// Strong definition.
3494 Strong
3495 };
3496
3497 /// Determine whether a definition of this inline variable should
3498 /// be treated as a weak or strong definition. For compatibility with
3499 /// C++14 and before, for a constexpr static data member, if there is an
3500 /// out-of-line declaration of the member, we may promote it from weak to
3501 /// strong.
3504
3505private:
3507 friend class DeclContext;
3508
3509 const ASTRecordLayout &
3510 getObjCLayout(const ObjCInterfaceDecl *D,
3511 const ObjCImplementationDecl *Impl) const;
3512
3513 /// A set of deallocations that should be performed when the
3514 /// ASTContext is destroyed.
3515 // FIXME: We really should have a better mechanism in the ASTContext to
3516 // manage running destructors for types which do variable sized allocation
3517 // within the AST. In some places we thread the AST bump pointer allocator
3518 // into the datastructures which avoids this mess during deallocation but is
3519 // wasteful of memory, and here we require a lot of error prone book keeping
3520 // in order to track and run destructors while we're tearing things down.
3522 llvm::SmallVector<std::pair<void (*)(void *), void *>, 16>;
3523 mutable DeallocationFunctionsAndArguments Deallocations;
3524
3525 // FIXME: This currently contains the set of StoredDeclMaps used
3526 // by DeclContext objects. This probably should not be in ASTContext,
3527 // but we include it here so that ASTContext can quickly deallocate them.
3528 llvm::PointerIntPair<StoredDeclsMap *, 1> LastSDM;
3529
3530 std::vector<Decl *> TraversalScope;
3531
3532 std::unique_ptr<VTableContextBase> VTContext;
3533
3534 void ReleaseDeclContextMaps();
3535
3536public:
3537 enum PragmaSectionFlag : unsigned {
3544 PSF_Invalid = 0x80000000U,
3545 };
3546
3551
3552 SectionInfo() = default;
3554 int SectionFlags)
3557 };
3558
3559 llvm::StringMap<SectionInfo> SectionInfos;
3560
3561 /// Return a new OMPTraitInfo object owned by this context.
3563
3564 /// Whether a C++ static variable or CUDA/HIP kernel may be externalized.
3565 bool mayExternalize(const Decl *D) const;
3566
3567 /// Whether a C++ static variable or CUDA/HIP kernel should be externalized.
3568 bool shouldExternalize(const Decl *D) const;
3569
3570 /// Resolve the root record to be used to derive the vtable pointer
3571 /// authentication policy for the specified record.
3572 const CXXRecordDecl *
3574 bool useAbbreviatedThunkName(GlobalDecl VirtualMethodDecl,
3575 StringRef MangledName);
3576
3577 StringRef getCUIDHash() const;
3578
3579private:
3580 /// All OMPTraitInfo objects live in this collection, one per
3581 /// `pragma omp [begin] declare variant` directive.
3582 SmallVector<std::unique_ptr<OMPTraitInfo>, 4> OMPTraitInfoVector;
3583
3584 llvm::DenseMap<GlobalDecl, llvm::StringSet<>> ThunksToBeAbbreviated;
3585};
3586
3587/// Insertion operator for diagnostics.
3589 const ASTContext::SectionInfo &Section);
3590
3591/// Utility function for constructing a nullary selector.
3592inline Selector GetNullarySelector(StringRef name, ASTContext &Ctx) {
3593 const IdentifierInfo *II = &Ctx.Idents.get(name);
3594 return Ctx.Selectors.getSelector(0, &II);
3595}
3596
3597/// Utility function for constructing an unary selector.
3598inline Selector GetUnarySelector(StringRef name, ASTContext &Ctx) {
3599 const IdentifierInfo *II = &Ctx.Idents.get(name);
3600 return Ctx.Selectors.getSelector(1, &II);
3601}
3602
3603} // namespace clang
3604
3605// operator new and delete aren't allowed inside namespaces.
3606
3607/// Placement new for using the ASTContext's allocator.
3608///
3609/// This placement form of operator new uses the ASTContext's allocator for
3610/// obtaining memory.
3611///
3612/// IMPORTANT: These are also declared in clang/AST/ASTContextAllocate.h!
3613/// Any changes here need to also be made there.
3614///
3615/// We intentionally avoid using a nothrow specification here so that the calls
3616/// to this operator will not perform a null check on the result -- the
3617/// underlying allocator never returns null pointers.
3618///
3619/// Usage looks like this (assuming there's an ASTContext 'Context' in scope):
3620/// @code
3621/// // Default alignment (8)
3622/// IntegerLiteral *Ex = new (Context) IntegerLiteral(arguments);
3623/// // Specific alignment
3624/// IntegerLiteral *Ex2 = new (Context, 4) IntegerLiteral(arguments);
3625/// @endcode
3626/// Memory allocated through this placement new operator does not need to be
3627/// explicitly freed, as ASTContext will free all of this memory when it gets
3628/// destroyed. Please note that you cannot use delete on the pointer.
3629///
3630/// @param Bytes The number of bytes to allocate. Calculated by the compiler.
3631/// @param C The ASTContext that provides the allocator.
3632/// @param Alignment The alignment of the allocated memory (if the underlying
3633/// allocator supports it).
3634/// @return The allocated memory. Could be nullptr.
3635inline void *operator new(size_t Bytes, const clang::ASTContext &C,
3636 size_t Alignment /* = 8 */) {
3637 return C.Allocate(Bytes, Alignment);
3638}
3639
3640/// Placement delete companion to the new above.
3641///
3642/// This operator is just a companion to the new above. There is no way of
3643/// invoking it directly; see the new operator for more details. This operator
3644/// is called implicitly by the compiler if a placement new expression using
3645/// the ASTContext throws in the object constructor.
3646inline void operator delete(void *Ptr, const clang::ASTContext &C, size_t) {
3647 C.Deallocate(Ptr);
3648}
3649
3650/// This placement form of operator new[] uses the ASTContext's allocator for
3651/// obtaining memory.
3652///
3653/// We intentionally avoid using a nothrow specification here so that the calls
3654/// to this operator will not perform a null check on the result -- the
3655/// underlying allocator never returns null pointers.
3656///
3657/// Usage looks like this (assuming there's an ASTContext 'Context' in scope):
3658/// @code
3659/// // Default alignment (8)
3660/// char *data = new (Context) char[10];
3661/// // Specific alignment
3662/// char *data = new (Context, 4) char[10];
3663/// @endcode
3664/// Memory allocated through this placement new[] operator does not need to be
3665/// explicitly freed, as ASTContext will free all of this memory when it gets
3666/// destroyed. Please note that you cannot use delete on the pointer.
3667///
3668/// @param Bytes The number of bytes to allocate. Calculated by the compiler.
3669/// @param C The ASTContext that provides the allocator.
3670/// @param Alignment The alignment of the allocated memory (if the underlying
3671/// allocator supports it).
3672/// @return The allocated memory. Could be nullptr.
3673inline void *operator new[](size_t Bytes, const clang::ASTContext& C,
3674 size_t Alignment /* = 8 */) {
3675 return C.Allocate(Bytes, Alignment);
3676}
3677
3678/// Placement delete[] companion to the new[] above.
3679///
3680/// This operator is just a companion to the new[] above. There is no way of
3681/// invoking it directly; see the new[] operator for more details. This operator
3682/// is called implicitly by the compiler if a placement new[] expression using
3683/// the ASTContext throws in the object constructor.
3684inline void operator delete[](void *Ptr, const clang::ASTContext &C, size_t) {
3685 C.Deallocate(Ptr);
3686}
3687
3688/// Create the representation of a LazyGenerationalUpdatePtr.
3689template <typename Owner, typename T,
3690 void (clang::ExternalASTSource::*Update)(Owner)>
3693 const clang::ASTContext &Ctx, T Value) {
3694 // Note, this is implemented here so that ExternalASTSource.h doesn't need to
3695 // include ASTContext.h. We explicitly instantiate it for all relevant types
3696 // in ASTContext.cpp.
3697 if (auto *Source = Ctx.getExternalSource())
3698 return new (Ctx) LazyData(Source, Value);
3699 return Value;
3700}
3701
3702#endif // LLVM_CLANG_AST_ASTCONTEXT_H
#define OPT_LIST(V)
Definition: ASTContext.h:3430
#define V(N, I)
Definition: ASTContext.h:3443
Forward declaration of all AST node types.
DynTypedNode Node
static char ID
Definition: Arena.cpp:183
#define SM(sm)
Definition: Cuda.cpp:84
static bool CanThrow(Expr *E, ASTContext &Ctx)
Definition: CFG.cpp:2686
clang::CharUnits operator*(clang::CharUnits::QuantityType Scale, const clang::CharUnits &CU)
Definition: CharUnits.h:225
const Decl * D
Expr * E
enum clang::sema::@1718::IndirectLocalPathEntry::EntryKind Kind
static CGCXXABI * createCXXABI(CodeGenModule &CGM)
#define X(type, name)
Definition: Value.h:144
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
llvm::MachO::Target Target
Definition: MachO.h:51
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
This file declares types used to describe SYCL kernels.
SourceLocation Loc
Definition: SemaObjC.cpp:759
Defines the clang::SourceLocation class and associated facilities.
#define CXXABI(Name, Str)
Definition: TargetCXXABI.h:32
SourceLocation Begin
__device__ int
__SIZE_TYPE__ size_t
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:188
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.
QualType getUsingType(const UsingShadowDecl *Found, QualType Underlying) const
CanQualType AccumTy
Definition: ASTContext.h:1173
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
Definition: ASTContext.h:1192
SourceManager & getSourceManager()
Definition: ASTContext.h:741
TranslationUnitDecl * getTranslationUnitDecl() const
Definition: ASTContext.h:1141
const ConstantArrayType * getAsConstantArrayType(QualType T) const
Definition: ASTContext.h:2915
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.
bool areLaxCompatibleSveTypes(QualType FirstType, QualType SecondType)
Return true if the given vector types are lax-compatible SVE vector types, false otherwise.
llvm::PointerUnion< VarTemplateDecl *, MemberSpecializationInfo * > TemplateOrSpecializationInfo
A type synonym for the TemplateOrInstantiation mapping.
Definition: ASTContext.h:508
LangAS getOpenCLTypeAddrSpace(const Type *T) const
Get address space for OpenCL type.
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.
Definition: ASTContext.cpp:894
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
Definition: ASTContext.h:1191
uint64_t getTypeSize(const Type *T) const
Definition: ASTContext.h:2483
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.
Definition: ASTContext.h:896
BuiltinTemplateDecl * getBuiltinCommonTypeDecl() const
unsigned getManglingNumber(const NamedDecl *ND, bool ForAuxTarget=false) const
CanQualType LongTy
Definition: ASTContext.h:1169
const SmallVectorImpl< Type * > & getTypes() const
Definition: ASTContext.h:1292
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
Definition: ASTContext.h:1165
@ Weak
Weak definition of inline variable.
@ WeakUnknown
Weak for now, might become strong later in this TU.
const ProfileList & getProfileList() const
Definition: ASTContext.h:853
void setObjCConstantStringInterface(ObjCInterfaceDecl *Decl)
TypedefDecl * getObjCClassDecl() const
Retrieve the typedef declaration corresponding to the predefined Objective-C 'Class' type.
TypedefNameDecl * getTypedefNameForUnnamedTagDecl(const TagDecl *TD)
TypedefDecl * getCFConstantStringDecl() const
CanQualType Int128Ty
Definition: ASTContext.h:1169
CanQualType SatUnsignedFractTy
Definition: ASTContext.h:1182
CanQualType getAdjustedType(CanQualType Orig, CanQualType New) const
Definition: ASTContext.h:1471
BuiltinTemplateDecl * getMakeIntegerSeqDecl() 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 getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent, bool IsPack=false, ConceptDecl *TypeConstraintConcept=nullptr, ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
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
Definition: ASTContext.h:1091
bool AnyObjCImplementation()
Return true if there is at least one @implementation in the TU.
Definition: ASTContext.h:3197
CanQualType UnsignedShortAccumTy
Definition: ASTContext.h:1175
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)
Deallcates a DeclListNode by returning it to the ListNodeFreeList pool.
Definition: ASTContext.h:781
DeclListNode * AllocateDeclListNode(clang::NamedDecl *ND)
Allocates a DeclListNode or returns one from the ListNodeFreeList pool.
Definition: ASTContext.h:770
QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, ArrayRef< TemplateArgumentLoc > Args) const
QualType adjustFunctionResultType(QualType FunctionType, QualType NewResultType)
Change the result type of a function type, preserving sugar such as attributed types.
void setTemplateOrSpecializationInfo(VarDecl *Inst, TemplateOrSpecializationInfo TSI)
bool 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
Definition: ASTContext.h:2514
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
Definition: ASTContext.h:3559
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.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl.
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
QualType getBuiltinVaListType() const
Retrieve the type of the __builtin_va_list type.
Definition: ASTContext.h:2251
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:684
comments::FullComment * cloneFullComment(comments::FullComment *FC, const Decl *D) const
Definition: ASTContext.cpp:592
QualType getUnresolvedUsingType(const UnresolvedUsingTypenameDecl *Decl) const
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.
Definition: ASTContext.h:2218
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.
Definition: ASTContext.h:1966
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.
QualType getTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon=QualType()) const
std::unique_ptr< MangleNumberingContext > createMangleNumberingContext() const
CanQualType SatAccumTy
Definition: ASTContext.h:1178
QualType getUnsignedPointerDiffType() const
Return the unique unsigned counterpart of "ptrdiff_t" integer type.
QualType getucontext_tType() const
Retrieve the C ucontext_t type.
Definition: ASTContext.h:2125
QualType getRecordType(const RecordDecl *Decl) const
std::optional< CharUnits > getTypeSizeInCharsIfKnown(const Type *Ty) const
Definition: ASTContext.h:2507
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.
Definition: ASTContext.h:2265
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.
QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const
getInjectedClassNameType - Return the unique reference to the injected class name type for the specif...
QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a variable array of the specified element type.
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
CanQualType ShortAccumTy
Definition: ASTContext.h:1173
ASTMutationListener * getASTMutationListener() const
Retrieve a pointer to the AST mutation listener associated with this AST context, if any.
Definition: ASTContext.h:1289
IdentifierInfo * getBuiltinCommonTypeName() const
Definition: ASTContext.h:2069
unsigned NumImplicitCopyAssignmentOperatorsDeclared
The number of implicitly-declared copy assignment operators for which declarations were built.
Definition: ASTContext.h:3393
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,...
Definition: ASTContext.h:2521
unsigned char getFixedPointIBits(QualType Ty) const
QualType getCorrespondingSignedFixedPointType(QualType Ty) const
IntrusiveRefCntPtr< ExternalASTSource > ExternalSource
Definition: ASTContext.h:685
CanQualType FloatTy
Definition: ASTContext.h:1172
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.
Definition: ASTContext.h:1998
bool isObjCIdType(QualType T) const
Definition: ASTContext.h:3049
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.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Definition: ASTContext.h:2716
unsigned NumImplicitDestructorsDeclared
The number of implicitly-declared destructors for which declarations were built.
Definition: ASTContext.h:3407
bool isObjCClassType(QualType T) const
Definition: ASTContext.h:3055
void setObjCNSStringType(QualType T)
Definition: ASTContext.h:1985
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:857
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
Definition: ASTContext.h:2732
bool propertyTypesAreCompatible(QualType, QualType)
void setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst, UsingShadowDecl *Pattern)
CanQualType DoubleTy
Definition: ASTContext.h:1172
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateName Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
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
Definition: ASTContext.h:998
CanQualType SatLongAccumTy
Definition: ASTContext.h:1178
const XRayFunctionFilter & getXRayFilter() const
Definition: ASTContext.h:849
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.
QualType getFILEType() const
Retrieve the C FILE type.
Definition: ASTContext.h:2089
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.
Definition: ASTContext.h:2573
void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl)
Set the type for the C sigjmp_buf type.
Definition: ASTContext.h:2108
std::string getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl, bool Extended=false) const
Emit the encoded type for the method declaration Decl into S.
void DumpRecordLayout(const RecordDecl *RD, raw_ostream &OS, bool Simple=false) const
bool DeclMustBeEmitted(const Decl *D)
Determines if the decl can be CodeGen'ed or deserialized from PCH lazily, only when used; this is onl...
CanQualType LongDoubleTy
Definition: ASTContext.h:1172
CanQualType OMPArrayShapingTy
Definition: ASTContext.h:1201
ASTContext(LangOptions &LOpts, SourceManager &SM, IdentifierTable &idents, SelectorTable &sels, Builtin::Context &builtins, TranslationUnitKind TUKind)
Definition: ASTContext.cpp:913
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
Definition: ASTContext.h:1167
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 '...
Definition: ASTContext.h:2017
void addComment(const RawComment &RC)
Definition: ASTContext.cpp:346
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...
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod, bool IsBuiltin=false) const
Retrieves the default calling convention for the current target.
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'.
Definition: ASTContext.h:2024
void setFILEDecl(TypeDecl *FILEDecl)
Set the type for the C FILE type.
Definition: ASTContext.h:2086
QualType getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl, unsigned Index, std::optional< unsigned > PackIndex, SubstTemplateTypeParmTypeFlag Flag=SubstTemplateTypeParmTypeFlag::None) const
Retrieve a substitution-result 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
Definition: ASTContext.h:2921
QualType getMSGuidType() const
Retrieve the implicitly-predeclared 'struct _GUID' type.
Definition: ASTContext.h:2273
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...
const ASTRecordLayout & getASTObjCImplementationLayout(const ObjCImplementationDecl *D) const
Get or compute information about the layout of the specified Objective-C implementation.
CanQualType UnsignedLongFractTy
Definition: ASTContext.h:1177
QualType getEnumType(const EnumDecl *Decl) const
overridden_method_range overridden_methods(const CXXMethodDecl *Method) 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
Definition: ASTContext.h:1187
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
Definition: ASTContext.h:3061
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:760
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
CanQualType DependentTy
Definition: ASTContext.h:1188
IdentifierInfo * getMakeIntegerSeqName() const
Definition: ASTContext.h:2057
bool QIdProtocolsAdoptObjCObjectProtocols(QualType QT, ObjCInterfaceDecl *IDecl)
QIdProtocolsAdoptObjCObjectProtocols - Checks that protocols in QT's qualified-id protocol list adopt...
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...
IdentifierInfo * getTypePackElementName() const
Definition: ASTContext.h:2063
bool BlockRequiresCopying(QualType Ty, const VarDecl *D)
Returns true iff we need copy/dispose helpers for the given type.
CanQualType NullPtrTy
Definition: ASTContext.h:1187
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
Definition: ASTContext.h:1703
CanQualType WideCharTy
Definition: ASTContext.h:1164
CanQualType OMPIteratorTy
Definition: ASTContext.h:1201
IdentifierTable & Idents
Definition: ASTContext.h:680
std::vector< Decl * > getTraversalScope() const
Definition: ASTContext.h:726
TemplateName getSubstTemplateTemplateParm(TemplateName replacement, Decl *AssociatedDecl, unsigned Index, std::optional< unsigned > PackIndex) const
Builtin::Context & BuiltinInfo
Definition: ASTContext.h:682
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:834
QualType getConstType(QualType T) const
Return the uniqued reference to the type for a const qualified type.
Definition: ASTContext.h:1392
QualType getFunctionTypeWithoutPtrSizes(QualType T)
Get a function type and produce the equivalent function type where pointer size address spaces in the...
llvm::iterator_range< overridden_cxx_method_iterator > overridden_method_range
Definition: ASTContext.h:1063
SelectorTable & Selectors
Definition: ASTContext.h:681
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...
Definition: ASTContext.cpp:854
unsigned getMinGlobalAlignOfVar(uint64_t Size, const VarDecl *VD) const
Return the minimum alignement as specified by the target.
RawCommentList Comments
All comments in this translation unit.
Definition: ASTContext.h:867
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)
Definition: ASTContext.h:1962
TypedefDecl * getBOOLDecl() const
Retrieve declaration of 'BOOL' typedef.
Definition: ASTContext.h:2227
CanQualType SatShortFractTy
Definition: ASTContext.h:1181
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
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...
Definition: ASTContext.h:3330
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...
bool hasSameType(const Type *T1, const Type *T2) const
Definition: ASTContext.h:2735
QualType getObjCInstanceType()
Retrieve the Objective-C "instancetype" type, if already known; otherwise, returns a NULL type;.
Definition: ASTContext.h:2077
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:795
CanQualType Ibm128Ty
Definition: ASTContext.h:1172
void setASTMutationListener(ASTMutationListener *Listener)
Attach an AST mutation listener to the AST context.
Definition: ASTContext.h:1283
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:802
bool typesAreBlockPointerCompatible(QualType, QualType)
CanQualType SatUnsignedAccumTy
Definition: ASTContext.h:1179
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.
QualType getObjCProtoType() const
Retrieve the type of the Objective-C Protocol class.
Definition: ASTContext.h:2242
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)
Definition: ASTContext.h:1097
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
Definition: ASTContext.h:1200
QualType getCanonicalTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args) const
CanQualType ObjCBuiltinIdTy
Definition: ASTContext.h:1192
overridden_cxx_method_iterator overridden_methods_end(const CXXMethodDecl *Method) const
VTableContextBase * getVTableContext()
void setBOOLDecl(TypedefDecl *TD)
Save declaration of 'BOOL' typedef.
Definition: ASTContext.h:2232
llvm::SetVector< const ValueDecl * > CUDAExternalDeviceDeclODRUsedByHost
Keep track of CUDA/HIP external kernels or device variables ODR-used by host code.
Definition: ASTContext.h:1241
ComparisonCategories CompCategories
Types and expressions required to build C++2a three-way comparisons using operator<=>,...
Definition: ASTContext.h:2413
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
QualType AutoDeductTy
Definition: ASTContext.h:1223
CanQualType BoolTy
Definition: ASTContext.h:1161
void cacheRawCommentForDecl(const Decl &OriginalD, const RawComment &Comment) const
Attaches Comment to OriginalD and to its redeclaration chain and removes the redeclaration chain from...
Definition: ASTContext.cpp:504
void attachCommentsToJustParsedDecls(ArrayRef< Decl * > Decls, const Preprocessor *PP)
Searches existing comments for doc comments that should be attached to Decls.
Definition: ASTContext.cpp:530
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth,...
llvm::BumpPtrAllocator & getAllocator() const
Definition: ASTContext.h:750
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
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:844
struct clang::ASTContext::CUDAConstantEvalContext CUDAConstantEvalCtx
IdentifierInfo * getNSObjectName() const
Retrieve the identifier 'NSObject'.
Definition: ASTContext.h:2029
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.
Definition: ASTContext.h:2206
QualType getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
std::string getObjCEncodingForFunctionDecl(const FunctionDecl *Decl) const
Emit the encoded type for the function Decl into S.
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
Definition: ASTContext.h:3010
CanQualType UnsignedFractTy
Definition: ASTContext.h:1177
QualType getjmp_bufType() const
Retrieve the C jmp_buf type.
Definition: ASTContext.h:2101
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.
Definition: ASTContext.h:2113
void addOverriddenMethod(const CXXMethodDecl *Method, const CXXMethodDecl *Overridden)
Note that the given C++ Method overrides the given Overridden method.
const TargetInfo * getAuxTargetInfo() const
Definition: ASTContext.h:800
CanQualType Float128Ty
Definition: ASTContext.h:1172
CanQualType ObjCBuiltinClassTy
Definition: ASTContext.h:1192
unsigned NumImplicitDefaultConstructorsDeclared
The number of implicitly-declared default constructors for which declarations were built.
Definition: ASTContext.h:3372
CanQualType UnresolvedTemplateTy
Definition: ASTContext.h:1188
void setucontext_tDecl(TypeDecl *ucontext_tDecl)
Set the type for the C ucontext_t type.
Definition: ASTContext.h:2120
OMPTraitInfo & getNewOMPTraitInfo()
Return a new OMPTraitInfo object owned by this context.
CanQualType UnsignedLongTy
Definition: ASTContext.h:1170
llvm::DenseSet< const FunctionDecl * > CUDAImplicitHostDeviceFunUsedByDevice
Keep track of CUDA/HIP implicit host device functions used on device side in device compilation.
Definition: ASTContext.h:1245
void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass, SmallVectorImpl< const ObjCIvarDecl * > &Ivars) const
DeepCollectObjCIvars - This routine first collects all declared, but not synthesized,...
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
Definition: ASTContext.h:3014
const TranslationUnitKind TUKind
Definition: ASTContext.h:683
QualType getQualifiedType(const Type *T, Qualifiers Qs) const
Return a type with additional qualifiers.
Definition: ASTContext.h:2303
CanQualType UnsignedLongAccumTy
Definition: ASTContext.h:1175
QualType AutoRRefDeductTy
Definition: ASTContext.h:1224
QualType getRestrictType(QualType T) const
Return the uniqued reference to the type for a restrict qualified type.
Definition: ASTContext.h:1372
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
TypeInfo getTypeInfo(const Type *T) const
Get the size and alignment of the specified complete type in bits.
CanQualType ShortFractTy
Definition: ASTContext.h:1176
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.
Definition: ASTContext.h:2237
TypeSourceInfo * getTemplateSpecializationTypeInfo(TemplateName T, SourceLocation TLoc, const TemplateArgumentListInfo &Args, QualType Canon=QualType()) const
QualType getSubstTemplateTypeParmPackType(Decl *AssociatedDecl, unsigned Index, bool Final, const TemplateArgument &ArgPack)
Retrieve a.
llvm::DenseMap< const CXXMethodDecl *, CXXCastPath > LambdaCastPaths
For capturing lambdas with an explicit object parameter whose type is derived from the lambda type,...
Definition: ASTContext.h:1256
CanQualType BoundMemberTy
Definition: ASTContext.h:1188
CanQualType SatUnsignedShortFractTy
Definition: ASTContext.h:1182
CanQualType CharTy
Definition: ASTContext.h:1162
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:870
BlockVarCopyInit getBlockVarCopyInit(const VarDecl *VD) const
Get the copy initialization expression of the VarDecl VD, or nullptr if none exists.
unsigned NumImplicitMoveConstructorsDeclared
The number of implicitly-declared move constructors for which declarations were built.
Definition: ASTContext.h:3386
unsigned NumImplicitCopyConstructorsDeclared
The number of implicitly-declared copy constructors for which declarations were built.
Definition: ASTContext.h:3379
CanQualType IntTy
Definition: ASTContext.h:1169
llvm::DenseSet< const VarDecl * > CUDADeviceVarODRUsedByHost
Keep track of CUDA/HIP device-side variables ODR-used by host code.
Definition: ASTContext.h:1237
CanQualType PseudoObjectTy
Definition: ASTContext.h:1191
QualType getWebAssemblyExternrefType() const
Return a WebAssembly externref type.
void setTraversalScope(const std::vector< Decl * > &)
Definition: ASTContext.cpp:980
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
Definition: ASTContext.h:1452
friend class NestedNameSpecifier
Definition: ASTContext.h:189
void PrintStats() const
Definition: ASTContext.cpp:994
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.
Definition: ASTContext.cpp:607
unsigned NumImplicitDestructors
The number of implicitly-declared destructors.
Definition: ASTContext.h:3403
CanQualType Float16Ty
Definition: ASTContext.h:1186
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
Definition: ASTContext.h:2289
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, TagDecl *OwnedTagDecl=nullptr) const
bool isAlignmentRequired(const Type *T) const
Determine if the alignment the type has was required using an alignment attribute.
TagDecl * MSGuidTagDecl
Definition: ASTContext.h:1231
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
Definition: ASTContext.h:1169
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
ASTMutationListener * Listener
Definition: ASTContext.h:686
QualType getPackExpansionType(QualType Pattern, std::optional< unsigned > NumExpansions, bool ExpectPackInType=true) const
Form a pack expansion type with the given pattern.
void setNonKeyFunction(const CXXMethodDecl *method)
Observe that the given method cannot be a key function.
CanQualType ObjCBuiltinBoolTy
Definition: ASTContext.h:1193
TypeInfoChars getTypeInfoInChars(const Type *T) 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.
Definition: ASTContext.h:1528
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:742
CanQualType OverloadTy
Definition: ASTContext.h:1188
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.
CanQualType OCLClkEventTy
Definition: ASTContext.h:1197
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.
Definition: ASTContext.h:2541
const clang::PrintingPolicy & getPrintingPolicy() const
Definition: ASTContext.h:733
ArrayRef< Module * > getModulesWithMergedDefinition(const NamedDecl *Def)
Get the additional modules in which the definition Def has been merged.
static ImportDecl * getNextLocalImport(ImportDecl *Import)
Definition: ASTContext.h:1087
llvm::FixedPointSemantics getFixedPointSemantics(QualType Ty) const
QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a dependently-sized array of the specified element type...
uint64_t lookupFieldBitOffset(const ObjCInterfaceDecl *OID, const ObjCImplementationDecl *ID, const ObjCIvarDecl *Ivar) const
Get the offset of an ObjCIvarDecl in bits.
CanQualType SatUnsignedShortAccumTy
Definition: ASTContext.h:1179
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.
Definition: ASTContext.cpp:422
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.
static bool isObjCNSObjectType(QualType Ty)
Return true if this is an NSObject object with its NSObject attribute set.
Definition: ASTContext.h:2462
GVALinkage GetGVALinkageForVariable(const VarDecl *VD) const
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)...
Definition: ASTContext.h:1915
QualType getObjCIdType() const
Represents the Objective-CC id type.
Definition: ASTContext.h:2196
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...
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
Definition: ASTContext.h:2763
QualType getCorrespondingUnsaturatedType(QualType Ty) const
comments::FullComment * getCommentForDecl(const Decl *D, const Preprocessor *PP) const
Return parsed documentation comment attached to a given declaration.
Definition: ASTContext.cpp:612
FunctionProtoType::ExceptionSpecInfo mergeExceptionSpecs(FunctionProtoType::ExceptionSpecInfo ESI1, FunctionProtoType::ExceptionSpecInfo ESI2, SmallVectorImpl< QualType > &ExceptionTypeStorage, bool AcceptDependent)
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.
Definition: ASTContext.h:1250
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.
const CXXRecordDecl * baseForVTableAuthentication(const CXXRecordDecl *ThisClass)
Resolve the root record to be used to derive the vtable pointer authentication policy for the specifi...
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
Definition: ASTContext.h:2482
CanQualType UnsignedInt128Ty
Definition: ASTContext.h:1171
CanQualType BuiltinFnTy
Definition: ASTContext.h:1190
ObjCInterfaceDecl * getObjCProtocolDecl() const
Retrieve the Objective-C class declaration corresponding to the predefined Protocol class.
unsigned NumImplicitDefaultConstructors
The number of implicitly-declared default constructors.
Definition: ASTContext.h:3368
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
unsigned NumImplicitMoveAssignmentOperatorsDeclared
The number of implicitly-declared move assignment operators for which declarations were built.
Definition: ASTContext.h:3400
void setManglingNumber(const NamedDecl *ND, unsigned Number)
llvm::DenseMap< const Decl *, const RawComment * > DeclRawComments
Mapping from declaration to directly attached comment.
Definition: ASTContext.h:876
CanQualType OCLSamplerTy
Definition: ASTContext.h:1197
TypedefDecl * getBuiltinVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_va_list type.
TypeInfo getTypeInfo(QualType T) const
Definition: ASTContext.h:2476
CanQualType VoidTy
Definition: ASTContext.h:1160
CanQualType UnsignedCharTy
Definition: ASTContext.h:1170
CanQualType UnsignedShortFractTy
Definition: ASTContext.h:1177
BuiltinTemplateDecl * buildBuiltinTemplateDecl(BuiltinTemplateKind BTK, const IdentifierInfo *II) const
void * Allocate(size_t Size, unsigned Align=8) const
Definition: ASTContext.h:754
bool canBuiltinBeRedeclared(const FunctionDecl *) const
Return whether a declaration to a builtin is allowed to be overloaded/redeclared.
CanQualType UnsignedIntTy
Definition: ASTContext.h:1170
TemplateName getDependentTemplateName(NestedNameSpecifier *NNS, const IdentifierInfo *Name) const
Retrieve the template name that represents a dependent template name such as MetaFun::template apply.
unsigned NumImplicitMoveConstructors
The number of implicitly-declared move constructors.
Definition: ASTContext.h:3382
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.
Definition: ASTContext.h:1381
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.
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
QualType getObjCClassRedefinitionType() const
Retrieve the type that Class has been defined to, which may be different from the built-in Class if C...
Definition: ASTContext.h:2004
TagDecl * getMSGuidTagDecl() const
Retrieve the implicitly-predeclared 'struct _GUID' declaration.
Definition: ASTContext.h:2270
QualType getExceptionObjectType(QualType T) const
CanQualType UnknownAnyTy
Definition: ASTContext.h:1189
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
Definition: ASTContext.h:1676
CanQualType UnsignedLongLongTy
Definition: ASTContext.h:1171
QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error, unsigned *IntegerConstantArgs=nullptr) const
Return the type for the specified builtin.
QualType getCommonSugaredType(QualType X, QualType Y, bool Unqualified=false)
CanQualType OCLReserveIDTy
Definition: ASTContext.h:1198
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.
size_t getASTAllocatedMemory() const
Return the total amount of physical memory allocated for representing AST nodes and type information.
Definition: ASTContext.h:788
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
Definition: ASTContext.h:1170
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
Definition: ASTContext.h:1977
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.
Definition: ASTContext.h:1681
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
bool canAssignObjCInterfacesInBlockPointer(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT, bool BlockReturnType)
canAssignObjCInterfacesInBlockPointer - This routine is specifically written for providing type-safet...
CanQualType SatUnsignedLongFractTy
Definition: ASTContext.h:1183
void setcudaConfigureCallDecl(FunctionDecl *FD)
Definition: ASTContext.h:1533
CanQualType getDecayedType(CanQualType T) const
Definition: ASTContext.h:1480
QualType getObjCIdRedefinitionType() const
Retrieve the type that id has been defined to, which may be different from the built-in id if id has ...
Definition: ASTContext.h:1991
const CXXConstructorDecl * getCopyConstructorForExceptionObject(CXXRecordDecl *RD)
QualType getDependentAddressSpaceType(QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttrLoc) const
QualType getPackIndexingType(QualType Pattern, Expr *IndexExpr, bool FullySubstituted=false, ArrayRef< QualType > Expansions={}, int Index=-1) const
RawComment * getRawCommentForDeclNoCache(const Decl *D) const
Return the documentation comment attached to a given declaration, without looking into cache.
Definition: ASTContext.cpp:313
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.
Definition: ASTContext.h:3175
const VariableArrayType * getAsVariableArrayType(QualType T) const
Definition: ASTContext.h:2918
QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType, UnaryTransformType::UTTKind UKind) const
Unary type transforms.
const Type * getCanonicalType(const Type *T) const
Definition: ASTContext.h:2720
void setExternalSource(IntrusiveRefCntPtr< ExternalASTSource > Source)
Attach an external AST source to the AST context.
Definition: ASTContext.cpp:990
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
Definition: ASTContext.h:1169
StringLiteral * getPredefinedStringLiteralFromCache(StringRef Key) const
Return a string representing the human readable name for the specified function declaration or file n...
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.
bool areCompatibleSveTypes(QualType FirstType, QualType SecondType)
Return true if the given types are an SVE builtin and a VectorType that is a fixed-length representat...
void setObjCClassRedefinitionType(QualType RedefType)
Set the user-written type that redefines 'SEL'.
Definition: ASTContext.h:2011
bool hasDirectOwnershipQualifier(QualType Ty) const
Return true if the type has been explicitly qualified with ObjC ownership.
CanQualType FractTy
Definition: ASTContext.h:1176
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)
FunctionDecl * getcudaConfigureCallDecl()
Definition: ASTContext.h:1537
DiagnosticsEngine & getDiagnostics() const
llvm::StringRef backupStr(llvm::StringRef S) const
Definition: ASTContext.h:762
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...
Definition: ASTContext.h:2324
void ResetObjCLayout(const ObjCContainerDecl *CD)
CanQualType LongAccumTy
Definition: ASTContext.h:1174
interp::Context & getInterpContext()
Returns the clang bytecode interpreter context.
Definition: ASTContext.cpp:887
CanQualType Char32Ty
Definition: ASTContext.h:1168
QualType getCVRQualifiedType(QualType T, unsigned CVR) const
Return a type with additional const, volatile, or restrict qualifiers.
Definition: ASTContext.h:2284
UnnamedGlobalConstantDecl * getUnnamedGlobalConstantDecl(QualType Ty, const APValue &Value) const
Return a declaration for a uniquified anonymous global constant corresponding to a given APValue.
CanQualType SatFractTy
Definition: ASTContext.h:1181
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size.
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
Definition: ASTContext.h:1181
const TargetInfo & getTargetInfo() const
Definition: ASTContext.h:799
void setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst, FieldDecl *Tmpl)
CanQualType OCLQueueTy
Definition: ASTContext.h:1198
CanQualType LongFractTy
Definition: ASTContext.h:1176
CanQualType SatShortAccumTy
Definition: ASTContext.h:1178
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
CanQualType BFloat16Ty
Definition: ASTContext.h:1185
unsigned NumImplicitCopyConstructors
The number of implicitly-declared copy constructors.
Definition: ASTContext.h:3375
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
CanQualType IncompleteMatrixIdxTy
Definition: ASTContext.h:1199
std::optional< CharUnits > getTypeSizeInCharsIfKnown(QualType Ty) const
Definition: ASTContext.h:2501
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.
Definition: ASTContext.h:2312
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
Definition: ASTContext.h:1981
TargetCXXABI::Kind getCXXABIKind() const
Return the C++ ABI kind that should be used.
Definition: ASTContext.cpp:861
void setjmp_bufDecl(TypeDecl *jmp_bufDecl)
Set the type for the C jmp_buf type.
Definition: ASTContext.h:2096
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.
Definition: ASTContext.h:3261
bool UnwrapSimilarTypes(QualType &T1, QualType &T2, bool AllowPiMismatch=true) const
Attempt to unwrap two types that may be similar (C++ [conv.qual]).
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
Definition: ASTContext.h:1274
uint64_t getConstantArrayElementCount(const ConstantArrayType *CA) const
Return number of constant array elements.
BuiltinTemplateDecl * getTypePackElementDecl() const
CanQualType SatUnsignedLongAccumTy
Definition: ASTContext.h:1180
QualType getUnconstrainedType(QualType T) const
Remove any type constraints from a template parameter type, for equivalence comparison of template pa...
CanQualType LongLongTy
Definition: ASTContext.h:1169
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.
Definition: ASTContext.h:2294
llvm::DenseMap< const Decl *, const Decl * > CommentlessRedeclChains
Keeps track of redeclaration chains that don't have any comment attached.
Definition: ASTContext.h:892
uint64_t getArrayInitLoopExprElementCount(const ArrayInitLoopExpr *AILE) const
Return number of elements initialized in an ArrayInitLoopExpr.
void deduplicateMergedDefinitonsFor(NamedDecl *ND)
Clean up the merged definition list.
unsigned getTargetAddressSpace(LangAS AS) const
QualType getWideCharType() const
Return the type of wide characters.
Definition: ASTContext.h:1920
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...
void addTranslationUnitDecl()
Definition: ASTContext.h:1144
CanQualType WCharTy
Definition: ASTContext.h:1163
bool hasSameNullabilityTypeQualifier(QualType SubT, QualType SuperT, bool IsParam) const
Definition: ASTContext.h:2768
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.
Definition: ASTContext.h:3389
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:757
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:883
CanQualType getSignedSizeType() const
Return the unique signed counterpart of the integer type corresponding to size_t.
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.
Definition: ASTContext.h:2334
QualType getDecltypeType(Expr *e, QualType UnderlyingType) const
C++11 decltype.
QualType getLogicalOperationType() const
The result type of logical operations, '<', '>', '!=', etc.
Definition: ASTContext.h:2132
NestedNameSpecifier * getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const
Retrieves the "canonical" nested name specifier for a given nested name specifier.
QualType getTypedefType(const TypedefNameDecl *Decl, QualType Underlying=QualType()) const
Return the unique reference to the type for the specified typedef-name decl.
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)
Definition: ASTContext.h:1101
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'.
Definition: ASTContext.h:2051
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...
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
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.
Definition: ASTContext.h:2384
@ GE_Missing_stdio
Missing a type from <stdio.h>
Definition: ASTContext.h:2390
@ GE_Missing_type
Missing a type.
Definition: ASTContext.h:2387
@ GE_Missing_ucontext
Missing a type from <ucontext.h>
Definition: ASTContext.h:2396
@ GE_Missing_setjmp
Missing a type from <setjmp.h>
Definition: ASTContext.h:2393
QualType adjustStringLiteralBaseType(QualType StrLTy) const
uint16_t getPointerAuthTypeDiscriminator(QualType T)
Return the "other" type-specific discriminator for the given type.
QualType getTypeOfExprType(Expr *E, TypeOfKind Kind) const
C23 feature and GCC extension.
CanQualType Char8Ty
Definition: ASTContext.h:1166
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.
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
Definition: ASTContext.h:1184
CanQualType UnsignedAccumTy
Definition: ASTContext.h:1175
void setObjCMethodRedeclaration(const ObjCMethodDecl *MD, const ObjCMethodDecl *Redecl)
void addTypedefNameForUnnamedTagDecl(TagDecl *TD, TypedefNameDecl *TND)
bool isDependenceAllowed() const
Definition: ASTContext.h:840
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.
Definition: ASTContext.h:1934
QualType getVariableArrayDecayedType(QualType Ty) const
Returns a vla type where known sizes are replaced with [*].
bool isInSameModule(const Module *M1, const Module *M2)
If the two module M1 and M2 are in the same module.
void setCFConstantStringType(QualType T)
ASTContext & operator=(const ASTContext &)=delete
Module * getCurrentNamedModule() const
Get module under construction, nullptr if this is not a C++20 module.
Definition: ASTContext.h:1133
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...
CanQualType OCLEventTy
Definition: ASTContext.h:1197
void setPrintingPolicy(const clang::PrintingPolicy &Policy)
Definition: ASTContext.h:737
void AddDeallocation(void(*Callback)(void *), void *Data) const
Add a deallocation callback that will be invoked when the ASTContext is destroyed.
Definition: ASTContext.cpp:985
AttrVec & getDeclAttrs(const Decl *D)
Retrieve the attributes for the given declaration.
CXXMethodVector::const_iterator overridden_cxx_method_iterator
Definition: ASTContext.h:1053
RawComment * getRawCommentForDeclNoCacheImpl(const Decl *D, const SourceLocation RepresentativeLocForDecl, const std::map< unsigned, RawComment * > &CommentsInFile) const
Definition: ASTContext.cpp:235
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
Definition: ASTContext.h:2513
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'.
Definition: ASTContext.h:2038
uint64_t getCharWidth() const
Return the size of the character type, in bits.
Definition: ASTContext.h:2486
CanQualType getPointerType(CanQualType T) const
Definition: ASTContext.h:1459
QualType getUnqualifiedArrayType(QualType T) const
Definition: ASTContext.h:2756
import_range local_imports() const
Definition: ASTContext.h:1093
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
Definition: ASTContext.h:2924
unsigned NumImplicitMoveAssignmentOperators
The number of implicitly-declared move assignment operators.
Definition: ASTContext.h:3396
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:383
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
Definition: RecordLayout.h:38
Writes an AST file containing the contents of a translation unit.
Definition: ASTWriter.h:89
Represents a loop initializing the elements of an array.
Definition: Expr.h:5752
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition: Type.h:3577
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Definition: Expr.h:6678
Attr - This represents one attribute.
Definition: Attr.h:43
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:6414
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: Type.h:3034
Holds information about both target-independent and target-specific builtins, allowing easy queries b...
Definition: Builtins.h:85
Implements C++ ABI-specific semantic analysis functions.
Definition: CXXABI.h:29
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2553
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2078
Represents a C++ struct/union/class.
Definition: DeclCXX.h:258
static CanQual< Type > CreateUnsafe(QualType Other)
Builds a canonical type from a QualType.
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
Definition: CanonicalType.h:84
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: Type.h:3615
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1435
A list storing NamedDecls in the lookup tables.
Definition: DeclBase.h:1315
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
Definition: DeclBase.h:1065
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
Definition: DeclBase.h:198
DeclarationNameTable is used to store and retrieve DeclarationName instances for the various kinds of...
The name of a declaration.
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:735
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
Definition: Type.h:6522
Represents an array type in C++ whose size is a value-dependent expression.
Definition: Type.h:3862
An allocator for DiagnosticStorage objects, which uses a small cache to objects, used to reduce mallo...
Definition: Diagnostic.h:192
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:231
Container for either a single DynTypedNode or for an ArrayRef to DynTypedNode.
Represents an enum.
Definition: Decl.h:3847
This represents one expression.
Definition: Expr.h:110
Declaration context for names declared as extern "C" in C++.
Definition: Decl.h:226
Abstract interface for external sources of AST nodes.
Represents a member of a struct/union/class.
Definition: Decl.h:3033
A SourceLocation and its associated SourceManager.
Represents a function declaration or definition.
Definition: Decl.h:1935
Represents a prototype with parameter type info, e.g.
Definition: Type.h:5102
A class which abstracts out some details necessary for making a call.
Definition: Type.h:4432
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:4321
GlobalDecl - represents a global declaration.
Definition: GlobalDecl.h:56
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:4786
Represents a C array with an unspecified size.
Definition: Type.h:3764
Provides support for incremental compilation.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:499
A global _GUID constant.
Definition: DeclCXX.h:4307
MangleContext - Context for tracking state which persists across multiple calls to the C++ name mangl...
Definition: Mangle.h:45
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...
Definition: DeclTemplate.h:620
Describes a module or submodule.
Definition: Module.h:115
This represents a decl that may have a name.
Definition: Decl.h:253
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:2328
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
Definition: DeclObjC.h:2544
ObjCContainerDecl - Represents a container for method declarations.
Definition: DeclObjC.h:947
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2596
Represents an ObjC class declaration.
Definition: DeclObjC.h:1153
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1951
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:140
Represents a pointer to an Objective C object.
Definition: Type.h:7580
Represents a class type in Objective C.
Definition: Type.h:7326
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:730
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition: DeclObjC.h:2804
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2083
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:578
Represents a parameter to a function.
Definition: Decl.h:1725
Pointer-authentication qualifiers.
Definition: Type.h:151
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:138
A (possibly-)qualified type.
Definition: Type.h:929
PointerAuthQualifier getPointerAuth() const
Definition: Type.h:1448
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition: Type.h:7931
A qualifier set is used to build a set of qualifiers.
Definition: Type.h:7871
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
Definition: Type.h:7878
The collection of all-type qualifiers we support.
Definition: Type.h:324
@ OCL_None
There is no lifetime qualification on this type.
Definition: Type.h:343
void removeObjCLifetime()
Definition: Type.h:544
bool hasNonFastQualifiers() const
Return true if the set contains any qualifiers which require an ExtQuals node to be allocated.
Definition: Type.h:631
unsigned getFastQualifiers() const
Definition: Type.h:612
static Qualifiers fromCVRMask(unsigned CVR)
Definition: Type.h:428
void setPointerAuth(PointerAuthQualifier Q)
Definition: Type.h:599
void addObjCLifetime(ObjCLifetime type)
Definition: Type.h:545
This class represents all comments included in the translation unit, sorted in order of appearance in...
Represents a struct/union/class.
Definition: Decl.h:4148
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
Definition: Decl.h:4981
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.
A trivial tuple used to represent a source range.
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
Definition: Diagnostic.h:1102
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1778
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3564
Kind
The basic C++ ABI kind.
Definition: TargetCXXABI.h:31
Exposes information about the current target.
Definition: TargetInfo.h:220
A convenient class for passing around template argument information.
Definition: TemplateBase.h:632
Represents a template argument.
Definition: TemplateBase.h:61
Represents a C++ template name within the type system.
Definition: TemplateName.h:220
A template parameter object.
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:73
Declaration of a template type parameter.
The top declaration context.
Definition: Decl.h:84
static TranslationUnitDecl * Create(ASTContext &C)
Definition: Decl.cpp:5295
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:3370
A container of type source information.
Definition: Type.h:7902
The base class of the type hierarchy.
Definition: Type.h:1828
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
Definition: Type.cpp:2201
bool isObjCNSObjectType() const
Definition: Type.cpp:5016
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:2706
QualType getCanonicalTypeInternal() const
Definition: Type.h:2989
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
Definition: Type.cpp:2396
std::optional< NullabilityKind > getNullability() const
Determine the nullability of the given type.
Definition: Type.cpp:4763
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Definition: Decl.h:3514
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3413
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
Definition: DeclCXX.h:4364
The iterator over UnresolvedSets.
Definition: UnresolvedSet.h:35
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3977
Represents a C++ using-enum-declaration.
Definition: DeclCXX.h:3731
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition: DeclCXX.h:3338
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:671
Represents a variable declaration or definition.
Definition: Decl.h:882
Represents a C array with a specified size that is not an integer-constant-expression.
Definition: Type.h:3808
Represents a GCC generic vector type.
Definition: Type.h:4034
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:1083
Holds all information required to evaluate constexpr code in a module.
Definition: Context.h:40
bool operator!=(const CommonEntityInfo &LHS, const CommonEntityInfo &RHS)
Definition: Types.h:129
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:43
The JSON file list parser is used to communicate input to InstallAPI.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:21
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: Type.h:1778
bool isTargetAddressSpace(LangAS AS)
Definition: AddressSpaces.h:77
OpenCLTypeKind
OpenCL type kinds.
Definition: TargetInfo.h:206
NullabilityKind
Describes the nullability of a particular type.
Definition: Specifiers.h:336
@ Nullable
Values of this type can be null.
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
@ NonNull
Values of this type can never be null.
TypeOfKind
The kind of 'typeof' expression we're after.
Definition: Type.h:910
bool operator==(const CallGraphNode::CallRecord &LHS, const CallGraphNode::CallRecord &RHS)
Definition: CallGraph.h:204
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
Selector GetUnarySelector(StringRef name, ASTContext &Ctx)
Utility function for constructing an unary selector.
Definition: ASTContext.h:3598
@ Result
The result type of a method or function.
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition: Type.h:3574
SubstTemplateTypeParmTypeFlag
Definition: Type.h:1789
Selector GetNullarySelector(StringRef name, ASTContext &Ctx)
Utility function for constructing a nullary selector.
Definition: ASTContext.h:3592
TagTypeKind
The kind of a tag type.
Definition: Type.h:6871
BuiltinTemplateKind
Kinds of BuiltinTemplateDecl.
Definition: Builtins.h:305
LangAS
Defines the address space values used by the address space qualifier of QualType.
Definition: AddressSpaces.h:25
TranslationUnitKind
Describes the kind of translation unit being processed.
Definition: LangOptions.h:1096
@ TU_Incremental
The translation unit is a is a complete translation unit that we might incrementally extend later.
Definition: LangOptions.h:1109
FloatModeKind
Definition: TargetInfo.h:73
const FunctionProtoType * T
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
Definition: ASTContext.h:117
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
VectorKind
Definition: Type.h:3993
AlignRequirementKind
Definition: ASTContext.h:144
@ None
The alignment was not explicit in code.
@ RequiredByEnum
The alignment comes from an alignment attribute on a enum type.
@ RequiredByTypedef
The alignment comes from an alignment attribute on a typedef.
@ RequiredByRecord
The alignment comes from an alignment attribute on a record type.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition: Type.h:6846
@ Other
Other implicit parameter.
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30
BuiltinVectorTypeInfo(QualType ElementType, llvm::ElementCount EC, unsigned NumVectors)
Definition: ASTContext.h:1605
CUDAConstantEvalContextRAII(ASTContext &Ctx_, bool NoWrongSidedVars)
Definition: ASTContext.h:698
bool NoWrongSidedVars
Do not allow wrong-sided variables in constant expressions.
Definition: ASTContext.h:693
SourceLocation PragmaSectionLocation
Definition: ASTContext.h:3549
SectionInfo(NamedDecl *Decl, SourceLocation PragmaSectionLocation, int SectionFlags)
Definition: ASTContext.h:3553
Copy initialization expr of a __block variable and a boolean flag that indicates whether the expressi...
Definition: Expr.h:6460
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
Holds information about the various types of exception specification.
Definition: Type.h:5159
Extra information about a function prototype.
Definition: Type.h:5187
A cache of the value of this pointer, in the most recent generation in which we queried it.
A lazy value (of type T) that is within an AST node of type Owner, where the value might change in la...
llvm::PointerUnion< T, LazyData * > ValueType
Parts of a decomposed MSGuidDecl.
Definition: DeclCXX.h:4282
Contains information gathered from parsing the contents of TargetAttr.
Definition: TargetInfo.h:58
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:57
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
Definition: Type.h:862
const Type * Ty
The locally-unqualified type.
Definition: Type.h:864
Qualifiers Quals
The local qualifiers.
Definition: Type.h:867
AlignRequirementKind AlignRequirement
Definition: ASTContext.h:175
TypeInfoChars(CharUnits Width, CharUnits Align, AlignRequirementKind AlignRequirement)
Definition: ASTContext.h:178
bool isAlignRequired()
Definition: ASTContext.h:167
AlignRequirementKind AlignRequirement
Definition: ASTContext.h:161
uint64_t Width
Definition: ASTContext.h:159
unsigned Align
Definition: ASTContext.h:160
TypeInfo(uint64_t Width, unsigned Align, AlignRequirementKind AlignRequirement)
Definition: ASTContext.h:164