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