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