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