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