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.
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
171
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::FoldingSet<PackExpansionType> PackExpansionTypes;
245 mutable llvm::FoldingSet<ObjCObjectTypeImpl> ObjCObjectTypes;
246 mutable llvm::FoldingSet<ObjCObjectPointerType> ObjCObjectPointerTypes;
247 mutable llvm::FoldingSet<UnaryTransformType> UnaryTransformTypes;
248 // An AutoType can have a dependency on another AutoType via its template
249 // arguments. Since both dependent and dependency are on the same set,
250 // we can end up in an infinite recursion when looking for a node if we used
251 // a `FoldingSet`, since both could end up in the same bucket.
252 mutable llvm::DenseMap<llvm::FoldingSetNodeID, AutoType *> AutoTypes;
253 mutable llvm::FoldingSet<DeducedTemplateSpecializationType>
254 DeducedTemplateSpecializationTypes;
255 mutable llvm::FoldingSet<AtomicType> AtomicTypes;
256 mutable llvm::FoldingSet<AttributedType> AttributedTypes;
257 mutable llvm::FoldingSet<PipeType> PipeTypes;
258 mutable llvm::FoldingSet<BitIntType> BitIntTypes;
259 mutable llvm::ContextualFoldingSet<DependentBitIntType, ASTContext &>
260 DependentBitIntTypes;
261 mutable llvm::FoldingSet<BTFTagAttributedType> BTFTagAttributedTypes;
262 llvm::FoldingSet<HLSLAttributedResourceType> HLSLAttributedResourceTypes;
263 llvm::FoldingSet<HLSLInlineSpirvType> HLSLInlineSpirvTypes;
264
265 mutable llvm::FoldingSet<CountAttributedType> CountAttributedTypes;
266
267 mutable llvm::FoldingSet<QualifiedTemplateName> QualifiedTemplateNames;
268 mutable llvm::FoldingSet<DependentTemplateName> DependentTemplateNames;
269 mutable llvm::FoldingSet<SubstTemplateTemplateParmStorage>
270 SubstTemplateTemplateParms;
271 mutable llvm::ContextualFoldingSet<SubstTemplateTemplateParmPackStorage,
272 ASTContext&>
273 SubstTemplateTemplateParmPacks;
274 mutable llvm::ContextualFoldingSet<DeducedTemplateStorage, ASTContext &>
275 DeducedTemplates;
276
277 mutable llvm::ContextualFoldingSet<ArrayParameterType, ASTContext &>
278 ArrayParameterTypes;
279
280 /// Store the unique Type corresponding to each Kind.
281 mutable std::array<Type *,
282 llvm::to_underlying(PredefinedSugarType::Kind::Last) + 1>
283 PredefinedSugarTypes{};
284
285 /// Internal storage for NestedNameSpecifiers.
286 ///
287 /// This set is managed by the NestedNameSpecifier class.
288 mutable llvm::FoldingSet<NamespaceAndPrefixStorage>
289 NamespaceAndPrefixStorages;
290
291 /// A cache mapping from RecordDecls to ASTRecordLayouts.
292 ///
293 /// This is lazily created. This is intentionally not serialized.
294 mutable llvm::DenseMap<const RecordDecl*, const ASTRecordLayout*>
295 ASTRecordLayouts;
296 mutable llvm::DenseMap<const ObjCInterfaceDecl *, const ASTRecordLayout *>
297 ObjCLayouts;
298
299 /// A cache from types to size and alignment information.
300 using TypeInfoMap = llvm::DenseMap<const Type *, struct TypeInfo>;
301 mutable TypeInfoMap MemoizedTypeInfo;
302
303 /// A cache from types to unadjusted alignment information. Only ARM and
304 /// AArch64 targets need this information, keeping it separate prevents
305 /// imposing overhead on TypeInfo size.
306 using UnadjustedAlignMap = llvm::DenseMap<const Type *, unsigned>;
307 mutable UnadjustedAlignMap MemoizedUnadjustedAlign;
308
309 /// A cache mapping from CXXRecordDecls to key functions.
310 llvm::DenseMap<const CXXRecordDecl*, LazyDeclPtr> KeyFunctions;
311
312 /// Mapping from ObjCContainers to their ObjCImplementations.
313 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*> ObjCImpls;
314
315 /// Mapping from ObjCMethod to its duplicate declaration in the same
316 /// interface.
317 llvm::DenseMap<const ObjCMethodDecl*,const ObjCMethodDecl*> ObjCMethodRedecls;
318
319 /// Mapping from __block VarDecls to BlockVarCopyInit.
320 llvm::DenseMap<const VarDecl *, BlockVarCopyInit> BlockVarCopyInits;
321
322 /// Mapping from GUIDs to the corresponding MSGuidDecl.
323 mutable llvm::FoldingSet<MSGuidDecl> MSGuidDecls;
324
325 /// Mapping from APValues to the corresponding UnnamedGlobalConstantDecl.
326 mutable llvm::FoldingSet<UnnamedGlobalConstantDecl>
327 UnnamedGlobalConstantDecls;
328
329 /// Mapping from APValues to the corresponding TemplateParamObjects.
330 mutable llvm::FoldingSet<TemplateParamObjectDecl> TemplateParamObjectDecls;
331
332 /// A cache mapping a string value to a StringLiteral object with the same
333 /// value.
334 ///
335 /// This is lazily created. This is intentionally not serialized.
336 mutable llvm::StringMap<StringLiteral *> StringLiteralCache;
337
338 mutable llvm::DenseSet<const FunctionDecl *> DestroyingOperatorDeletes;
339 mutable llvm::DenseSet<const FunctionDecl *> TypeAwareOperatorNewAndDeletes;
340
341 /// The next string literal "version" to allocate during constant evaluation.
342 /// This is used to distinguish between repeated evaluations of the same
343 /// string literal.
344 ///
345 /// We don't need to serialize this because constants get re-evaluated in the
346 /// current file before they are compared locally.
347 unsigned NextStringLiteralVersion = 0;
348
349 /// MD5 hash of CUID. It is calculated when first used and cached by this
350 /// data member.
351 mutable std::string CUIDHash;
352
353 /// Representation of a "canonical" template template parameter that
354 /// is used in canonical template names.
355 class CanonicalTemplateTemplateParm : public llvm::FoldingSetNode {
356 TemplateTemplateParmDecl *Parm;
357
358 public:
359 CanonicalTemplateTemplateParm(TemplateTemplateParmDecl *Parm)
360 : Parm(Parm) {}
361
362 TemplateTemplateParmDecl *getParam() const { return Parm; }
363
364 void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &C) {
365 Profile(ID, C, Parm);
366 }
367
368 static void Profile(llvm::FoldingSetNodeID &ID,
369 const ASTContext &C,
370 TemplateTemplateParmDecl *Parm);
371 };
372 mutable llvm::ContextualFoldingSet<CanonicalTemplateTemplateParm,
373 const ASTContext&>
374 CanonTemplateTemplateParms;
375
376 /// The typedef for the __int128_t type.
377 mutable TypedefDecl *Int128Decl = nullptr;
378
379 /// The typedef for the __uint128_t type.
380 mutable TypedefDecl *UInt128Decl = nullptr;
381
382 /// The typedef for the target specific predefined
383 /// __builtin_va_list type.
384 mutable TypedefDecl *BuiltinVaListDecl = nullptr;
385
386 /// The typedef for the predefined \c __builtin_ms_va_list type.
387 mutable TypedefDecl *BuiltinMSVaListDecl = nullptr;
388
389 /// The typedef for the predefined \c id type.
390 mutable TypedefDecl *ObjCIdDecl = nullptr;
391
392 /// The typedef for the predefined \c SEL type.
393 mutable TypedefDecl *ObjCSelDecl = nullptr;
394
395 /// The typedef for the predefined \c Class type.
396 mutable TypedefDecl *ObjCClassDecl = nullptr;
397
398 /// The typedef for the predefined \c Protocol class in Objective-C.
399 mutable ObjCInterfaceDecl *ObjCProtocolClassDecl = nullptr;
400
401 /// The typedef for the predefined 'BOOL' type.
402 mutable TypedefDecl *BOOLDecl = nullptr;
403
404 // Typedefs which may be provided defining the structure of Objective-C
405 // pseudo-builtins
406 QualType ObjCIdRedefinitionType;
407 QualType ObjCClassRedefinitionType;
408 QualType ObjCSelRedefinitionType;
409
410 /// The identifier 'bool'.
411 mutable IdentifierInfo *BoolName = nullptr;
412
413 /// The identifier 'NSObject'.
414 mutable IdentifierInfo *NSObjectName = nullptr;
415
416 /// The identifier 'NSCopying'.
417 IdentifierInfo *NSCopyingName = nullptr;
418
419#define BuiltinTemplate(BTName) mutable IdentifierInfo *Name##BTName = nullptr;
420#include "clang/Basic/BuiltinTemplates.inc"
421
422 QualType ObjCConstantStringType;
423 mutable RecordDecl *CFConstantStringTagDecl = nullptr;
424 mutable TypedefDecl *CFConstantStringTypeDecl = nullptr;
425
426 mutable QualType ObjCSuperType;
427
428 QualType ObjCNSStringType;
429
430 /// The typedef declaration for the Objective-C "instancetype" type.
431 TypedefDecl *ObjCInstanceTypeDecl = nullptr;
432
433 /// The type for the C FILE type.
434 TypeDecl *FILEDecl = nullptr;
435
436 /// The type for the C jmp_buf type.
437 TypeDecl *jmp_bufDecl = nullptr;
438
439 /// The type for the C sigjmp_buf type.
440 TypeDecl *sigjmp_bufDecl = nullptr;
441
442 /// The type for the C ucontext_t type.
443 TypeDecl *ucontext_tDecl = nullptr;
444
445 /// Type for the Block descriptor for Blocks CodeGen.
446 ///
447 /// Since this is only used for generation of debug info, it is not
448 /// serialized.
449 mutable RecordDecl *BlockDescriptorType = nullptr;
450
451 /// Type for the Block descriptor for Blocks CodeGen.
452 ///
453 /// Since this is only used for generation of debug info, it is not
454 /// serialized.
455 mutable RecordDecl *BlockDescriptorExtendedType = nullptr;
456
457 /// Declaration for the CUDA cudaConfigureCall function.
458 FunctionDecl *cudaConfigureCallDecl = nullptr;
459
460 /// Keeps track of all declaration attributes.
461 ///
462 /// Since so few decls have attrs, we keep them in a hash map instead of
463 /// wasting space in the Decl class.
464 llvm::DenseMap<const Decl*, AttrVec*> DeclAttrs;
465
466 /// A mapping from non-redeclarable declarations in modules that were
467 /// merged with other declarations to the canonical declaration that they were
468 /// merged into.
469 llvm::DenseMap<Decl*, Decl*> MergedDecls;
470
471 /// A mapping from a defining declaration to a list of modules (other
472 /// than the owning module of the declaration) that contain merged
473 /// definitions of that entity.
474 llvm::DenseMap<NamedDecl*, llvm::TinyPtrVector<Module*>> MergedDefModules;
475
476 /// Initializers for a module, in order. Each Decl will be either
477 /// something that has a semantic effect on startup (such as a variable with
478 /// a non-constant initializer), or an ImportDecl (which recursively triggers
479 /// initialization of another module).
480 struct PerModuleInitializers {
481 llvm::SmallVector<Decl*, 4> Initializers;
482 llvm::SmallVector<GlobalDeclID, 4> LazyInitializers;
483
484 void resolve(ASTContext &Ctx);
485 };
486 llvm::DenseMap<Module*, PerModuleInitializers*> ModuleInitializers;
487
488 /// This is the top-level (C++20) Named module we are building.
489 Module *CurrentCXXNamedModule = nullptr;
490
491 /// Help structures to decide whether two `const Module *` belongs
492 /// to the same conceptual module to avoid the expensive to string comparison
493 /// if possible.
494 ///
495 /// Not serialized intentionally.
496 mutable llvm::StringMap<const Module *> PrimaryModuleNameMap;
497 mutable llvm::DenseMap<const Module *, const Module *> SameModuleLookupSet;
498
499 static constexpr unsigned ConstantArrayTypesLog2InitSize = 8;
500 static constexpr unsigned GeneralTypesLog2InitSize = 9;
501 static constexpr unsigned FunctionProtoTypesLog2InitSize = 12;
502
503 /// A mapping from an ObjC class to its subclasses.
504 llvm::DenseMap<const ObjCInterfaceDecl *,
505 SmallVector<const ObjCInterfaceDecl *, 4>>
506 ObjCSubClasses;
507
508 ASTContext &this_() { return *this; }
509
510public:
511 /// A type synonym for the TemplateOrInstantiation mapping.
513 llvm::PointerUnion<VarTemplateDecl *, MemberSpecializationInfo *>;
514
515private:
516 friend class ASTDeclReader;
517 friend class ASTReader;
518 friend class ASTWriter;
519 template <class> friend class serialization::AbstractTypeReader;
520 friend class CXXRecordDecl;
521 friend class IncrementalParser;
522
523 /// A mapping to contain the template or declaration that
524 /// a variable declaration describes or was instantiated from,
525 /// respectively.
526 ///
527 /// For non-templates, this value will be NULL. For variable
528 /// declarations that describe a variable template, this will be a
529 /// pointer to a VarTemplateDecl. For static data members
530 /// of class template specializations, this will be the
531 /// MemberSpecializationInfo referring to the member variable that was
532 /// instantiated or specialized. Thus, the mapping will keep track of
533 /// the static data member templates from which static data members of
534 /// class template specializations were instantiated.
535 ///
536 /// Given the following example:
537 ///
538 /// \code
539 /// template<typename T>
540 /// struct X {
541 /// static T value;
542 /// };
543 ///
544 /// template<typename T>
545 /// T X<T>::value = T(17);
546 ///
547 /// int *x = &X<int>::value;
548 /// \endcode
549 ///
550 /// This mapping will contain an entry that maps from the VarDecl for
551 /// X<int>::value to the corresponding VarDecl for X<T>::value (within the
552 /// class template X) and will be marked TSK_ImplicitInstantiation.
553 llvm::DenseMap<const VarDecl *, TemplateOrSpecializationInfo>
554 TemplateOrInstantiation;
555
556 /// Keeps track of the declaration from which a using declaration was
557 /// created during instantiation.
558 ///
559 /// The source and target declarations are always a UsingDecl, an
560 /// UnresolvedUsingValueDecl, or an UnresolvedUsingTypenameDecl.
561 ///
562 /// For example:
563 /// \code
564 /// template<typename T>
565 /// struct A {
566 /// void f();
567 /// };
568 ///
569 /// template<typename T>
570 /// struct B : A<T> {
571 /// using A<T>::f;
572 /// };
573 ///
574 /// template struct B<int>;
575 /// \endcode
576 ///
577 /// This mapping will contain an entry that maps from the UsingDecl in
578 /// B<int> to the UnresolvedUsingDecl in B<T>.
579 llvm::DenseMap<NamedDecl *, NamedDecl *> InstantiatedFromUsingDecl;
580
581 /// Like InstantiatedFromUsingDecl, but for using-enum-declarations. Maps
582 /// from the instantiated using-enum to the templated decl from whence it
583 /// came.
584 /// Note that using-enum-declarations cannot be dependent and
585 /// thus will never be instantiated from an "unresolved"
586 /// version thereof (as with using-declarations), so each mapping is from
587 /// a (resolved) UsingEnumDecl to a (resolved) UsingEnumDecl.
588 llvm::DenseMap<UsingEnumDecl *, UsingEnumDecl *>
589 InstantiatedFromUsingEnumDecl;
590
591 /// Similarly maps instantiated UsingShadowDecls to their origin.
592 llvm::DenseMap<UsingShadowDecl*, UsingShadowDecl*>
593 InstantiatedFromUsingShadowDecl;
594
595 llvm::DenseMap<FieldDecl *, FieldDecl *> InstantiatedFromUnnamedFieldDecl;
596
597 /// Mapping that stores the methods overridden by a given C++
598 /// member function.
599 ///
600 /// Since most C++ member functions aren't virtual and therefore
601 /// don't override anything, we store the overridden functions in
602 /// this map on the side rather than within the CXXMethodDecl structure.
603 using CXXMethodVector = llvm::TinyPtrVector<const CXXMethodDecl *>;
604 llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector> OverriddenMethods;
605
606 /// Mapping from each declaration context to its corresponding
607 /// mangling numbering context (used for constructs like lambdas which
608 /// need to be consistently numbered for the mangler).
609 llvm::DenseMap<const DeclContext *, std::unique_ptr<MangleNumberingContext>>
610 MangleNumberingContexts;
611 llvm::DenseMap<const Decl *, std::unique_ptr<MangleNumberingContext>>
612 ExtraMangleNumberingContexts;
613
614 /// Side-table of mangling numbers for declarations which rarely
615 /// need them (like static local vars).
616 llvm::MapVector<const NamedDecl *, unsigned> MangleNumbers;
617 llvm::MapVector<const VarDecl *, unsigned> StaticLocalNumbers;
618 /// Mapping the associated device lambda mangling number if present.
619 mutable llvm::DenseMap<const CXXRecordDecl *, unsigned>
620 DeviceLambdaManglingNumbers;
621
622 /// Mapping that stores parameterIndex values for ParmVarDecls when
623 /// that value exceeds the bitfield size of ParmVarDeclBits.ParameterIndex.
624 using ParameterIndexTable = llvm::DenseMap<const VarDecl *, unsigned>;
625 ParameterIndexTable ParamIndices;
626
627public:
632 std::optional<CXXRecordDeclRelocationInfo>
636
637 /// Examines a given type, and returns whether the type itself
638 /// is address discriminated, or any transitively embedded types
639 /// contain data that is address discriminated. This includes
640 /// implicitly authenticated values like vtable pointers, as well as
641 /// explicitly qualified fields.
643 if (!isPointerAuthenticationAvailable())
644 return false;
645 return findPointerAuthContent(T) != PointerAuthContent::None;
646 }
647
648 /// Examines a given type, and returns whether the type itself
649 /// or any data it transitively contains has a pointer authentication
650 /// schema that is not safely relocatable. e.g. any data or fields
651 /// with address discrimination other than any otherwise similar
652 /// vtable pointers.
654 if (!isPointerAuthenticationAvailable())
655 return false;
656 return findPointerAuthContent(T) != PointerAuthContent::None;
657 }
658
659private:
660 llvm::DenseMap<const CXXRecordDecl *, CXXRecordDeclRelocationInfo>
661 RelocatableClasses;
662
663 // FIXME: store in RecordDeclBitfields in future?
664 enum class PointerAuthContent : uint8_t {
665 None,
666 AddressDiscriminatedVTable,
667 AddressDiscriminatedData
668 };
669
670 // A simple helper function to short circuit pointer auth checks.
671 bool isPointerAuthenticationAvailable() const {
672 return LangOpts.PointerAuthCalls || LangOpts.PointerAuthIntrinsics;
673 }
674 PointerAuthContent findPointerAuthContent(QualType T) const;
675 mutable llvm::DenseMap<const RecordDecl *, PointerAuthContent>
676 RecordContainsAddressDiscriminatedPointerAuth;
677
678 ImportDecl *FirstLocalImport = nullptr;
679 ImportDecl *LastLocalImport = nullptr;
680
681 TranslationUnitDecl *TUDecl = nullptr;
682 mutable ExternCContextDecl *ExternCContext = nullptr;
683
684#define BuiltinTemplate(BTName) \
685 mutable BuiltinTemplateDecl *Decl##BTName = nullptr;
686#include "clang/Basic/BuiltinTemplates.inc"
687
688 /// The associated SourceManager object.
689 SourceManager &SourceMgr;
690
691 /// The language options used to create the AST associated with
692 /// this ASTContext object.
693 LangOptions &LangOpts;
694
695 /// NoSanitizeList object that is used by sanitizers to decide which
696 /// entities should not be instrumented.
697 std::unique_ptr<NoSanitizeList> NoSanitizeL;
698
699 /// Function filtering mechanism to determine whether a given function
700 /// should be imbued with the XRay "always" or "never" attributes.
701 std::unique_ptr<XRayFunctionFilter> XRayFilter;
702
703 /// ProfileList object that is used by the profile instrumentation
704 /// to decide which entities should be instrumented.
705 std::unique_ptr<ProfileList> ProfList;
706
707 /// The allocator used to create AST objects.
708 ///
709 /// AST objects are never destructed; rather, all memory associated with the
710 /// AST objects will be released when the ASTContext itself is destroyed.
711 mutable llvm::BumpPtrAllocator BumpAlloc;
712
713 /// Allocator for partial diagnostics.
715
716 /// The current C++ ABI.
717 std::unique_ptr<CXXABI> ABI;
718 CXXABI *createCXXABI(const TargetInfo &T);
719
720 /// Address space map mangling must be used with language specific
721 /// address spaces (e.g. OpenCL/CUDA)
722 bool AddrSpaceMapMangling;
723
724 /// For performance, track whether any function effects are in use.
725 mutable bool AnyFunctionEffects = false;
726
727 const TargetInfo *Target = nullptr;
728 const TargetInfo *AuxTarget = nullptr;
729 clang::PrintingPolicy PrintingPolicy;
730 std::unique_ptr<interp::Context> InterpContext;
731 std::unique_ptr<ParentMapContext> ParentMapCtx;
732
733 /// Keeps track of the deallocated DeclListNodes for future reuse.
734 DeclListNode *ListNodeFreeList = nullptr;
735
736public:
744
745 /// Returns the clang bytecode interpreter context.
747
749 /// Do not allow wrong-sided variables in constant expressions.
750 bool NoWrongSidedVars = false;
761
762 /// Returns the dynamic AST node parent map context.
764
765 // A traversal scope limits the parts of the AST visible to certain analyses.
766 // RecursiveASTVisitor only visits specified children of TranslationUnitDecl.
767 // getParents() will only observe reachable parent edges.
768 //
769 // The scope is defined by a set of "top-level" declarations which will be
770 // visible under the TranslationUnitDecl.
771 // Initially, it is the entire TU, represented by {getTranslationUnitDecl()}.
772 //
773 // After setTraversalScope({foo, bar}), the exposed AST looks like:
774 // TranslationUnitDecl
775 // - foo
776 // - ...
777 // - bar
778 // - ...
779 // All other siblings of foo and bar are pruned from the tree.
780 // (However they are still accessible via TranslationUnitDecl->decls())
781 //
782 // Changing the scope clears the parent cache, which is expensive to rebuild.
783 ArrayRef<Decl *> getTraversalScope() const { return TraversalScope; }
784 void setTraversalScope(const std::vector<Decl *> &);
785
786 /// Forwards to get node parents from the ParentMapContext. New callers should
787 /// use ParentMapContext::getParents() directly.
788 template <typename NodeT> DynTypedNodeList getParents(const NodeT &Node);
789
791 return PrintingPolicy;
792 }
793
795 PrintingPolicy = Policy;
796 }
797
798 SourceManager& getSourceManager() { return SourceMgr; }
799 const SourceManager& getSourceManager() const { return SourceMgr; }
800
801 // Cleans up some of the data structures. This allows us to do cleanup
802 // normally done in the destructor earlier. Renders much of the ASTContext
803 // unusable, mostly the actual AST nodes, so should be called when we no
804 // longer need access to the AST.
805 void cleanup();
806
807 llvm::BumpPtrAllocator &getAllocator() const {
808 return BumpAlloc;
809 }
810
811 void *Allocate(size_t Size, unsigned Align = 8) const {
812 return BumpAlloc.Allocate(Size, Align);
813 }
814 template <typename T> T *Allocate(size_t Num = 1) const {
815 return static_cast<T *>(Allocate(Num * sizeof(T), alignof(T)));
816 }
817 void Deallocate(void *Ptr) const {}
818
819 llvm::StringRef backupStr(llvm::StringRef S) const {
820 char *Buf = new (*this) char[S.size()];
821 llvm::copy(S, Buf);
822 return llvm::StringRef(Buf, S.size());
823 }
824
825 /// Allocates a \c DeclListNode or returns one from the \c ListNodeFreeList
826 /// pool.
828 if (DeclListNode *Alloc = ListNodeFreeList) {
829 ListNodeFreeList = dyn_cast_if_present<DeclListNode *>(Alloc->Rest);
830 Alloc->D = ND;
831 Alloc->Rest = nullptr;
832 return Alloc;
833 }
834 return new (*this) DeclListNode(ND);
835 }
836 /// Deallocates a \c DeclListNode by returning it to the \c ListNodeFreeList
837 /// pool.
839 N->Rest = ListNodeFreeList;
840 ListNodeFreeList = N;
841 }
842
843 /// Return the total amount of physical memory allocated for representing
844 /// AST nodes and type information.
845 size_t getASTAllocatedMemory() const {
846 return BumpAlloc.getTotalMemory();
847 }
848
849 /// Return the total memory used for various side tables.
850 size_t getSideTableAllocatedMemory() const;
851
853 return DiagAllocator;
854 }
855
856 const TargetInfo &getTargetInfo() const { return *Target; }
857 const TargetInfo *getAuxTargetInfo() const { return AuxTarget; }
858
859 const QualType GetHigherPrecisionFPType(QualType ElementType) const {
860 const auto *CurrentBT = cast<BuiltinType>(ElementType);
861 switch (CurrentBT->getKind()) {
862 case BuiltinType::Kind::Half:
863 case BuiltinType::Kind::Float16:
864 return FloatTy;
865 case BuiltinType::Kind::Float:
866 case BuiltinType::Kind::BFloat16:
867 return DoubleTy;
868 case BuiltinType::Kind::Double:
869 return LongDoubleTy;
870 default:
871 return ElementType;
872 }
873 return ElementType;
874 }
875
876 /// getIntTypeForBitwidth -
877 /// sets integer QualTy according to specified details:
878 /// bitwidth, signed/unsigned.
879 /// Returns empty type if there is no appropriate target types.
880 QualType getIntTypeForBitwidth(unsigned DestWidth,
881 unsigned Signed) const;
882
883 /// getRealTypeForBitwidth -
884 /// sets floating point QualTy according to specified bitwidth.
885 /// Returns empty type if there is no appropriate target types.
886 QualType getRealTypeForBitwidth(unsigned DestWidth,
887 FloatModeKind ExplicitType) const;
888
889 bool AtomicUsesUnsupportedLibcall(const AtomicExpr *E) const;
890
891 const LangOptions& getLangOpts() const { return LangOpts; }
892
893 // If this condition is false, typo correction must be performed eagerly
894 // rather than delayed in many places, as it makes use of dependent types.
895 // the condition is false for clang's C-only codepath, as it doesn't support
896 // dependent types yet.
897 bool isDependenceAllowed() const {
898 return LangOpts.CPlusPlus || LangOpts.RecoveryAST;
899 }
900
901 const NoSanitizeList &getNoSanitizeList() const { return *NoSanitizeL; }
902
904 const QualType &Ty) const;
905
907 return *XRayFilter;
908 }
909
910 const ProfileList &getProfileList() const { return *ProfList; }
911
913
915 return FullSourceLoc(Loc,SourceMgr);
916 }
917
918 /// Return the C++ ABI kind that should be used. The C++ ABI can be overriden
919 /// at compile time with `-fc++-abi=`. If this is not provided, we instead use
920 /// the default ABI set by the target.
922
923 /// All comments in this translation unit.
925
926 /// True if comments are already loaded from ExternalASTSource.
927 mutable bool CommentsLoaded = false;
928
929 /// Mapping from declaration to directly attached comment.
930 ///
931 /// Raw comments are owned by Comments list. This mapping is populated
932 /// lazily.
933 mutable llvm::DenseMap<const Decl *, const RawComment *> DeclRawComments;
934
935 /// Mapping from canonical declaration to the first redeclaration in chain
936 /// that has a comment attached.
937 ///
938 /// Raw comments are owned by Comments list. This mapping is populated
939 /// lazily.
940 mutable llvm::DenseMap<const Decl *, const Decl *> RedeclChainComments;
941
942 /// Keeps track of redeclaration chains that don't have any comment attached.
943 /// Mapping from canonical declaration to redeclaration chain that has no
944 /// comments attached to any redeclaration. Specifically it's mapping to
945 /// the last redeclaration we've checked.
946 ///
947 /// Shall not contain declarations that have comments attached to any
948 /// redeclaration in their chain.
949 mutable llvm::DenseMap<const Decl *, const Decl *> CommentlessRedeclChains;
950
951 /// Mapping from declarations to parsed comments attached to any
952 /// redeclaration.
953 mutable llvm::DenseMap<const Decl *, comments::FullComment *> ParsedComments;
954
955 /// Attaches \p Comment to \p OriginalD and to its redeclaration chain
956 /// and removes the redeclaration chain from the set of commentless chains.
957 ///
958 /// Don't do anything if a comment has already been attached to \p OriginalD
959 /// or its redeclaration chain.
960 void cacheRawCommentForDecl(const Decl &OriginalD,
961 const RawComment &Comment) const;
962
963 /// \returns searches \p CommentsInFile for doc comment for \p D.
964 ///
965 /// \p RepresentativeLocForDecl is used as a location for searching doc
966 /// comments. \p CommentsInFile is a mapping offset -> comment of files in the
967 /// same file where \p RepresentativeLocForDecl is.
969 const Decl *D, const SourceLocation RepresentativeLocForDecl,
970 const std::map<unsigned, RawComment *> &CommentsInFile) const;
971
972 /// Return the documentation comment attached to a given declaration,
973 /// without looking into cache.
975
976public:
977 void addComment(const RawComment &RC);
978
979 /// Return the documentation comment attached to a given declaration.
980 /// Returns nullptr if no comment is attached.
981 ///
982 /// \param OriginalDecl if not nullptr, is set to declaration AST node that
983 /// had the comment, if the comment we found comes from a redeclaration.
984 const RawComment *
986 const Decl **OriginalDecl = nullptr) const;
987
988 /// Searches existing comments for doc comments that should be attached to \p
989 /// Decls. If any doc comment is found, it is parsed.
990 ///
991 /// Requirement: All \p Decls are in the same file.
992 ///
993 /// If the last comment in the file is already attached we assume
994 /// there are not comments left to be attached to \p Decls.
996 const Preprocessor *PP);
997
998 /// Return parsed documentation comment attached to a given declaration.
999 /// Returns nullptr if no comment is attached.
1000 ///
1001 /// \param PP the Preprocessor used with this TU. Could be nullptr if
1002 /// preprocessor is not available.
1004 const Preprocessor *PP) const;
1005
1006 /// Return parsed documentation comment attached to a given declaration.
1007 /// Returns nullptr if no comment is attached. Does not look at any
1008 /// redeclarations of the declaration.
1010
1012 const Decl *D) const;
1013
1014private:
1015 mutable comments::CommandTraits CommentCommandTraits;
1016
1017 /// Iterator that visits import declarations.
1018 class import_iterator {
1019 ImportDecl *Import = nullptr;
1020
1021 public:
1022 using value_type = ImportDecl *;
1023 using reference = ImportDecl *;
1024 using pointer = ImportDecl *;
1025 using difference_type = int;
1026 using iterator_category = std::forward_iterator_tag;
1027
1028 import_iterator() = default;
1029 explicit import_iterator(ImportDecl *Import) : Import(Import) {}
1030
1031 reference operator*() const { return Import; }
1032 pointer operator->() const { return Import; }
1033
1034 import_iterator &operator++() {
1035 Import = ASTContext::getNextLocalImport(Import);
1036 return *this;
1037 }
1038
1039 import_iterator operator++(int) {
1040 import_iterator Other(*this);
1041 ++(*this);
1042 return Other;
1043 }
1044
1045 friend bool operator==(import_iterator X, import_iterator Y) {
1046 return X.Import == Y.Import;
1047 }
1048
1049 friend bool operator!=(import_iterator X, import_iterator Y) {
1050 return X.Import != Y.Import;
1051 }
1052 };
1053
1054public:
1056 return CommentCommandTraits;
1057 }
1058
1059 /// Retrieve the attributes for the given declaration.
1060 AttrVec& getDeclAttrs(const Decl *D);
1061
1062 /// Erase the attributes corresponding to the given declaration.
1063 void eraseDeclAttrs(const Decl *D);
1064
1065 /// If this variable is an instantiated static data member of a
1066 /// class template specialization, returns the templated static data member
1067 /// from which it was instantiated.
1068 // FIXME: Remove ?
1070 const VarDecl *Var);
1071
1072 /// Note that the static data member \p Inst is an instantiation of
1073 /// the static data member template \p Tmpl of a class template.
1076 SourceLocation PointOfInstantiation = SourceLocation());
1077
1080
1083
1084 /// If the given using decl \p Inst is an instantiation of
1085 /// another (possibly unresolved) using decl, return it.
1087
1088 /// Remember that the using decl \p Inst is an instantiation
1089 /// of the using decl \p Pattern of a class template.
1090 void setInstantiatedFromUsingDecl(NamedDecl *Inst, NamedDecl *Pattern);
1091
1092 /// If the given using-enum decl \p Inst is an instantiation of
1093 /// another using-enum decl, return it.
1095
1096 /// Remember that the using enum decl \p Inst is an instantiation
1097 /// of the using enum decl \p Pattern of a class template.
1099 UsingEnumDecl *Pattern);
1100
1103 UsingShadowDecl *Pattern);
1104
1106
1108
1109 // Access to the set of methods overridden by the given C++ method.
1110 using overridden_cxx_method_iterator = CXXMethodVector::const_iterator;
1113
1116
1117 unsigned overridden_methods_size(const CXXMethodDecl *Method) const;
1118
1120 llvm::iterator_range<overridden_cxx_method_iterator>;
1121
1123
1124 /// Note that the given C++ \p Method overrides the given \p
1125 /// Overridden method.
1127 const CXXMethodDecl *Overridden);
1128
1129 /// Return C++ or ObjC overridden methods for the given \p Method.
1130 ///
1131 /// An ObjC method is considered to override any method in the class's
1132 /// base classes, its protocols, or its categories' protocols, that has
1133 /// the same selector and is of the same kind (class or instance).
1134 /// A method in an implementation is not considered as overriding the same
1135 /// method in the interface or its categories.
1137 const NamedDecl *Method,
1138 SmallVectorImpl<const NamedDecl *> &Overridden) const;
1139
1140 /// Notify the AST context that a new import declaration has been
1141 /// parsed or implicitly created within this translation unit.
1142 void addedLocalImportDecl(ImportDecl *Import);
1143
1145 return Import->getNextLocalImport();
1146 }
1147
1148 using import_range = llvm::iterator_range<import_iterator>;
1149
1151 return import_range(import_iterator(FirstLocalImport), import_iterator());
1152 }
1153
1155 Decl *Result = MergedDecls.lookup(D);
1156 return Result ? Result : D;
1157 }
1158 void setPrimaryMergedDecl(Decl *D, Decl *Primary) {
1159 MergedDecls[D] = Primary;
1160 }
1161
1162 /// Note that the definition \p ND has been merged into module \p M,
1163 /// and should be visible whenever \p M is visible.
1165 bool NotifyListeners = true);
1166
1167 /// Clean up the merged definition list. Call this if you might have
1168 /// added duplicates into the list.
1170
1171 /// Get the additional modules in which the definition \p Def has
1172 /// been merged.
1174
1175 /// Add a declaration to the list of declarations that are initialized
1176 /// for a module. This will typically be a global variable (with internal
1177 /// linkage) that runs module initializers, such as the iostream initializer,
1178 /// or an ImportDecl nominating another module that has initializers.
1180
1182
1183 /// Get the initializations to perform when importing a module, if any.
1185
1186 /// Set the (C++20) module we are building.
1188
1189 /// Get module under construction, nullptr if this is not a C++20 module.
1190 Module *getCurrentNamedModule() const { return CurrentCXXNamedModule; }
1191
1192 /// If the two module \p M1 and \p M2 are in the same module.
1193 ///
1194 /// FIXME: The signature may be confusing since `clang::Module` means to
1195 /// a module fragment or a module unit but not a C++20 module.
1196 bool isInSameModule(const Module *M1, const Module *M2) const;
1197
1199 assert(TUDecl->getMostRecentDecl() == TUDecl &&
1200 "The active TU is not current one!");
1201 return TUDecl->getMostRecentDecl();
1202 }
1204 assert(!TUDecl || TUKind == TU_Incremental);
1206 if (TraversalScope.empty() || TraversalScope.back() == TUDecl)
1207 TraversalScope = {NewTUDecl};
1208 if (TUDecl)
1209 NewTUDecl->setPreviousDecl(TUDecl);
1210 TUDecl = NewTUDecl;
1211 }
1212
1214
1215#define BuiltinTemplate(BTName) BuiltinTemplateDecl *get##BTName##Decl() const;
1216#include "clang/Basic/BuiltinTemplates.inc"
1217
1218 // Builtin Types.
1222 CanQualType WCharTy; // [C++ 3.9.1p5].
1223 CanQualType WideCharTy; // Same as WCharTy in C++, integer type in C99.
1224 CanQualType WIntTy; // [C99 7.24.1], integer type unchanged by default promotions.
1225 CanQualType Char8Ty; // [C++20 proposal]
1226 CanQualType Char16Ty; // [C++0x 3.9.1p5], integer type in C99.
1227 CanQualType Char32Ty; // [C++0x 3.9.1p5], integer type in C99.
1233 LongAccumTy; // ISO/IEC JTC1 SC22 WG14 N1169 Extension
1243 CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
1245 CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
1253#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1254 CanQualType SingletonId;
1255#include "clang/Basic/OpenCLImageTypes.def"
1261#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1262 CanQualType Id##Ty;
1263#include "clang/Basic/OpenCLExtensionTypes.def"
1264#define SVE_TYPE(Name, Id, SingletonId) \
1265 CanQualType SingletonId;
1266#include "clang/Basic/AArch64ACLETypes.def"
1267#define PPC_VECTOR_TYPE(Name, Id, Size) \
1268 CanQualType Id##Ty;
1269#include "clang/Basic/PPCTypes.def"
1270#define RVV_TYPE(Name, Id, SingletonId) \
1271 CanQualType SingletonId;
1272#include "clang/Basic/RISCVVTypes.def"
1273#define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
1274#include "clang/Basic/WebAssemblyReferenceTypes.def"
1275#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
1276 CanQualType SingletonId;
1277#include "clang/Basic/AMDGPUTypes.def"
1278#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
1279#include "clang/Basic/HLSLIntangibleTypes.def"
1280
1281 // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand.
1282 mutable QualType AutoDeductTy; // Deduction against 'auto'.
1283 mutable QualType AutoRRefDeductTy; // Deduction against 'auto &&'.
1284
1285 // Decl used to help define __builtin_va_list for some targets.
1286 // The decl is built when constructing 'BuiltinVaListDecl'.
1287 mutable Decl *VaListTagDecl = nullptr;
1288
1289 // Implicitly-declared type 'struct _GUID'.
1290 mutable TagDecl *MSGuidTagDecl = nullptr;
1291
1292 // Implicitly-declared type 'struct type_info'.
1293 mutable TagDecl *MSTypeInfoTagDecl = nullptr;
1294
1295 /// Keep track of CUDA/HIP device-side variables ODR-used by host code.
1296 /// This does not include extern shared variables used by device host
1297 /// functions as addresses of shared variables are per warp, therefore
1298 /// cannot be accessed by host code.
1299 llvm::DenseSet<const VarDecl *> CUDADeviceVarODRUsedByHost;
1300
1301 /// Keep track of CUDA/HIP external kernels or device variables ODR-used by
1302 /// host code. SetVector is used to maintain the order.
1303 llvm::SetVector<const ValueDecl *> CUDAExternalDeviceDeclODRUsedByHost;
1304
1305 /// Keep track of CUDA/HIP implicit host device functions used on device side
1306 /// in device compilation.
1307 llvm::DenseSet<const FunctionDecl *> CUDAImplicitHostDeviceFunUsedByDevice;
1308
1309 /// Map of SYCL kernels indexed by the unique type used to name the kernel.
1310 /// Entries are not serialized but are recreated on deserialization of a
1311 /// sycl_kernel_entry_point attributed function declaration.
1312 llvm::DenseMap<CanQualType, SYCLKernelInfo> SYCLKernels;
1313
1314 /// For capturing lambdas with an explicit object parameter whose type is
1315 /// derived from the lambda type, we need to perform derived-to-base
1316 /// conversion so we can access the captures; the cast paths for that
1317 /// are stored here.
1318 llvm::DenseMap<const CXXMethodDecl *, CXXCastPath> LambdaCastPaths;
1319
1321 SelectorTable &sels, Builtin::Context &builtins,
1323 ASTContext(const ASTContext &) = delete;
1324 ASTContext &operator=(const ASTContext &) = delete;
1325 ~ASTContext();
1326
1327 /// Attach an external AST source to the AST context.
1328 ///
1329 /// The external AST source provides the ability to load parts of
1330 /// the abstract syntax tree as needed from some external storage,
1331 /// e.g., a precompiled header.
1333
1334 /// Retrieve a pointer to the external AST source associated
1335 /// with this AST context, if any.
1337 return ExternalSource.get();
1338 }
1339
1340 /// Retrieve a pointer to the external AST source associated
1341 /// with this AST context, if any. Returns as an IntrusiveRefCntPtr.
1345
1346 /// Attach an AST mutation listener to the AST context.
1347 ///
1348 /// The AST mutation listener provides the ability to track modifications to
1349 /// the abstract syntax tree entities committed after they were initially
1350 /// created.
1352 this->Listener = Listener;
1353 }
1354
1355 /// Retrieve a pointer to the AST mutation listener associated
1356 /// with this AST context, if any.
1358
1359 void PrintStats() const;
1360 const SmallVectorImpl<Type *>& getTypes() const { return Types; }
1361
1363 const IdentifierInfo *II) const;
1364
1365 /// Create a new implicit TU-level CXXRecordDecl or RecordDecl
1366 /// declaration.
1368 StringRef Name,
1369 RecordDecl::TagKind TK = RecordDecl::TagKind::Struct) const;
1370
1371 /// Create a new implicit TU-level typedef declaration.
1372 TypedefDecl *buildImplicitTypedef(QualType T, StringRef Name) const;
1373
1374 /// Retrieve the declaration for the 128-bit signed integer type.
1375 TypedefDecl *getInt128Decl() const;
1376
1377 /// Retrieve the declaration for the 128-bit unsigned integer type.
1378 TypedefDecl *getUInt128Decl() const;
1379
1380 //===--------------------------------------------------------------------===//
1381 // Type Constructors
1382 //===--------------------------------------------------------------------===//
1383
1384private:
1385 /// Return a type with extended qualifiers.
1386 QualType getExtQualType(const Type *Base, Qualifiers Quals) const;
1387
1388 QualType getPipeType(QualType T, bool ReadOnly) const;
1389
1390public:
1391 /// Return the uniqued reference to the type for an address space
1392 /// qualified type with the specified type and address space.
1393 ///
1394 /// The resulting type has a union of the qualifiers from T and the address
1395 /// space. If T already has an address space specifier, it is silently
1396 /// replaced.
1397 QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const;
1398
1399 /// Remove any existing address space on the type and returns the type
1400 /// with qualifiers intact (or that's the idea anyway)
1401 ///
1402 /// The return type should be T with all prior qualifiers minus the address
1403 /// space.
1405
1406 /// Return the "other" discriminator used for the pointer auth schema used for
1407 /// vtable pointers in instances of the requested type.
1408 uint16_t
1410
1411 /// Return the "other" type-specific discriminator for the given type.
1413
1414 /// Apply Objective-C protocol qualifiers to the given type.
1415 /// \param allowOnPointerType specifies if we can apply protocol
1416 /// qualifiers on ObjCObjectPointerType. It can be set to true when
1417 /// constructing the canonical type of a Objective-C type parameter.
1419 ArrayRef<ObjCProtocolDecl *> protocols, bool &hasError,
1420 bool allowOnPointerType = false) const;
1421
1422 /// Return the uniqued reference to the type for an Objective-C
1423 /// gc-qualified type.
1424 ///
1425 /// The resulting type has a union of the qualifiers from T and the gc
1426 /// attribute.
1428
1429 /// Remove the existing address space on the type if it is a pointer size
1430 /// address space and return the type with qualifiers intact.
1432
1433 /// Return the uniqued reference to the type for a \c restrict
1434 /// qualified type.
1435 ///
1436 /// The resulting type has a union of the qualifiers from \p T and
1437 /// \c restrict.
1439 return T.withFastQualifiers(Qualifiers::Restrict);
1440 }
1441
1442 /// Return the uniqued reference to the type for a \c volatile
1443 /// qualified type.
1444 ///
1445 /// The resulting type has a union of the qualifiers from \p T and
1446 /// \c volatile.
1448 return T.withFastQualifiers(Qualifiers::Volatile);
1449 }
1450
1451 /// Return the uniqued reference to the type for a \c const
1452 /// qualified type.
1453 ///
1454 /// The resulting type has a union of the qualifiers from \p T and \c const.
1455 ///
1456 /// It can be reasonably expected that this will always be equivalent to
1457 /// calling T.withConst().
1458 QualType getConstType(QualType T) const { return T.withConst(); }
1459
1460 /// Rebuild a type, preserving any existing type sugar. For function types,
1461 /// you probably want to just use \c adjustFunctionResultType and friends
1462 /// instead.
1464 llvm::function_ref<QualType(QualType)> Adjust) const;
1465
1466 /// Change the ExtInfo on a function type.
1468 FunctionType::ExtInfo EInfo);
1469
1470 /// Change the result type of a function type, preserving sugar such as
1471 /// attributed types.
1473 QualType NewResultType);
1474
1475 /// Adjust the given function result type.
1477
1478 /// Change the result type of a function type once it is deduced.
1480
1481 /// Get a function type and produce the equivalent function type with the
1482 /// specified exception specification. Type sugar that can be present on a
1483 /// declaration of a function with an exception specification is permitted
1484 /// and preserved. Other type sugar (for instance, typedefs) is not.
1486 QualType Orig, const FunctionProtoType::ExceptionSpecInfo &ESI) const;
1487
1488 /// Determine whether two function types are the same, ignoring
1489 /// exception specifications in cases where they're part of the type.
1491
1492 /// Change the exception specification on a function once it is
1493 /// delay-parsed, instantiated, or computed.
1496 bool AsWritten = false);
1497
1498 /// Get a function type and produce the equivalent function type where
1499 /// pointer size address spaces in the return type and parameter types are
1500 /// replaced with the default address space.
1502
1503 /// Determine whether two function types are the same, ignoring pointer sizes
1504 /// in the return type and parameter types.
1506
1507 /// Get or construct a function type that is equivalent to the input type
1508 /// except that the parameter ABI annotations are stripped.
1510
1511 /// Determine if two function types are the same, ignoring parameter ABI
1512 /// annotations.
1514
1515 /// Return the uniqued reference to the type for a complex
1516 /// number with the specified element type.
1521
1522 /// Return the uniqued reference to the type for a pointer to
1523 /// the specified type.
1528
1529 QualType
1530 getCountAttributedType(QualType T, Expr *CountExpr, bool CountInBytes,
1531 bool OrNull,
1532 ArrayRef<TypeCoupledDeclRefInfo> DependentDecls) const;
1533
1534 /// Return the uniqued reference to a type adjusted from the original
1535 /// type to a new type.
1541
1542 /// Return the uniqued reference to the decayed version of the given
1543 /// type. Can only be called on array and function types which decay to
1544 /// pointer types.
1549 /// Return the uniqued reference to a specified decay from the original
1550 /// type to the decayed type.
1551 QualType getDecayedType(QualType Orig, QualType Decayed) const;
1552
1553 /// Return the uniqued reference to a specified array parameter type from the
1554 /// original array type.
1556
1557 /// Return the uniqued reference to the atomic type for the specified
1558 /// type.
1560
1561 /// Return the uniqued reference to the type for a block of the
1562 /// specified type.
1564
1565 /// Gets the struct used to keep track of the descriptor for pointer to
1566 /// blocks.
1568
1569 /// Return a read_only pipe type for the specified type.
1571
1572 /// Return a write_only pipe type for the specified type.
1574
1575 /// Return a bit-precise integer type with the specified signedness and bit
1576 /// count.
1577 QualType getBitIntType(bool Unsigned, unsigned NumBits) const;
1578
1579 /// Return a dependent bit-precise integer type with the specified signedness
1580 /// and bit count.
1581 QualType getDependentBitIntType(bool Unsigned, Expr *BitsExpr) const;
1582
1584
1585 /// Gets the struct used to keep track of the extended descriptor for
1586 /// pointer to blocks.
1588
1589 /// Map an AST Type to an OpenCLTypeKind enum value.
1590 OpenCLTypeKind getOpenCLTypeKind(const Type *T) const;
1591
1592 /// Get address space for OpenCL type.
1593 LangAS getOpenCLTypeAddrSpace(const Type *T) const;
1594
1595 /// Returns default address space based on OpenCL version and enabled features
1597 return LangOpts.OpenCLGenericAddressSpace ? LangAS::opencl_generic
1599 }
1600
1602 cudaConfigureCallDecl = FD;
1603 }
1604
1606 return cudaConfigureCallDecl;
1607 }
1608
1609 /// Returns true iff we need copy/dispose helpers for the given type.
1610 bool BlockRequiresCopying(QualType Ty, const VarDecl *D);
1611
1612 /// Returns true, if given type has a known lifetime. HasByrefExtendedLayout
1613 /// is set to false in this case. If HasByrefExtendedLayout returns true,
1614 /// byref variable has extended lifetime.
1615 bool getByrefLifetime(QualType Ty,
1616 Qualifiers::ObjCLifetime &Lifetime,
1617 bool &HasByrefExtendedLayout) const;
1618
1619 /// Return the uniqued reference to the type for an lvalue reference
1620 /// to the specified type.
1621 QualType getLValueReferenceType(QualType T, bool SpelledAsLValue = true)
1622 const;
1623
1624 /// Return the uniqued reference to the type for an rvalue reference
1625 /// to the specified type.
1627
1628 /// Return the uniqued reference to the type for a member pointer to
1629 /// the specified type in the specified nested name.
1631 const CXXRecordDecl *Cls) const;
1632
1633 /// Return a non-unique reference to the type for a variable array of
1634 /// the specified element type.
1637 unsigned IndexTypeQuals) const;
1638
1639 /// Return a non-unique reference to the type for a dependently-sized
1640 /// array of the specified element type.
1641 ///
1642 /// FIXME: We will need these to be uniqued, or at least comparable, at some
1643 /// point.
1646 unsigned IndexTypeQuals) const;
1647
1648 /// Return a unique reference to the type for an incomplete array of
1649 /// the specified element type.
1651 unsigned IndexTypeQuals) const;
1652
1653 /// Return the unique reference to the type for a constant array of
1654 /// the specified element type.
1655 QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize,
1656 const Expr *SizeExpr, ArraySizeModifier ASM,
1657 unsigned IndexTypeQuals) const;
1658
1659 /// Return a type for a constant array for a string literal of the
1660 /// specified element type and length.
1661 QualType getStringLiteralArrayType(QualType EltTy, unsigned Length) const;
1662
1663 /// Returns a vla type where known sizes are replaced with [*].
1665
1666 // Convenience struct to return information about a builtin vector type.
1675
1676 /// Returns the element type, element count and number of vectors
1677 /// (in case of tuple) for a builtin vector type.
1678 BuiltinVectorTypeInfo
1679 getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const;
1680
1681 /// Return the unique reference to a scalable vector type of the specified
1682 /// element type and scalable number of elements.
1683 /// For RISC-V, number of fields is also provided when it fetching for
1684 /// tuple type.
1685 ///
1686 /// \pre \p EltTy must be a built-in type.
1687 QualType getScalableVectorType(QualType EltTy, unsigned NumElts,
1688 unsigned NumFields = 1) const;
1689
1690 /// Return a WebAssembly externref type.
1692
1693 /// Return the unique reference to a vector type of the specified
1694 /// element type and size.
1695 ///
1696 /// \pre \p VectorType must be a built-in type.
1697 QualType getVectorType(QualType VectorType, unsigned NumElts,
1698 VectorKind VecKind) const;
1699 /// Return the unique reference to the type for a dependently sized vector of
1700 /// the specified element type.
1702 SourceLocation AttrLoc,
1703 VectorKind VecKind) const;
1704
1705 /// Return the unique reference to an extended vector type
1706 /// of the specified element type and size.
1707 ///
1708 /// \pre \p VectorType must be a built-in type.
1709 QualType getExtVectorType(QualType VectorType, unsigned NumElts) const;
1710
1711 /// \pre Return a non-unique reference to the type for a dependently-sized
1712 /// vector of the specified element type.
1713 ///
1714 /// FIXME: We will need these to be uniqued, or at least comparable, at some
1715 /// point.
1717 Expr *SizeExpr,
1718 SourceLocation AttrLoc) const;
1719
1720 /// Return the unique reference to the matrix type of the specified element
1721 /// type and size
1722 ///
1723 /// \pre \p ElementType must be a valid matrix element type (see
1724 /// MatrixType::isValidElementType).
1725 QualType getConstantMatrixType(QualType ElementType, unsigned NumRows,
1726 unsigned NumColumns) const;
1727
1728 /// Return the unique reference to the matrix type of the specified element
1729 /// type and size
1730 QualType getDependentSizedMatrixType(QualType ElementType, Expr *RowExpr,
1731 Expr *ColumnExpr,
1732 SourceLocation AttrLoc) const;
1733
1735 Expr *AddrSpaceExpr,
1736 SourceLocation AttrLoc) const;
1737
1738 /// Return a K&R style C function type like 'int()'.
1740 const FunctionType::ExtInfo &Info) const;
1741
1745
1746 /// Return a normal function type with a typed argument list.
1748 const FunctionProtoType::ExtProtoInfo &EPI) const {
1749 return getFunctionTypeInternal(ResultTy, Args, EPI, false);
1750 }
1751
1753
1754private:
1755 /// Return a normal function type with a typed argument list.
1756 QualType getFunctionTypeInternal(QualType ResultTy, ArrayRef<QualType> Args,
1758 bool OnlyWantCanonical) const;
1759 QualType
1760 getAutoTypeInternal(QualType DeducedType, AutoTypeKeyword Keyword,
1761 bool IsDependent, bool IsPack = false,
1762 TemplateDecl *TypeConstraintConcept = nullptr,
1763 ArrayRef<TemplateArgument> TypeConstraintArgs = {},
1764 bool IsCanon = false) const;
1765
1766public:
1768 NestedNameSpecifier Qualifier,
1769 const TypeDecl *Decl) const;
1770
1771 /// Return the unique reference to the type for the specified type
1772 /// declaration.
1773 QualType getTypeDeclType(const TypeDecl *Decl) const;
1774
1775 /// Use the normal 'getFooBarType' constructors to obtain these types.
1776 QualType getTypeDeclType(const TagDecl *) const = delete;
1777 QualType getTypeDeclType(const TypedefDecl *) const = delete;
1778 QualType getTypeDeclType(const TypeAliasDecl *) const = delete;
1780
1782
1784 NestedNameSpecifier Qualifier, const UsingShadowDecl *D,
1785 QualType UnderlyingType = QualType()) const;
1786
1787 /// Return the unique reference to the type for the specified
1788 /// typedef-name decl.
1789 /// FIXME: TypeMatchesDeclOrNone is a workaround for a serialization issue:
1790 /// The decl underlying type might still not be available.
1793 const TypedefNameDecl *Decl, QualType UnderlyingType = QualType(),
1794 std::optional<bool> TypeMatchesDeclOrNone = std::nullopt) const;
1795
1796 CanQualType getCanonicalTagType(const TagDecl *TD) const;
1798 NestedNameSpecifier Qualifier, const TagDecl *TD,
1799 bool OwnsTag) const;
1800
1801private:
1802 UnresolvedUsingType *getUnresolvedUsingTypeInternal(
1804 const UnresolvedUsingTypenameDecl *D, void *InsertPos,
1805 const Type *CanonicalType) const;
1806
1807 TagType *getTagTypeInternal(ElaboratedTypeKeyword Keyword,
1808 NestedNameSpecifier Qualifier, const TagDecl *Tag,
1809 bool OwnsTag, bool IsInjected,
1810 const Type *CanonicalType,
1811 bool WithFoldingSetNode) const;
1812
1813public:
1814 /// Compute BestType and BestPromotionType for an enum based on the highest
1815 /// number of negative and positive bits of its elements.
1816 /// Returns true if enum width is too large.
1817 bool computeBestEnumTypes(bool IsPacked, unsigned NumNegativeBits,
1818 unsigned NumPositiveBits, QualType &BestType,
1819 QualType &BestPromotionType);
1820
1821 /// Determine whether the given integral value is representable within
1822 /// the given type T.
1823 bool isRepresentableIntegerValue(llvm::APSInt &Value, QualType T);
1824
1825 /// Compute NumNegativeBits and NumPositiveBits for an enum based on
1826 /// the constant values of its enumerators.
1827 template <typename RangeT>
1828 bool computeEnumBits(RangeT EnumConstants, unsigned &NumNegativeBits,
1829 unsigned &NumPositiveBits) {
1830 NumNegativeBits = 0;
1831 NumPositiveBits = 0;
1832 bool MembersRepresentableByInt = true;
1833 for (auto *Elem : EnumConstants) {
1834 EnumConstantDecl *ECD = cast_or_null<EnumConstantDecl>(Elem);
1835 if (!ECD)
1836 continue; // Already issued a diagnostic.
1837
1838 llvm::APSInt InitVal = ECD->getInitVal();
1839 if (InitVal.isUnsigned() || InitVal.isNonNegative()) {
1840 // If the enumerator is zero that should still be counted as a positive
1841 // bit since we need a bit to store the value zero.
1842 unsigned ActiveBits = InitVal.getActiveBits();
1843 NumPositiveBits = std::max({NumPositiveBits, ActiveBits, 1u});
1844 } else {
1845 NumNegativeBits =
1846 std::max(NumNegativeBits, InitVal.getSignificantBits());
1847 }
1848
1849 MembersRepresentableByInt &= isRepresentableIntegerValue(InitVal, IntTy);
1850 }
1851
1852 // If we have an empty set of enumerators we still need one bit.
1853 // From [dcl.enum]p8
1854 // If the enumerator-list is empty, the values of the enumeration are as if
1855 // the enumeration had a single enumerator with value 0
1856 if (!NumPositiveBits && !NumNegativeBits)
1857 NumPositiveBits = 1;
1858
1859 return MembersRepresentableByInt;
1860 }
1861
1865 NestedNameSpecifier Qualifier,
1866 const UnresolvedUsingTypenameDecl *D) const;
1867
1868 QualType getAttributedType(attr::Kind attrKind, QualType modifiedType,
1869 QualType equivalentType,
1870 const Attr *attr = nullptr) const;
1871
1872 QualType getAttributedType(const Attr *attr, QualType modifiedType,
1873 QualType equivalentType) const;
1874
1875 QualType getAttributedType(NullabilityKind nullability, QualType modifiedType,
1876 QualType equivalentType);
1877
1878 QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr,
1879 QualType Wrapped) const;
1880
1882 QualType Wrapped, QualType Contained,
1883 const HLSLAttributedResourceType::Attributes &Attrs);
1884
1885 QualType getHLSLInlineSpirvType(uint32_t Opcode, uint32_t Size,
1886 uint32_t Alignment,
1887 ArrayRef<SpirvOperand> Operands);
1888
1890 Decl *AssociatedDecl, unsigned Index,
1891 UnsignedOrNone PackIndex,
1892 bool Final) const;
1894 unsigned Index, bool Final,
1895 const TemplateArgument &ArgPack);
1897
1898 QualType
1899 getTemplateTypeParmType(unsigned Depth, unsigned Index,
1900 bool ParameterPack,
1901 TemplateTypeParmDecl *ParmDecl = nullptr) const;
1902
1905 ArrayRef<TemplateArgument> CanonicalArgs) const;
1906
1907 QualType
1909 ArrayRef<TemplateArgument> SpecifiedArgs,
1910 ArrayRef<TemplateArgument> CanonicalArgs,
1911 QualType Underlying = QualType()) const;
1912
1913 QualType
1915 ArrayRef<TemplateArgumentLoc> SpecifiedArgs,
1916 ArrayRef<TemplateArgument> CanonicalArgs,
1917 QualType Canon = QualType()) const;
1918
1920 ElaboratedTypeKeyword Keyword, SourceLocation ElaboratedKeywordLoc,
1921 NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKeywordLoc,
1923 const TemplateArgumentListInfo &SpecifiedArgs,
1924 ArrayRef<TemplateArgument> CanonicalArgs,
1925 QualType Canon = QualType()) const;
1926
1927 QualType getParenType(QualType NamedType) const;
1928
1930 const IdentifierInfo *MacroII) const;
1931
1934 const IdentifierInfo *Name) const;
1935
1937
1938 /// Form a pack expansion type with the given pattern.
1939 /// \param NumExpansions The number of expansions for the pack, if known.
1940 /// \param ExpectPackInType If \c false, we should not expect \p Pattern to
1941 /// contain an unexpanded pack. This only makes sense if the pack
1942 /// expansion is used in a context where the arity is inferred from
1943 /// elsewhere, such as if the pattern contains a placeholder type or
1944 /// if this is the canonical type of another pack expansion type.
1946 bool ExpectPackInType = true) const;
1947
1949 ObjCInterfaceDecl *PrevDecl = nullptr) const;
1950
1951 /// Legacy interface: cannot provide type arguments or __kindof.
1953 ObjCProtocolDecl * const *Protocols,
1954 unsigned NumProtocols) const;
1955
1957 ArrayRef<QualType> typeArgs,
1959 bool isKindOf) const;
1960
1962 ArrayRef<ObjCProtocolDecl *> protocols) const;
1964 ObjCTypeParamDecl *New) const;
1965
1967
1968 /// QIdProtocolsAdoptObjCObjectProtocols - Checks that protocols in
1969 /// QT's qualified-id protocol list adopt all protocols in IDecl's list
1970 /// of protocols.
1972 ObjCInterfaceDecl *IDecl);
1973
1974 /// Return a ObjCObjectPointerType type for the given ObjCObjectType.
1976
1977 /// C23 feature and GCC extension.
1978 QualType getTypeOfExprType(Expr *E, TypeOfKind Kind) const;
1979 QualType getTypeOfType(QualType QT, TypeOfKind Kind) const;
1980
1981 QualType getReferenceQualifiedType(const Expr *e) const;
1982
1983 /// C++11 decltype.
1984 QualType getDecltypeType(Expr *e, QualType UnderlyingType) const;
1985
1986 QualType getPackIndexingType(QualType Pattern, Expr *IndexExpr,
1987 bool FullySubstituted = false,
1988 ArrayRef<QualType> Expansions = {},
1989 UnsignedOrNone Index = std::nullopt) const;
1990
1991 /// Unary type transforms
1992 QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType,
1993 UnaryTransformType::UTTKind UKind) const;
1994
1995 /// C++11 deduced auto type.
1996 QualType
1997 getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent,
1998 bool IsPack = false,
1999 TemplateDecl *TypeConstraintConcept = nullptr,
2000 ArrayRef<TemplateArgument> TypeConstraintArgs = {}) const;
2001
2002 /// C++11 deduction pattern for 'auto' type.
2003 QualType getAutoDeductType() const;
2004
2005 /// C++11 deduction pattern for 'auto &&' type.
2006 QualType getAutoRRefDeductType() const;
2007
2008 /// Remove any type constraints from a template parameter type, for
2009 /// equivalence comparison of template parameters.
2010 QualType getUnconstrainedType(QualType T) const;
2011
2012 /// C++17 deduced class template specialization type.
2015 QualType DeducedType,
2016 bool IsDependent) const;
2017
2018private:
2019 QualType getDeducedTemplateSpecializationTypeInternal(
2021 QualType DeducedType, bool IsDependent, QualType Canon) const;
2022
2023public:
2024 /// Return the unique type for "size_t" (C99 7.17), defined in
2025 /// <stddef.h>.
2026 ///
2027 /// The sizeof operator requires this (C99 6.5.3.4p4).
2028 QualType getSizeType() const;
2029
2031
2032 /// Return the unique signed counterpart of
2033 /// the integer type corresponding to size_t.
2034 QualType getSignedSizeType() const;
2035
2036 /// Return the unique type for "intmax_t" (C99 7.18.1.5), defined in
2037 /// <stdint.h>.
2038 CanQualType getIntMaxType() const;
2039
2040 /// Return the unique type for "uintmax_t" (C99 7.18.1.5), defined in
2041 /// <stdint.h>.
2043
2044 /// Return the unique wchar_t type available in C++ (and available as
2045 /// __wchar_t as a Microsoft extension).
2046 QualType getWCharType() const { return WCharTy; }
2047
2048 /// Return the type of wide characters. In C++, this returns the
2049 /// unique wchar_t type. In C99, this returns a type compatible with the type
2050 /// defined in <stddef.h> as defined by the target.
2052
2053 /// Return the type of "signed wchar_t".
2054 ///
2055 /// Used when in C++, as a GCC extension.
2057
2058 /// Return the type of "unsigned wchar_t".
2059 ///
2060 /// Used when in C++, as a GCC extension.
2062
2063 /// In C99, this returns a type compatible with the type
2064 /// defined in <stddef.h> as defined by the target.
2065 QualType getWIntType() const { return WIntTy; }
2066
2067 /// Return a type compatible with "intptr_t" (C99 7.18.1.4),
2068 /// as defined by the target.
2069 QualType getIntPtrType() const;
2070
2071 /// Return a type compatible with "uintptr_t" (C99 7.18.1.4),
2072 /// as defined by the target.
2073 QualType getUIntPtrType() const;
2074
2075 /// Return the unique type for "ptrdiff_t" (C99 7.17) defined in
2076 /// <stddef.h>. Pointer - pointer requires this (C99 6.5.6p9).
2078
2079 /// Return the unique unsigned counterpart of "ptrdiff_t"
2080 /// integer type. The standard (C11 7.21.6.1p7) refers to this type
2081 /// in the definition of %tu format specifier.
2083
2084 /// Return the unique type for "pid_t" defined in
2085 /// <sys/types.h>. We need this to compute the correct type for vfork().
2086 QualType getProcessIDType() const;
2087
2088 /// Return the C structure type used to represent constant CFStrings.
2090
2091 /// Returns the C struct type for objc_super
2092 QualType getObjCSuperType() const;
2093 void setObjCSuperType(QualType ST) { ObjCSuperType = ST; }
2094
2095 /// Get the structure type used to representation CFStrings, or NULL
2096 /// if it hasn't yet been built.
2098 if (CFConstantStringTypeDecl)
2100 /*Qualifier=*/std::nullopt,
2101 CFConstantStringTypeDecl);
2102 return QualType();
2103 }
2107
2108 // This setter/getter represents the ObjC type for an NSConstantString.
2111 return ObjCConstantStringType;
2112 }
2113
2115 return ObjCNSStringType;
2116 }
2117
2119 ObjCNSStringType = T;
2120 }
2121
2122 /// Retrieve the type that \c id has been defined to, which may be
2123 /// different from the built-in \c id if \c id has been typedef'd.
2125 if (ObjCIdRedefinitionType.isNull())
2126 return getObjCIdType();
2127 return ObjCIdRedefinitionType;
2128 }
2129
2130 /// Set the user-written type that redefines \c id.
2132 ObjCIdRedefinitionType = RedefType;
2133 }
2134
2135 /// Retrieve the type that \c Class has been defined to, which may be
2136 /// different from the built-in \c Class if \c Class has been typedef'd.
2138 if (ObjCClassRedefinitionType.isNull())
2139 return getObjCClassType();
2140 return ObjCClassRedefinitionType;
2141 }
2142
2143 /// Set the user-written type that redefines 'SEL'.
2145 ObjCClassRedefinitionType = RedefType;
2146 }
2147
2148 /// Retrieve the type that 'SEL' has been defined to, which may be
2149 /// different from the built-in 'SEL' if 'SEL' has been typedef'd.
2151 if (ObjCSelRedefinitionType.isNull())
2152 return getObjCSelType();
2153 return ObjCSelRedefinitionType;
2154 }
2155
2156 /// Set the user-written type that redefines 'SEL'.
2158 ObjCSelRedefinitionType = RedefType;
2159 }
2160
2161 /// Retrieve the identifier 'NSObject'.
2163 if (!NSObjectName) {
2164 NSObjectName = &Idents.get("NSObject");
2165 }
2166
2167 return NSObjectName;
2168 }
2169
2170 /// Retrieve the identifier 'NSCopying'.
2172 if (!NSCopyingName) {
2173 NSCopyingName = &Idents.get("NSCopying");
2174 }
2175
2176 return NSCopyingName;
2177 }
2178
2180
2182
2183 /// Retrieve the identifier 'bool'.
2185 if (!BoolName)
2186 BoolName = &Idents.get("bool");
2187 return BoolName;
2188 }
2189
2190#define BuiltinTemplate(BTName) \
2191 IdentifierInfo *get##BTName##Name() const { \
2192 if (!Name##BTName) \
2193 Name##BTName = &Idents.get(#BTName); \
2194 return Name##BTName; \
2195 }
2196#include "clang/Basic/BuiltinTemplates.inc"
2197
2198 /// Retrieve the Objective-C "instancetype" type.
2201 /*Qualifier=*/std::nullopt,
2203 }
2204
2205 /// Retrieve the typedef declaration corresponding to the Objective-C
2206 /// "instancetype" type.
2208
2209 /// Set the type for the C FILE type.
2210 void setFILEDecl(TypeDecl *FILEDecl) { this->FILEDecl = FILEDecl; }
2211
2212 /// Retrieve the C FILE type.
2214 if (FILEDecl)
2216 /*Qualifier=*/std::nullopt, FILEDecl);
2217 return QualType();
2218 }
2219
2220 /// Set the type for the C jmp_buf type.
2221 void setjmp_bufDecl(TypeDecl *jmp_bufDecl) {
2222 this->jmp_bufDecl = jmp_bufDecl;
2223 }
2224
2225 /// Retrieve the C jmp_buf type.
2227 if (jmp_bufDecl)
2229 /*Qualifier=*/std::nullopt, jmp_bufDecl);
2230 return QualType();
2231 }
2232
2233 /// Set the type for the C sigjmp_buf type.
2234 void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl) {
2235 this->sigjmp_bufDecl = sigjmp_bufDecl;
2236 }
2237
2238 /// Retrieve the C sigjmp_buf type.
2240 if (sigjmp_bufDecl)
2242 /*Qualifier=*/std::nullopt, sigjmp_bufDecl);
2243 return QualType();
2244 }
2245
2246 /// Set the type for the C ucontext_t type.
2247 void setucontext_tDecl(TypeDecl *ucontext_tDecl) {
2248 this->ucontext_tDecl = ucontext_tDecl;
2249 }
2250
2251 /// Retrieve the C ucontext_t type.
2253 if (ucontext_tDecl)
2255 /*Qualifier=*/std::nullopt, ucontext_tDecl);
2256 return QualType();
2257 }
2258
2259 /// The result type of logical operations, '<', '>', '!=', etc.
2261 return getLangOpts().CPlusPlus ? BoolTy : IntTy;
2262 }
2263
2264 /// Emit the Objective-CC type encoding for the given type \p T into
2265 /// \p S.
2266 ///
2267 /// If \p Field is specified then record field names are also encoded.
2268 void getObjCEncodingForType(QualType T, std::string &S,
2269 const FieldDecl *Field=nullptr,
2270 QualType *NotEncodedT=nullptr) const;
2271
2272 /// Emit the Objective-C property type encoding for the given
2273 /// type \p T into \p S.
2274 void getObjCEncodingForPropertyType(QualType T, std::string &S) const;
2275
2277
2278 /// Put the string version of the type qualifiers \p QT into \p S.
2280 std::string &S) const;
2281
2282 /// Emit the encoded type for the function \p Decl into \p S.
2283 ///
2284 /// This is in the same format as Objective-C method encodings.
2285 ///
2286 /// \returns true if an error occurred (e.g., because one of the parameter
2287 /// types is incomplete), false otherwise.
2288 std::string getObjCEncodingForFunctionDecl(const FunctionDecl *Decl) const;
2289
2290 /// Emit the encoded type for the method declaration \p Decl into
2291 /// \p S.
2293 bool Extended = false) const;
2294
2295 /// Return the encoded type for this block declaration.
2296 std::string getObjCEncodingForBlock(const BlockExpr *blockExpr) const;
2297
2298 /// getObjCEncodingForPropertyDecl - Return the encoded type for
2299 /// this method declaration. If non-NULL, Container must be either
2300 /// an ObjCCategoryImplDecl or ObjCImplementationDecl; it should
2301 /// only be NULL when getting encodings for protocol properties.
2303 const Decl *Container) const;
2304
2306 ObjCProtocolDecl *rProto) const;
2307
2309 const ObjCPropertyDecl *PD,
2310 const Decl *Container) const;
2311
2312 /// Return the size of type \p T for Objective-C encoding purpose,
2313 /// in characters.
2315
2316 /// Retrieve the typedef corresponding to the predefined \c id type
2317 /// in Objective-C.
2318 TypedefDecl *getObjCIdDecl() const;
2319
2320 /// Represents the Objective-CC \c id type.
2321 ///
2322 /// This is set up lazily, by Sema. \c id is always a (typedef for a)
2323 /// pointer type, a pointer to a struct.
2326 /*Qualifier=*/std::nullopt, getObjCIdDecl());
2327 }
2328
2329 /// Retrieve the typedef corresponding to the predefined 'SEL' type
2330 /// in Objective-C.
2331 TypedefDecl *getObjCSelDecl() const;
2332
2333 /// Retrieve the type that corresponds to the predefined Objective-C
2334 /// 'SEL' type.
2337 /*Qualifier=*/std::nullopt, getObjCSelDecl());
2338 }
2339
2341
2342 /// Retrieve the typedef declaration corresponding to the predefined
2343 /// Objective-C 'Class' type.
2345
2346 /// Represents the Objective-C \c Class type.
2347 ///
2348 /// This is set up lazily, by Sema. \c Class is always a (typedef for a)
2349 /// pointer type, a pointer to a struct.
2352 /*Qualifier=*/std::nullopt, getObjCClassDecl());
2353 }
2354
2355 /// Retrieve the Objective-C class declaration corresponding to
2356 /// the predefined \c Protocol class.
2358
2359 /// Retrieve declaration of 'BOOL' typedef
2361 return BOOLDecl;
2362 }
2363
2364 /// Save declaration of 'BOOL' typedef
2366 BOOLDecl = TD;
2367 }
2368
2369 /// type of 'BOOL' type.
2372 /*Qualifier=*/std::nullopt, getBOOLDecl());
2373 }
2374
2375 /// Retrieve the type of the Objective-C \c Protocol class.
2379
2380 /// Retrieve the C type declaration corresponding to the predefined
2381 /// \c __builtin_va_list type.
2383
2384 /// Retrieve the type of the \c __builtin_va_list type.
2387 /*Qualifier=*/std::nullopt, getBuiltinVaListDecl());
2388 }
2389
2390 /// Retrieve the C type declaration corresponding to the predefined
2391 /// \c __va_list_tag type used to help define the \c __builtin_va_list type
2392 /// for some targets.
2393 Decl *getVaListTagDecl() const;
2394
2395 /// Retrieve the C type declaration corresponding to the predefined
2396 /// \c __builtin_ms_va_list type.
2398
2399 /// Retrieve the type of the \c __builtin_ms_va_list type.
2402 /*Qualifier=*/std::nullopt, getBuiltinMSVaListDecl());
2403 }
2404
2405 /// Retrieve the implicitly-predeclared 'struct _GUID' declaration.
2407
2408 /// Retrieve the implicitly-predeclared 'struct _GUID' type.
2410 assert(MSGuidTagDecl && "asked for GUID type but MS extensions disabled");
2412 }
2413
2414 /// Retrieve the implicitly-predeclared 'struct type_info' declaration.
2416 // Lazily create this type on demand - it's only needed for MS builds.
2417 if (!MSTypeInfoTagDecl)
2419 return MSTypeInfoTagDecl;
2420 }
2421
2422 /// Return whether a declaration to a builtin is allowed to be
2423 /// overloaded/redeclared.
2424 bool canBuiltinBeRedeclared(const FunctionDecl *) const;
2425
2426 /// Return a type with additional \c const, \c volatile, or
2427 /// \c restrict qualifiers.
2430 }
2431
2432 /// Un-split a SplitQualType.
2434 return getQualifiedType(split.Ty, split.Quals);
2435 }
2436
2437 /// Return a type with additional qualifiers.
2439 if (!Qs.hasNonFastQualifiers())
2440 return T.withFastQualifiers(Qs.getFastQualifiers());
2441 QualifierCollector Qc(Qs);
2442 const Type *Ptr = Qc.strip(T);
2443 return getExtQualType(Ptr, Qc);
2444 }
2445
2446 /// Return a type with additional qualifiers.
2448 if (!Qs.hasNonFastQualifiers())
2449 return QualType(T, Qs.getFastQualifiers());
2450 return getExtQualType(T, Qs);
2451 }
2452
2453 /// Return a type with the given lifetime qualifier.
2454 ///
2455 /// \pre Neither type.ObjCLifetime() nor \p lifetime may be \c OCL_None.
2457 Qualifiers::ObjCLifetime lifetime) {
2458 assert(type.getObjCLifetime() == Qualifiers::OCL_None);
2459 assert(lifetime != Qualifiers::OCL_None);
2460
2461 Qualifiers qs;
2462 qs.addObjCLifetime(lifetime);
2463 return getQualifiedType(type, qs);
2464 }
2465
2466 /// getUnqualifiedObjCPointerType - Returns version of
2467 /// Objective-C pointer type with lifetime qualifier removed.
2469 if (!type.getTypePtr()->isObjCObjectPointerType() ||
2470 !type.getQualifiers().hasObjCLifetime())
2471 return type;
2472 Qualifiers Qs = type.getQualifiers();
2473 Qs.removeObjCLifetime();
2474 return getQualifiedType(type.getUnqualifiedType(), Qs);
2475 }
2476
2477 /// \brief Return a type with the given __ptrauth qualifier.
2479 assert(!Ty.getPointerAuth());
2480 assert(PointerAuth);
2481
2482 Qualifiers Qs;
2483 Qs.setPointerAuth(PointerAuth);
2484 return getQualifiedType(Ty, Qs);
2485 }
2486
2487 unsigned char getFixedPointScale(QualType Ty) const;
2488 unsigned char getFixedPointIBits(QualType Ty) const;
2489 llvm::FixedPointSemantics getFixedPointSemantics(QualType Ty) const;
2490 llvm::APFixedPoint getFixedPointMax(QualType Ty) const;
2491 llvm::APFixedPoint getFixedPointMin(QualType Ty) const;
2492
2494 SourceLocation NameLoc) const;
2495
2497 UnresolvedSetIterator End) const;
2499
2501 bool TemplateKeyword,
2502 TemplateName Template) const;
2505
2507 Decl *AssociatedDecl,
2508 unsigned Index,
2509 UnsignedOrNone PackIndex,
2510 bool Final) const;
2512 Decl *AssociatedDecl,
2513 unsigned Index,
2514 bool Final) const;
2515
2516 /// Represents a TemplateName which had some of its default arguments
2517 /// deduced. This both represents this default argument deduction as sugar,
2518 /// and provides the support for it's equivalences through canonicalization.
2519 /// For example DeducedTemplateNames which have the same set of default
2520 /// arguments are equivalent, and are also equivalent to the underlying
2521 /// template when the deduced template arguments are the same.
2523 DefaultArguments DefaultArgs) const;
2524
2526 /// No error
2528
2529 /// Missing a type
2531
2532 /// Missing a type from <stdio.h>
2534
2535 /// Missing a type from <setjmp.h>
2537
2538 /// Missing a type from <ucontext.h>
2540 };
2541
2542 QualType DecodeTypeStr(const char *&Str, const ASTContext &Context,
2544 bool &RequireICE, bool AllowTypeModifiers) const;
2545
2546 /// Return the type for the specified builtin.
2547 ///
2548 /// If \p IntegerConstantArgs is non-null, it is filled in with a bitmask of
2549 /// arguments to the builtin that are required to be integer constant
2550 /// expressions.
2552 unsigned *IntegerConstantArgs = nullptr) const;
2553
2554 /// Types and expressions required to build C++2a three-way comparisons
2555 /// using operator<=>, including the values return by builtin <=> operators.
2557
2558private:
2559 CanQualType getFromTargetType(unsigned Type) const;
2560 TypeInfo getTypeInfoImpl(const Type *T) const;
2561
2562 //===--------------------------------------------------------------------===//
2563 // Type Predicates.
2564 //===--------------------------------------------------------------------===//
2565
2566public:
2567 /// Return one of the GCNone, Weak or Strong Objective-C garbage
2568 /// collection attributes.
2570
2571 /// Return true if the given vector types are of the same unqualified
2572 /// type or if they are equivalent to the same GCC vector type.
2573 ///
2574 /// \note This ignores whether they are target-specific (AltiVec or Neon)
2575 /// types.
2576 bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec);
2577
2578 /// Return true if the given types are an RISC-V vector builtin type and a
2579 /// VectorType that is a fixed-length representation of the RISC-V vector
2580 /// builtin type for a specific vector-length.
2581 bool areCompatibleRVVTypes(QualType FirstType, QualType SecondType);
2582
2583 /// Return true if the given vector types are lax-compatible RISC-V vector
2584 /// types as defined by -flax-vector-conversions=, which permits implicit
2585 /// conversions between vectors with different number of elements and/or
2586 /// incompatible element types, false otherwise.
2587 bool areLaxCompatibleRVVTypes(QualType FirstType, QualType SecondType);
2588
2589 /// Return true if the type has been explicitly qualified with ObjC ownership.
2590 /// A type may be implicitly qualified with ownership under ObjC ARC, and in
2591 /// some cases the compiler treats these differently.
2593
2594 /// Return true if this is an \c NSObject object with its \c NSObject
2595 /// attribute set.
2597 return Ty->isObjCNSObjectType();
2598 }
2599
2600 //===--------------------------------------------------------------------===//
2601 // Type Sizing and Analysis
2602 //===--------------------------------------------------------------------===//
2603
2604 /// Return the APFloat 'semantics' for the specified scalar floating
2605 /// point type.
2606 const llvm::fltSemantics &getFloatTypeSemantics(QualType T) const;
2607
2608 /// Get the size and alignment of the specified complete type in bits.
2609 TypeInfo getTypeInfo(const Type *T) const;
2610 TypeInfo getTypeInfo(QualType T) const { return getTypeInfo(T.getTypePtr()); }
2611
2612 /// Get default simd alignment of the specified complete type in bits.
2613 unsigned getOpenMPDefaultSimdAlign(QualType T) const;
2614
2615 /// Return the size of the specified (complete) type \p T, in bits.
2616 uint64_t getTypeSize(QualType T) const { return getTypeInfo(T).Width; }
2617 uint64_t getTypeSize(const Type *T) const { return getTypeInfo(T).Width; }
2618
2619 /// Return the size of the character type, in bits.
2620 uint64_t getCharWidth() const {
2621 return getTypeSize(CharTy);
2622 }
2623
2624 /// Convert a size in bits to a size in characters.
2625 CharUnits toCharUnitsFromBits(int64_t BitSize) const;
2626
2627 /// Convert a size in characters to a size in bits.
2628 int64_t toBits(CharUnits CharSize) const;
2629
2630 /// Return the size of the specified (complete) type \p T, in
2631 /// characters.
2633 CharUnits getTypeSizeInChars(const Type *T) const;
2634
2635 std::optional<CharUnits> getTypeSizeInCharsIfKnown(QualType Ty) const {
2636 if (Ty->isIncompleteType() || Ty->isDependentType())
2637 return std::nullopt;
2638 return getTypeSizeInChars(Ty);
2639 }
2640
2641 std::optional<CharUnits> getTypeSizeInCharsIfKnown(const Type *Ty) const {
2642 return getTypeSizeInCharsIfKnown(QualType(Ty, 0));
2643 }
2644
2645 /// Return the ABI-specified alignment of a (complete) type \p T, in
2646 /// bits.
2647 unsigned getTypeAlign(QualType T) const { return getTypeInfo(T).Align; }
2648 unsigned getTypeAlign(const Type *T) const { return getTypeInfo(T).Align; }
2649
2650 /// Return the ABI-specified natural alignment of a (complete) type \p T,
2651 /// before alignment adjustments, in bits.
2652 ///
2653 /// This alignment is currently used only by ARM and AArch64 when passing
2654 /// arguments of a composite type.
2656 return getTypeUnadjustedAlign(T.getTypePtr());
2657 }
2658 unsigned getTypeUnadjustedAlign(const Type *T) const;
2659
2660 /// Return the alignment of a type, in bits, or 0 if
2661 /// the type is incomplete and we cannot determine the alignment (for
2662 /// example, from alignment attributes). The returned alignment is the
2663 /// Preferred alignment if NeedsPreferredAlignment is true, otherwise is the
2664 /// ABI alignment.
2666 bool NeedsPreferredAlignment = false) const;
2667
2668 /// Return the ABI-specified alignment of a (complete) type \p T, in
2669 /// characters.
2671 CharUnits getTypeAlignInChars(const Type *T) const;
2672
2673 /// Return the PreferredAlignment of a (complete) type \p T, in
2674 /// characters.
2678
2679 /// getTypeUnadjustedAlignInChars - Return the ABI-specified alignment of a type,
2680 /// in characters, before alignment adjustments. This method does not work on
2681 /// incomplete types.
2684
2685 // getTypeInfoDataSizeInChars - Return the size of a type, in chars. If the
2686 // type is a record, its data size is returned.
2688
2689 TypeInfoChars getTypeInfoInChars(const Type *T) const;
2691
2692 /// Determine if the alignment the type has was required using an
2693 /// alignment attribute.
2694 bool isAlignmentRequired(const Type *T) const;
2695 bool isAlignmentRequired(QualType T) const;
2696
2697 /// More type predicates useful for type checking/promotion
2698 bool isPromotableIntegerType(QualType T) const; // C99 6.3.1.1p2
2699
2700 /// Return the "preferred" alignment of the specified type \p T for
2701 /// the current target, in bits.
2702 ///
2703 /// This can be different than the ABI alignment in cases where it is
2704 /// beneficial for performance or backwards compatibility preserving to
2705 /// overalign a data type. (Note: despite the name, the preferred alignment
2706 /// is ABI-impacting, and not an optimization.)
2708 return getPreferredTypeAlign(T.getTypePtr());
2709 }
2710 unsigned getPreferredTypeAlign(const Type *T) const;
2711
2712 /// Return the default alignment for __attribute__((aligned)) on
2713 /// this target, to be used if no alignment value is specified.
2715
2716 /// Return the alignment in bits that should be given to a
2717 /// global variable with type \p T. If \p VD is non-null it will be
2718 /// considered specifically for the query.
2719 unsigned getAlignOfGlobalVar(QualType T, const VarDecl *VD) const;
2720
2721 /// Return the alignment in characters that should be given to a
2722 /// global variable with type \p T. If \p VD is non-null it will be
2723 /// considered specifically for the query.
2725
2726 /// Return the minimum alignment as specified by the target. If \p VD is
2727 /// non-null it may be used to identify external or weak variables.
2728 unsigned getMinGlobalAlignOfVar(uint64_t Size, const VarDecl *VD) const;
2729
2730 /// Return a conservative estimate of the alignment of the specified
2731 /// decl \p D.
2732 ///
2733 /// \pre \p D must not be a bitfield type, as bitfields do not have a valid
2734 /// alignment.
2735 ///
2736 /// If \p ForAlignof, references are treated like their underlying type
2737 /// and large arrays don't get any special treatment. If not \p ForAlignof
2738 /// it computes the value expected by CodeGen: references are treated like
2739 /// pointers and large arrays get extra alignment.
2740 CharUnits getDeclAlign(const Decl *D, bool ForAlignof = false) const;
2741
2742 /// Return the alignment (in bytes) of the thrown exception object. This is
2743 /// only meaningful for targets that allocate C++ exceptions in a system
2744 /// runtime, such as those using the Itanium C++ ABI.
2746
2747 /// Get or compute information about the layout of the specified
2748 /// record (struct/union/class) \p D, which indicates its size and field
2749 /// position information.
2750 const ASTRecordLayout &getASTRecordLayout(const RecordDecl *D) const;
2751
2752 /// Get or compute information about the layout of the specified
2753 /// Objective-C interface.
2755 const;
2756
2757 void DumpRecordLayout(const RecordDecl *RD, raw_ostream &OS,
2758 bool Simple = false) const;
2759
2760 /// Get our current best idea for the key function of the
2761 /// given record decl, or nullptr if there isn't one.
2762 ///
2763 /// The key function is, according to the Itanium C++ ABI section 5.2.3:
2764 /// ...the first non-pure virtual function that is not inline at the
2765 /// point of class definition.
2766 ///
2767 /// Other ABIs use the same idea. However, the ARM C++ ABI ignores
2768 /// virtual functions that are defined 'inline', which means that
2769 /// the result of this computation can change.
2771
2772 /// Observe that the given method cannot be a key function.
2773 /// Checks the key-function cache for the method's class and clears it
2774 /// if matches the given declaration.
2775 ///
2776 /// This is used in ABIs where out-of-line definitions marked
2777 /// inline are not considered to be key functions.
2778 ///
2779 /// \param method should be the declaration from the class definition
2780 void setNonKeyFunction(const CXXMethodDecl *method);
2781
2782 /// Loading virtual member pointers using the virtual inheritance model
2783 /// always results in an adjustment using the vbtable even if the index is
2784 /// zero.
2785 ///
2786 /// This is usually OK because the first slot in the vbtable points
2787 /// backwards to the top of the MDC. However, the MDC might be reusing a
2788 /// vbptr from an nv-base. In this case, the first slot in the vbtable
2789 /// points to the start of the nv-base which introduced the vbptr and *not*
2790 /// the MDC. Modify the NonVirtualBaseAdjustment to account for this.
2792
2793 /// Get the offset of a FieldDecl or IndirectFieldDecl, in bits.
2794 uint64_t getFieldOffset(const ValueDecl *FD) const;
2795
2796 /// Get the offset of an ObjCIvarDecl in bits.
2797 uint64_t lookupFieldBitOffset(const ObjCInterfaceDecl *OID,
2798 const ObjCIvarDecl *Ivar) const;
2799
2800 /// Find the 'this' offset for the member path in a pointer-to-member
2801 /// APValue.
2803
2804 bool isNearlyEmpty(const CXXRecordDecl *RD) const;
2805
2807
2808 /// If \p T is null pointer, assume the target in ASTContext.
2809 MangleContext *createMangleContext(const TargetInfo *T = nullptr);
2810
2811 /// Creates a device mangle context to correctly mangle lambdas in a mixed
2812 /// architecture compile by setting the lambda mangling number source to the
2813 /// DeviceLambdaManglingNumber. Currently this asserts that the TargetInfo
2814 /// (from the AuxTargetInfo) is a an itanium target.
2816
2817 void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass,
2819
2820 unsigned CountNonClassIvars(const ObjCInterfaceDecl *OI) const;
2821 void CollectInheritedProtocols(const Decl *CDecl,
2823
2824 /// Return true if the specified type has unique object representations
2825 /// according to (C++17 [meta.unary.prop]p9)
2826 bool
2828 bool CheckIfTriviallyCopyable = true) const;
2829
2830 //===--------------------------------------------------------------------===//
2831 // Type Operators
2832 //===--------------------------------------------------------------------===//
2833
2834 /// Return the canonical (structural) type corresponding to the
2835 /// specified potentially non-canonical type \p T.
2836 ///
2837 /// The non-canonical version of a type may have many "decorated" versions of
2838 /// types. Decorators can include typedefs, 'typeof' operators, etc. The
2839 /// returned type is guaranteed to be free of any of these, allowing two
2840 /// canonical types to be compared for exact equality with a simple pointer
2841 /// comparison.
2843 return CanQualType::CreateUnsafe(T.getCanonicalType());
2844 }
2845
2846 const Type *getCanonicalType(const Type *T) const {
2847 return T->getCanonicalTypeInternal().getTypePtr();
2848 }
2849
2850 /// Return the canonical parameter type corresponding to the specific
2851 /// potentially non-canonical one.
2852 ///
2853 /// Qualifiers are stripped off, functions are turned into function
2854 /// pointers, and arrays decay one level into pointers.
2856
2857 /// Determine whether the given types \p T1 and \p T2 are equivalent.
2858 bool hasSameType(QualType T1, QualType T2) const {
2859 return getCanonicalType(T1) == getCanonicalType(T2);
2860 }
2861 bool hasSameType(const Type *T1, const Type *T2) const {
2862 return getCanonicalType(T1) == getCanonicalType(T2);
2863 }
2864
2865 /// Determine whether the given expressions \p X and \p Y are equivalent.
2866 bool hasSameExpr(const Expr *X, const Expr *Y) const;
2867
2868 /// Return this type as a completely-unqualified array type,
2869 /// capturing the qualifiers in \p Quals.
2870 ///
2871 /// This will remove the minimal amount of sugaring from the types, similar
2872 /// to the behavior of QualType::getUnqualifiedType().
2873 ///
2874 /// \param T is the qualified type, which may be an ArrayType
2875 ///
2876 /// \param Quals will receive the full set of qualifiers that were
2877 /// applied to the array.
2878 ///
2879 /// \returns if this is an array type, the completely unqualified array type
2880 /// that corresponds to it. Otherwise, returns T.getUnqualifiedType().
2883 Qualifiers Quals;
2884 return getUnqualifiedArrayType(T, Quals);
2885 }
2886
2887 /// Determine whether the given types are equivalent after
2888 /// cvr-qualifiers have been removed.
2890 return getCanonicalType(T1).getTypePtr() ==
2892 }
2893
2895 bool IsParam) const {
2896 auto SubTnullability = SubT->getNullability();
2897 auto SuperTnullability = SuperT->getNullability();
2898 if (SubTnullability.has_value() == SuperTnullability.has_value()) {
2899 // Neither has nullability; return true
2900 if (!SubTnullability)
2901 return true;
2902 // Both have nullability qualifier.
2903 if (*SubTnullability == *SuperTnullability ||
2904 *SubTnullability == NullabilityKind::Unspecified ||
2905 *SuperTnullability == NullabilityKind::Unspecified)
2906 return true;
2907
2908 if (IsParam) {
2909 // Ok for the superclass method parameter to be "nonnull" and the subclass
2910 // method parameter to be "nullable"
2911 return (*SuperTnullability == NullabilityKind::NonNull &&
2912 *SubTnullability == NullabilityKind::Nullable);
2913 }
2914 // For the return type, it's okay for the superclass method to specify
2915 // "nullable" and the subclass method specify "nonnull"
2916 return (*SuperTnullability == NullabilityKind::Nullable &&
2917 *SubTnullability == NullabilityKind::NonNull);
2918 }
2919 return true;
2920 }
2921
2922 bool ObjCMethodsAreEqual(const ObjCMethodDecl *MethodDecl,
2923 const ObjCMethodDecl *MethodImp);
2924
2925 bool UnwrapSimilarTypes(QualType &T1, QualType &T2,
2926 bool AllowPiMismatch = true) const;
2928 bool AllowPiMismatch = true) const;
2929
2930 /// Determine if two types are similar, according to the C++ rules. That is,
2931 /// determine if they are the same other than qualifiers on the initial
2932 /// sequence of pointer / pointer-to-member / array (and in Clang, object
2933 /// pointer) types and their element types.
2934 ///
2935 /// Clang offers a number of qualifiers in addition to the C++ qualifiers;
2936 /// those qualifiers are also ignored in the 'similarity' check.
2937 bool hasSimilarType(QualType T1, QualType T2) const;
2938
2939 /// Determine if two types are similar, ignoring only CVR qualifiers.
2940 bool hasCvrSimilarType(QualType T1, QualType T2);
2941
2942 /// Retrieves the default calling convention for the current context.
2943 ///
2944 /// The context's default calling convention may differ from the current
2945 /// target's default calling convention if the -fdefault-calling-conv option
2946 /// is used; to get the target's default calling convention, e.g. for built-in
2947 /// functions, call getTargetInfo().getDefaultCallingConv() instead.
2949 bool IsCXXMethod) const;
2950
2951 /// Retrieves the "canonical" template name that refers to a
2952 /// given template.
2953 ///
2954 /// The canonical template name is the simplest expression that can
2955 /// be used to refer to a given template. For most templates, this
2956 /// expression is just the template declaration itself. For example,
2957 /// the template std::vector can be referred to via a variety of
2958 /// names---std::vector, \::std::vector, vector (if vector is in
2959 /// scope), etc.---but all of these names map down to the same
2960 /// TemplateDecl, which is used to form the canonical template name.
2961 ///
2962 /// Dependent template names are more interesting. Here, the
2963 /// template name could be something like T::template apply or
2964 /// std::allocator<T>::template rebind, where the nested name
2965 /// specifier itself is dependent. In this case, the canonical
2966 /// template name uses the shortest form of the dependent
2967 /// nested-name-specifier, which itself contains all canonical
2968 /// types, values, and templates.
2970 bool IgnoreDeduced = false) const;
2971
2972 /// Determine whether the given template names refer to the same
2973 /// template.
2974 bool hasSameTemplateName(const TemplateName &X, const TemplateName &Y,
2975 bool IgnoreDeduced = false) const;
2976
2977 /// Determine whether the two declarations refer to the same entity.
2978 bool isSameEntity(const NamedDecl *X, const NamedDecl *Y) const;
2979
2980 /// Determine whether two template parameter lists are similar enough
2981 /// that they may be used in declarations of the same template.
2983 const TemplateParameterList *Y) const;
2984
2985 /// Determine whether two template parameters are similar enough
2986 /// that they may be used in declarations of the same template.
2987 bool isSameTemplateParameter(const NamedDecl *X, const NamedDecl *Y) const;
2988
2989 /// Determine whether two 'requires' expressions are similar enough that they
2990 /// may be used in re-declarations.
2991 ///
2992 /// Use of 'requires' isn't mandatory, works with constraints expressed in
2993 /// other ways too.
2995 const AssociatedConstraint &ACY) const;
2996
2997 /// Determine whether two 'requires' expressions are similar enough that they
2998 /// may be used in re-declarations.
2999 ///
3000 /// Use of 'requires' isn't mandatory, works with constraints expressed in
3001 /// other ways too.
3002 bool isSameConstraintExpr(const Expr *XCE, const Expr *YCE) const;
3003
3004 /// Determine whether two type contraint are similar enough that they could
3005 /// used in declarations of the same template.
3006 bool isSameTypeConstraint(const TypeConstraint *XTC,
3007 const TypeConstraint *YTC) const;
3008
3009 /// Determine whether two default template arguments are similar enough
3010 /// that they may be used in declarations of the same template.
3012 const NamedDecl *Y) const;
3013
3014 /// Retrieve the "canonical" template argument.
3015 ///
3016 /// The canonical template argument is the simplest template argument
3017 /// (which may be a type, value, expression, or declaration) that
3018 /// expresses the value of the argument.
3020 const;
3021
3022 /// Canonicalize the given template argument list.
3023 ///
3024 /// Returns true if any arguments were non-canonical, false otherwise.
3025 bool
3027
3028 /// Canonicalize the given TemplateTemplateParmDecl.
3031
3033 TemplateTemplateParmDecl *TTP) const;
3035 TemplateTemplateParmDecl *CanonTTP) const;
3036
3037 /// Determine whether the given template arguments \p Arg1 and \p Arg2 are
3038 /// equivalent.
3040 const TemplateArgument &Arg2) const;
3041
3042 /// Type Query functions. If the type is an instance of the specified class,
3043 /// return the Type pointer for the underlying maximally pretty type. This
3044 /// is a member of ASTContext because this may need to do some amount of
3045 /// canonicalization, e.g. to move type qualifiers into the element type.
3046 const ArrayType *getAsArrayType(QualType T) const;
3048 return dyn_cast_or_null<ConstantArrayType>(getAsArrayType(T));
3049 }
3051 return dyn_cast_or_null<VariableArrayType>(getAsArrayType(T));
3052 }
3054 return dyn_cast_or_null<IncompleteArrayType>(getAsArrayType(T));
3055 }
3057 const {
3058 return dyn_cast_or_null<DependentSizedArrayType>(getAsArrayType(T));
3059 }
3060
3061 /// Return the innermost element type of an array type.
3062 ///
3063 /// For example, will return "int" for int[m][n]
3064 QualType getBaseElementType(const ArrayType *VAT) const;
3065
3066 /// Return the innermost element type of a type (which needn't
3067 /// actually be an array type).
3069
3070 /// Return number of constant array elements.
3071 uint64_t getConstantArrayElementCount(const ConstantArrayType *CA) const;
3072
3073 /// Return number of elements initialized in an ArrayInitLoopExpr.
3074 uint64_t
3076
3077 /// Perform adjustment on the parameter type of a function.
3078 ///
3079 /// This routine adjusts the given parameter type @p T to the actual
3080 /// parameter type used by semantic analysis (C99 6.7.5.3p[7,8],
3081 /// C++ [dcl.fct]p3). The adjusted parameter type is returned.
3083
3084 /// Retrieve the parameter type as adjusted for use in the signature
3085 /// of a function, decaying array and function types and removing top-level
3086 /// cv-qualifiers.
3088
3090
3091 /// Return the properly qualified result of decaying the specified
3092 /// array type to a pointer.
3093 ///
3094 /// This operation is non-trivial when handling typedefs etc. The canonical
3095 /// type of \p T must be an array type, this returns a pointer to a properly
3096 /// qualified element of the array.
3097 ///
3098 /// See C99 6.7.5.3p7 and C99 6.3.2.1p3.
3100
3101 /// Return the type that \p PromotableType will promote to: C99
3102 /// 6.3.1.1p2, assuming that \p PromotableType is a promotable integer type.
3103 QualType getPromotedIntegerType(QualType PromotableType) const;
3104
3105 /// Recurses in pointer/array types until it finds an Objective-C
3106 /// retainable type and returns its ownership.
3108
3109 /// Whether this is a promotable bitfield reference according
3110 /// to C99 6.3.1.1p2, bullet 2 (and GCC extensions).
3111 ///
3112 /// \returns the type this bit-field will promote to, or NULL if no
3113 /// promotion occurs.
3115
3116 /// Return the highest ranked integer type, see C99 6.3.1.8p1.
3117 ///
3118 /// If \p LHS > \p RHS, returns 1. If \p LHS == \p RHS, returns 0. If
3119 /// \p LHS < \p RHS, return -1.
3120 int getIntegerTypeOrder(QualType LHS, QualType RHS) const;
3121
3122 /// Compare the rank of the two specified floating point types,
3123 /// ignoring the domain of the type (i.e. 'double' == '_Complex double').
3124 ///
3125 /// If \p LHS > \p RHS, returns 1. If \p LHS == \p RHS, returns 0. If
3126 /// \p LHS < \p RHS, return -1.
3127 int getFloatingTypeOrder(QualType LHS, QualType RHS) const;
3128
3129 /// Compare the rank of two floating point types as above, but compare equal
3130 /// if both types have the same floating-point semantics on the target (i.e.
3131 /// long double and double on AArch64 will return 0).
3133
3134 unsigned getTargetAddressSpace(LangAS AS) const;
3135
3136 LangAS getLangASForBuiltinAddressSpace(unsigned AS) const;
3137
3138 /// Get target-dependent integer value for null pointer which is used for
3139 /// constant folding.
3140 uint64_t getTargetNullPointerValue(QualType QT) const;
3141
3143 return AddrSpaceMapMangling || isTargetAddressSpace(AS);
3144 }
3145
3146 bool hasAnyFunctionEffects() const { return AnyFunctionEffects; }
3147
3148 // Merges two exception specifications, such that the resulting
3149 // exception spec is the union of both. For example, if either
3150 // of them can throw something, the result can throw it as well.
3154 SmallVectorImpl<QualType> &ExceptionTypeStorage,
3155 bool AcceptDependent) const;
3156
3157 // For two "same" types, return a type which has
3158 // the common sugar between them. If Unqualified is true,
3159 // both types need only be the same unqualified type.
3160 // The result will drop the qualifiers which do not occur
3161 // in both types.
3163 bool Unqualified = false) const;
3164
3165private:
3166 // Helper for integer ordering
3167 unsigned getIntegerRank(const Type *T) const;
3168
3169public:
3170 //===--------------------------------------------------------------------===//
3171 // Type Compatibility Predicates
3172 //===--------------------------------------------------------------------===//
3173
3174 /// Compatibility predicates used to check assignment expressions.
3176 bool CompareUnqualified = false); // C99 6.2.7p1
3177
3180
3181 bool isObjCIdType(QualType T) const { return T == getObjCIdType(); }
3182
3183 bool isObjCClassType(QualType T) const { return T == getObjCClassType(); }
3184
3185 bool isObjCSelType(QualType T) const { return T == getObjCSelType(); }
3186
3188 const ObjCObjectPointerType *RHS,
3189 bool ForCompare);
3190
3192 const ObjCObjectPointerType *RHS);
3193
3194 // Check the safety of assignment from LHS to RHS
3196 const ObjCObjectPointerType *RHSOPT);
3198 const ObjCObjectType *RHS);
3200 const ObjCObjectPointerType *LHSOPT,
3201 const ObjCObjectPointerType *RHSOPT,
3202 bool BlockReturnType);
3205 const ObjCObjectPointerType *RHSOPT);
3207
3208 // Functions for calculating composite types
3209 QualType mergeTypes(QualType, QualType, bool OfBlockPointer = false,
3210 bool Unqualified = false, bool BlockReturnType = false,
3211 bool IsConditionalOperator = false);
3212 QualType mergeFunctionTypes(QualType, QualType, bool OfBlockPointer = false,
3213 bool Unqualified = false, bool AllowCXX = false,
3214 bool IsConditionalOperator = false);
3216 bool OfBlockPointer = false,
3217 bool Unqualified = false);
3219 bool OfBlockPointer=false,
3220 bool Unqualified = false);
3222
3224
3225 /// This function merges the ExtParameterInfo lists of two functions. It
3226 /// returns true if the lists are compatible. The merged list is returned in
3227 /// NewParamInfos.
3228 ///
3229 /// \param FirstFnType The type of the first function.
3230 ///
3231 /// \param SecondFnType The type of the second function.
3232 ///
3233 /// \param CanUseFirst This flag is set to true if the first function's
3234 /// ExtParameterInfo list can be used as the composite list of
3235 /// ExtParameterInfo.
3236 ///
3237 /// \param CanUseSecond This flag is set to true if the second function's
3238 /// ExtParameterInfo list can be used as the composite list of
3239 /// ExtParameterInfo.
3240 ///
3241 /// \param NewParamInfos The composite list of ExtParameterInfo. The list is
3242 /// empty if none of the flags are set.
3243 ///
3245 const FunctionProtoType *FirstFnType,
3246 const FunctionProtoType *SecondFnType,
3247 bool &CanUseFirst, bool &CanUseSecond,
3249
3250 void ResetObjCLayout(const ObjCInterfaceDecl *D);
3251
3253 const ObjCInterfaceDecl *SubClass) {
3254 ObjCSubClasses[D].push_back(SubClass);
3255 }
3256
3257 //===--------------------------------------------------------------------===//
3258 // Integer Predicates
3259 //===--------------------------------------------------------------------===//
3260
3261 // The width of an integer, as defined in C99 6.2.6.2. This is the number
3262 // of bits in an integer type excluding any padding bits.
3263 unsigned getIntWidth(QualType T) const;
3264
3265 // Per C99 6.2.5p6, for every signed integer type, there is a corresponding
3266 // unsigned integer type. This method takes a signed type, and returns the
3267 // corresponding unsigned integer type.
3268 // With the introduction of fixed point types in ISO N1169, this method also
3269 // accepts fixed point types and returns the corresponding unsigned type for
3270 // a given fixed point type.
3272
3273 // Per C99 6.2.5p6, for every signed integer type, there is a corresponding
3274 // unsigned integer type. This method takes an unsigned type, and returns the
3275 // corresponding signed integer type.
3276 // With the introduction of fixed point types in ISO N1169, this method also
3277 // accepts fixed point types and returns the corresponding signed type for
3278 // a given fixed point type.
3280
3281 // Per ISO N1169, this method accepts fixed point types and returns the
3282 // corresponding saturated type for a given fixed point type.
3284
3285 // Per ISO N1169, this method accepts fixed point types and returns the
3286 // corresponding non-saturated type for a given fixed point type.
3288
3289 // This method accepts fixed point types and returns the corresponding signed
3290 // type. Unlike getCorrespondingUnsignedType(), this only accepts unsigned
3291 // fixed point types because there are unsigned integer types like bool and
3292 // char8_t that don't have signed equivalents.
3294
3295 //===--------------------------------------------------------------------===//
3296 // Integer Values
3297 //===--------------------------------------------------------------------===//
3298
3299 /// Make an APSInt of the appropriate width and signedness for the
3300 /// given \p Value and integer \p Type.
3301 llvm::APSInt MakeIntValue(uint64_t Value, QualType Type) const {
3302 // If Type is a signed integer type larger than 64 bits, we need to be sure
3303 // to sign extend Res appropriately.
3304 llvm::APSInt Res(64, !Type->isSignedIntegerOrEnumerationType());
3305 Res = Value;
3306 unsigned Width = getIntWidth(Type);
3307 if (Width != Res.getBitWidth())
3308 return Res.extOrTrunc(Width);
3309 return Res;
3310 }
3311
3312 bool isSentinelNullExpr(const Expr *E);
3313
3314 /// Get the implementation of the ObjCInterfaceDecl \p D, or nullptr if
3315 /// none exists.
3317
3318 /// Get the implementation of the ObjCCategoryDecl \p D, or nullptr if
3319 /// none exists.
3321
3322 /// Return true if there is at least one \@implementation in the TU.
3324 return !ObjCImpls.empty();
3325 }
3326
3327 /// Set the implementation of ObjCInterfaceDecl.
3329 ObjCImplementationDecl *ImplD);
3330
3331 /// Set the implementation of ObjCCategoryDecl.
3333 ObjCCategoryImplDecl *ImplD);
3334
3335 /// Get the duplicate declaration of a ObjCMethod in the same
3336 /// interface, or null if none exists.
3337 const ObjCMethodDecl *
3339
3341 const ObjCMethodDecl *Redecl);
3342
3343 /// Returns the Objective-C interface that \p ND belongs to if it is
3344 /// an Objective-C method/property/ivar etc. that is part of an interface,
3345 /// otherwise returns null.
3347
3348 /// Set the copy initialization expression of a block var decl. \p CanThrow
3349 /// indicates whether the copy expression can throw or not.
3350 void setBlockVarCopyInit(const VarDecl* VD, Expr *CopyExpr, bool CanThrow);
3351
3352 /// Get the copy initialization expression of the VarDecl \p VD, or
3353 /// nullptr if none exists.
3355
3356 /// Allocate an uninitialized TypeSourceInfo.
3357 ///
3358 /// The caller should initialize the memory held by TypeSourceInfo using
3359 /// the TypeLoc wrappers.
3360 ///
3361 /// \param T the type that will be the basis for type source info. This type
3362 /// should refer to how the declarator was written in source code, not to
3363 /// what type semantic analysis resolved the declarator to.
3364 ///
3365 /// \param Size the size of the type info to create, or 0 if the size
3366 /// should be calculated based on the type.
3367 TypeSourceInfo *CreateTypeSourceInfo(QualType T, unsigned Size = 0) const;
3368
3369 /// Allocate a TypeSourceInfo where all locations have been
3370 /// initialized to a given location, which defaults to the empty
3371 /// location.
3374 SourceLocation Loc = SourceLocation()) const;
3375
3376 /// Add a deallocation callback that will be invoked when the
3377 /// ASTContext is destroyed.
3378 ///
3379 /// \param Callback A callback function that will be invoked on destruction.
3380 ///
3381 /// \param Data Pointer data that will be provided to the callback function
3382 /// when it is called.
3383 void AddDeallocation(void (*Callback)(void *), void *Data) const;
3384
3385 /// If T isn't trivially destructible, calls AddDeallocation to register it
3386 /// for destruction.
3387 template <typename T> void addDestruction(T *Ptr) const {
3388 if (!std::is_trivially_destructible<T>::value) {
3389 auto DestroyPtr = [](void *V) { static_cast<T *>(V)->~T(); };
3390 AddDeallocation(DestroyPtr, Ptr);
3391 }
3392 }
3393
3396
3397 /// Determines if the decl can be CodeGen'ed or deserialized from PCH
3398 /// lazily, only when used; this is only relevant for function or file scoped
3399 /// var definitions.
3400 ///
3401 /// \returns true if the function/var must be CodeGen'ed/deserialized even if
3402 /// it is not used.
3403 bool DeclMustBeEmitted(const Decl *D);
3404
3405 /// Visits all versions of a multiversioned function with the passed
3406 /// predicate.
3408 const FunctionDecl *FD,
3409 llvm::function_ref<void(FunctionDecl *)> Pred) const;
3410
3411 const CXXConstructorDecl *
3413
3415 CXXConstructorDecl *CD);
3416
3418
3420
3422
3424
3425 void setManglingNumber(const NamedDecl *ND, unsigned Number);
3426 unsigned getManglingNumber(const NamedDecl *ND,
3427 bool ForAuxTarget = false) const;
3428
3429 void setStaticLocalNumber(const VarDecl *VD, unsigned Number);
3430 unsigned getStaticLocalNumber(const VarDecl *VD) const;
3431
3433 return !TypeAwareOperatorNewAndDeletes.empty();
3434 }
3435 void setIsDestroyingOperatorDelete(const FunctionDecl *FD, bool IsDestroying);
3436 bool isDestroyingOperatorDelete(const FunctionDecl *FD) const;
3438 bool IsTypeAware);
3439 bool isTypeAwareOperatorNewOrDelete(const FunctionDecl *FD) const;
3440
3441 /// Retrieve the context for computing mangling numbers in the given
3442 /// DeclContext.
3446 const Decl *D);
3447
3448 std::unique_ptr<MangleNumberingContext> createMangleNumberingContext() const;
3449
3450 /// Used by ParmVarDecl to store on the side the
3451 /// index of the parameter when it exceeds the size of the normal bitfield.
3452 void setParameterIndex(const ParmVarDecl *D, unsigned index);
3453
3454 /// Used by ParmVarDecl to retrieve on the side the
3455 /// index of the parameter when it exceeds the size of the normal bitfield.
3456 unsigned getParameterIndex(const ParmVarDecl *D) const;
3457
3458 /// Return a string representing the human readable name for the specified
3459 /// function declaration or file name. Used by SourceLocExpr and
3460 /// PredefinedExpr to cache evaluated results.
3462
3463 /// Return the next version number to be used for a string literal evaluated
3464 /// as part of constant evaluation.
3465 unsigned getNextStringLiteralVersion() { return NextStringLiteralVersion++; }
3466
3467 /// Return a declaration for the global GUID object representing the given
3468 /// GUID value.
3470
3471 /// Return a declaration for a uniquified anonymous global constant
3472 /// corresponding to a given APValue.
3475
3476 /// Return the template parameter object of the given type with the given
3477 /// value.
3479 const APValue &V) const;
3480
3481 /// Parses the target attributes passed in, and returns only the ones that are
3482 /// valid feature names.
3483 ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD) const;
3484
3485 void getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap,
3486 const FunctionDecl *) const;
3487 void getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap,
3488 GlobalDecl GD) const;
3489
3490 /// Generates and stores SYCL kernel metadata for the provided
3491 /// SYCL kernel entry point function. The provided function must have
3492 /// an attached sycl_kernel_entry_point attribute that specifies a unique
3493 /// type for the name of a SYCL kernel. Callers are required to detect
3494 /// conflicting SYCL kernel names and issue a diagnostic prior to calling
3495 /// this function.
3497
3498 /// Given a type used as a SYCL kernel name, returns a reference to the
3499 /// metadata generated from the corresponding SYCL kernel entry point.
3500 /// Aborts if the provided type is not a registered SYCL kernel name.
3502
3503 /// Returns a pointer to the metadata generated from the corresponding
3504 /// SYCLkernel entry point if the provided type corresponds to a registered
3505 /// SYCL kernel name. Returns a null pointer otherwise.
3507
3508 //===--------------------------------------------------------------------===//
3509 // Statistics
3510 //===--------------------------------------------------------------------===//
3511
3512 /// The number of implicitly-declared default constructors.
3514
3515 /// The number of implicitly-declared default constructors for
3516 /// which declarations were built.
3518
3519 /// The number of implicitly-declared copy constructors.
3521
3522 /// The number of implicitly-declared copy constructors for
3523 /// which declarations were built.
3525
3526 /// The number of implicitly-declared move constructors.
3528
3529 /// The number of implicitly-declared move constructors for
3530 /// which declarations were built.
3532
3533 /// The number of implicitly-declared copy assignment operators.
3535
3536 /// The number of implicitly-declared copy assignment operators for
3537 /// which declarations were built.
3539
3540 /// The number of implicitly-declared move assignment operators.
3542
3543 /// The number of implicitly-declared move assignment operators for
3544 /// which declarations were built.
3546
3547 /// The number of implicitly-declared destructors.
3549
3550 /// The number of implicitly-declared destructors for which
3551 /// declarations were built.
3553
3554public:
3555 /// Initialize built-in types.
3556 ///
3557 /// This routine may only be invoked once for a given ASTContext object.
3558 /// It is normally invoked after ASTContext construction.
3559 ///
3560 /// \param Target The target
3561 void InitBuiltinTypes(const TargetInfo &Target,
3562 const TargetInfo *AuxTarget = nullptr);
3563
3564private:
3565 void InitBuiltinType(CanQualType &R, BuiltinType::Kind K);
3566
3567 class ObjCEncOptions {
3568 unsigned Bits;
3569
3570 ObjCEncOptions(unsigned Bits) : Bits(Bits) {}
3571
3572 public:
3573 ObjCEncOptions() : Bits(0) {}
3574
3575#define OPT_LIST(V) \
3576 V(ExpandPointedToStructures, 0) \
3577 V(ExpandStructures, 1) \
3578 V(IsOutermostType, 2) \
3579 V(EncodingProperty, 3) \
3580 V(IsStructField, 4) \
3581 V(EncodeBlockParameters, 5) \
3582 V(EncodeClassNames, 6) \
3583
3584#define V(N,I) ObjCEncOptions& set##N() { Bits |= 1 << I; return *this; }
3585OPT_LIST(V)
3586#undef V
3587
3588#define V(N,I) bool N() const { return Bits & 1 << I; }
3589OPT_LIST(V)
3590#undef V
3591
3592#undef OPT_LIST
3593
3594 [[nodiscard]] ObjCEncOptions keepingOnly(ObjCEncOptions Mask) const {
3595 return Bits & Mask.Bits;
3596 }
3597
3598 [[nodiscard]] ObjCEncOptions forComponentType() const {
3599 ObjCEncOptions Mask = ObjCEncOptions()
3600 .setIsOutermostType()
3601 .setIsStructField();
3602 return Bits & ~Mask.Bits;
3603 }
3604 };
3605
3606 // Return the Objective-C type encoding for a given type.
3607 void getObjCEncodingForTypeImpl(QualType t, std::string &S,
3608 ObjCEncOptions Options,
3609 const FieldDecl *Field,
3610 QualType *NotEncodedT = nullptr) const;
3611
3612 // Adds the encoding of the structure's members.
3613 void getObjCEncodingForStructureImpl(RecordDecl *RD, std::string &S,
3614 const FieldDecl *Field,
3615 bool includeVBases = true,
3616 QualType *NotEncodedT=nullptr) const;
3617
3618public:
3619 // Adds the encoding of a method parameter or return type.
3621 QualType T, std::string& S,
3622 bool Extended) const;
3623
3624 /// Returns true if this is an inline-initialized static data member
3625 /// which is treated as a definition for MSVC compatibility.
3626 bool isMSStaticDataMemberInlineDefinition(const VarDecl *VD) const;
3627
3629 /// Not an inline variable.
3630 None,
3631
3632 /// Weak definition of inline variable.
3634
3635 /// Weak for now, might become strong later in this TU.
3637
3638 /// Strong definition.
3640 };
3641
3642 /// Determine whether a definition of this inline variable should
3643 /// be treated as a weak or strong definition. For compatibility with
3644 /// C++14 and before, for a constexpr static data member, if there is an
3645 /// out-of-line declaration of the member, we may promote it from weak to
3646 /// strong.
3649
3650private:
3652 friend class DeclContext;
3653
3654 const ASTRecordLayout &getObjCLayout(const ObjCInterfaceDecl *D) const;
3655
3656 /// A set of deallocations that should be performed when the
3657 /// ASTContext is destroyed.
3658 // FIXME: We really should have a better mechanism in the ASTContext to
3659 // manage running destructors for types which do variable sized allocation
3660 // within the AST. In some places we thread the AST bump pointer allocator
3661 // into the datastructures which avoids this mess during deallocation but is
3662 // wasteful of memory, and here we require a lot of error prone book keeping
3663 // in order to track and run destructors while we're tearing things down.
3664 using DeallocationFunctionsAndArguments =
3665 llvm::SmallVector<std::pair<void (*)(void *), void *>, 16>;
3666 mutable DeallocationFunctionsAndArguments Deallocations;
3667
3668 // FIXME: This currently contains the set of StoredDeclMaps used
3669 // by DeclContext objects. This probably should not be in ASTContext,
3670 // but we include it here so that ASTContext can quickly deallocate them.
3671 llvm::PointerIntPair<StoredDeclsMap *, 1> LastSDM;
3672
3673 std::vector<Decl *> TraversalScope;
3674
3675 std::unique_ptr<VTableContextBase> VTContext;
3676
3677 void ReleaseDeclContextMaps();
3678
3679public:
3680 enum PragmaSectionFlag : unsigned {
3687 PSF_Invalid = 0x80000000U,
3688 };
3689
3701
3702 llvm::StringMap<SectionInfo> SectionInfos;
3703
3704 /// Return a new OMPTraitInfo object owned by this context.
3706
3707 /// Whether a C++ static variable or CUDA/HIP kernel may be externalized.
3708 bool mayExternalize(const Decl *D) const;
3709
3710 /// Whether a C++ static variable or CUDA/HIP kernel should be externalized.
3711 bool shouldExternalize(const Decl *D) const;
3712
3713 /// Resolve the root record to be used to derive the vtable pointer
3714 /// authentication policy for the specified record.
3715 const CXXRecordDecl *
3716 baseForVTableAuthentication(const CXXRecordDecl *ThisClass) const;
3717
3718 bool useAbbreviatedThunkName(GlobalDecl VirtualMethodDecl,
3719 StringRef MangledName);
3720
3721 StringRef getCUIDHash() const;
3722
3723private:
3724 /// All OMPTraitInfo objects live in this collection, one per
3725 /// `pragma omp [begin] declare variant` directive.
3726 SmallVector<std::unique_ptr<OMPTraitInfo>, 4> OMPTraitInfoVector;
3727
3728 llvm::DenseMap<GlobalDecl, llvm::StringSet<>> ThunksToBeAbbreviated;
3729};
3730
3731/// Insertion operator for diagnostics.
3733 const ASTContext::SectionInfo &Section);
3734
3735/// Utility function for constructing a nullary selector.
3736inline Selector GetNullarySelector(StringRef name, ASTContext &Ctx) {
3737 const IdentifierInfo *II = &Ctx.Idents.get(name);
3738 return Ctx.Selectors.getSelector(0, &II);
3739}
3740
3741/// Utility function for constructing an unary selector.
3742inline Selector GetUnarySelector(StringRef name, ASTContext &Ctx) {
3743 const IdentifierInfo *II = &Ctx.Idents.get(name);
3744 return Ctx.Selectors.getSelector(1, &II);
3745}
3746
3747} // namespace clang
3748
3749// operator new and delete aren't allowed inside namespaces.
3750
3751/// Placement new for using the ASTContext's allocator.
3752///
3753/// This placement form of operator new uses the ASTContext's allocator for
3754/// obtaining memory.
3755///
3756/// IMPORTANT: These are also declared in clang/AST/ASTContextAllocate.h!
3757/// Any changes here need to also be made there.
3758///
3759/// We intentionally avoid using a nothrow specification here so that the calls
3760/// to this operator will not perform a null check on the result -- the
3761/// underlying allocator never returns null pointers.
3762///
3763/// Usage looks like this (assuming there's an ASTContext 'Context' in scope):
3764/// @code
3765/// // Default alignment (8)
3766/// IntegerLiteral *Ex = new (Context) IntegerLiteral(arguments);
3767/// // Specific alignment
3768/// IntegerLiteral *Ex2 = new (Context, 4) IntegerLiteral(arguments);
3769/// @endcode
3770/// Memory allocated through this placement new operator does not need to be
3771/// explicitly freed, as ASTContext will free all of this memory when it gets
3772/// destroyed. Please note that you cannot use delete on the pointer.
3773///
3774/// @param Bytes The number of bytes to allocate. Calculated by the compiler.
3775/// @param C The ASTContext that provides the allocator.
3776/// @param Alignment The alignment of the allocated memory (if the underlying
3777/// allocator supports it).
3778/// @return The allocated memory. Could be nullptr.
3779inline void *operator new(size_t Bytes, const clang::ASTContext &C,
3780 size_t Alignment /* = 8 */) {
3781 return C.Allocate(Bytes, Alignment);
3782}
3783
3784/// Placement delete companion to the new above.
3785///
3786/// This operator is just a companion to the new above. There is no way of
3787/// invoking it directly; see the new operator for more details. This operator
3788/// is called implicitly by the compiler if a placement new expression using
3789/// the ASTContext throws in the object constructor.
3790inline void operator delete(void *Ptr, const clang::ASTContext &C, size_t) {
3791 C.Deallocate(Ptr);
3792}
3793
3794/// This placement form of operator new[] uses the ASTContext's allocator for
3795/// obtaining memory.
3796///
3797/// We intentionally avoid using a nothrow specification here so that the calls
3798/// to this operator will not perform a null check on the result -- the
3799/// underlying allocator never returns null pointers.
3800///
3801/// Usage looks like this (assuming there's an ASTContext 'Context' in scope):
3802/// @code
3803/// // Default alignment (8)
3804/// char *data = new (Context) char[10];
3805/// // Specific alignment
3806/// char *data = new (Context, 4) char[10];
3807/// @endcode
3808/// Memory allocated through this placement new[] operator does not need to be
3809/// explicitly freed, as ASTContext will free all of this memory when it gets
3810/// destroyed. Please note that you cannot use delete on the pointer.
3811///
3812/// @param Bytes The number of bytes to allocate. Calculated by the compiler.
3813/// @param C The ASTContext that provides the allocator.
3814/// @param Alignment The alignment of the allocated memory (if the underlying
3815/// allocator supports it).
3816/// @return The allocated memory. Could be nullptr.
3817inline void *operator new[](size_t Bytes, const clang::ASTContext& C,
3818 size_t Alignment /* = 8 */) {
3819 return C.Allocate(Bytes, Alignment);
3820}
3821
3822/// Placement delete[] companion to the new[] above.
3823///
3824/// This operator is just a companion to the new[] above. There is no way of
3825/// invoking it directly; see the new[] operator for more details. This operator
3826/// is called implicitly by the compiler if a placement new[] expression using
3827/// the ASTContext throws in the object constructor.
3828inline void operator delete[](void *Ptr, const clang::ASTContext &C, size_t) {
3829 C.Deallocate(Ptr);
3830}
3831
3832/// Create the representation of a LazyGenerationalUpdatePtr.
3833template <typename Owner, typename T,
3834 void (clang::ExternalASTSource::*Update)(Owner)>
3837 const clang::ASTContext &Ctx, T Value) {
3838 // Note, this is implemented here so that ExternalASTSource.h doesn't need to
3839 // include ASTContext.h. We explicitly instantiate it for all relevant types
3840 // in ASTContext.cpp.
3841 if (auto *Source = Ctx.getExternalSource())
3842 return new (Ctx) LazyData(Source, Value);
3843 return Value;
3844}
3845
3846#endif // LLVM_CLANG_AST_ASTCONTEXT_H
#define OPT_LIST(V)
#define V(N, I)
Forward declaration of all AST node types.
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
#define X(type, name)
Definition Value.h:97
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
#define SM(sm)
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
This file declares types used to describe SYCL kernels.
Defines the clang::SourceLocation class and associated facilities.
#define CXXABI(Name, Str)
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:188
ASTContext(LangOptions &LOpts, SourceManager &SM, IdentifierTable &idents, SelectorTable &sels, Builtin::Context &builtins, TranslationUnitKind TUKind)
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
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
SourceManager & getSourceManager()
Definition ASTContext.h:798
TranslationUnitDecl * getTranslationUnitDecl() const
const ConstantArrayType * getAsConstantArrayType(QualType T) const
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.
LangAS getOpenCLTypeAddrSpace(const Type *T) const
Get address space for OpenCL type.
friend class ASTWriter
Definition ASTContext.h:518
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.
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
uint64_t getTypeSize(const Type *T) const
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:953
unsigned getManglingNumber(const NamedDecl *ND, bool ForAuxTarget=false) const
CanQualType LongTy
const SmallVectorImpl< Type * > & getTypes() const
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
@ Weak
Weak definition of inline variable.
@ WeakUnknown
Weak for now, might become strong later in this TU.
const ProfileList & getProfileList() const
Definition ASTContext.h:910
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
CanQualType SatUnsignedFractTy
CanQualType getAdjustedType(CanQualType Orig, CanQualType New) const
void setInstantiatedFromUsingDecl(NamedDecl *Inst, NamedDecl *Pattern)
Remember that the using decl Inst is an instantiation of the using decl Pattern of a class template.
bool areCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given types are an RISC-V vector builtin type and a VectorType that is a fixed-len...
ExternCContextDecl * getExternCContextDecl() const
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD) const
Parses the target attributes passed in, and returns only the ones that are valid feature names.
QualType 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
bool AnyObjCImplementation()
Return true if there is at least one @implementation in the TU.
CanQualType UnsignedShortAccumTy
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:838
DeclListNode * AllocateDeclListNode(clang::NamedDecl *ND)
Allocates a DeclListNode or returns one from the ListNodeFreeList pool.
Definition ASTContext.h:827
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
QualType getCanonicalTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName T, ArrayRef< TemplateArgument > CanonicalArgs) const
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
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.
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:741
comments::FullComment * cloneFullComment(comments::FullComment *FC, const Decl *D) const
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:653
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.
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.
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
QualType getUnsignedPointerDiffType() const
Return the unique unsigned counterpart of "ptrdiff_t" integer type.
QualType getucontext_tType() const
Retrieve the C ucontext_t type.
std::optional< CharUnits > getTypeSizeInCharsIfKnown(const Type *Ty) const
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.
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:783
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
CanQualType ShortAccumTy
ASTMutationListener * getASTMutationListener() const
Retrieve a pointer to the AST mutation listener associated with this AST context, if any.
unsigned NumImplicitCopyAssignmentOperatorsDeclared
The number of implicitly-declared copy assignment operators for which declarations were built.
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,...
unsigned char getFixedPointIBits(QualType Ty) const
QualType getSubstBuiltinTemplatePack(const TemplateArgument &ArgPack)
QualType getCorrespondingSignedFixedPointType(QualType Ty) const
IntrusiveRefCntPtr< ExternalASTSource > ExternalSource
Definition ASTContext.h:742
CanQualType FloatTy
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.
bool isObjCIdType(QualType T) const
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 ...
friend class IncrementalParser
Definition ASTContext.h:521
unsigned NumImplicitDestructorsDeclared
The number of implicitly-declared destructors for which declarations were built.
bool isObjCClassType(QualType T) const
void setObjCNSStringType(QualType T)
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:914
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
bool propertyTypesAreCompatible(QualType, QualType)
void setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst, UsingShadowDecl *Pattern)
CanQualType DoubleTy
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
CanQualType SatLongAccumTy
const XRayFunctionFilter & getXRayFilter() const
Definition ASTContext.h:906
CanQualType getIntMaxType() const
Return the unique type for "intmax_t" (C99 7.18.1.5), defined in <stdint.h>.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
OpenCLTypeKind getOpenCLTypeKind(const Type *T) const
Map an AST Type to an OpenCLTypeKind enum value.
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.
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.
void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl)
Set the type for the C sigjmp_buf type.
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
CanQualType OMPArrayShapingTy
ASTContext(LangOptions &LOpts, SourceManager &SM, IdentifierTable &idents, SelectorTable &sels, Builtin::Context &builtins, TranslationUnitKind TUKind)
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
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 '...
void addComment(const RawComment &RC)
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'.
void setFILEDecl(TypeDecl *FILEDecl)
Set the type for the C FILE type.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const IncompleteArrayType * getAsIncompleteArrayType(QualType T) const
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
QualType mergeTagDefinitions(QualType, QualType)
overridden_method_range overridden_methods(const CXXMethodDecl *Method) const
void setIsTypeAwareOperatorNewOrDelete(const FunctionDecl *FD, bool IsTypeAware)
bool hasSeenTypeAwareOperatorNewOrDelete() const
QualType getDependentBitIntType(bool Unsigned, Expr *BitsExpr) const
Return a dependent bit-precise integer type with the specified signedness and bit count.
void setObjCImplementation(ObjCInterfaceDecl *IFaceD, ObjCImplementationDecl *ImplD)
Set the implementation of ObjCInterfaceDecl.
StringRef getCUIDHash() const
bool isMSStaticDataMemberInlineDefinition(const VarDecl *VD) const
Returns true if this is an inline-initialized static data member which is treated as a definition for...
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
CanQualType VoidPtrTy
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
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:817
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
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
QualType getUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const UsingShadowDecl *D, QualType UnderlyingType=QualType()) const
CanQualType WideCharTy
CanQualType OMPIteratorTy
IdentifierTable & Idents
Definition ASTContext.h:737
Builtin::Context & BuiltinInfo
Definition ASTContext.h:739
bool computeEnumBits(RangeT EnumConstants, unsigned &NumNegativeBits, unsigned &NumPositiveBits)
Compute NumNegativeBits and NumPositiveBits for an enum based on the constant values of its enumerato...
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:891
QualType getConstType(QualType T) const
Return the uniqued reference to the type for a const qualified type.
bool containsAddressDiscriminatedPointerAuth(QualType T) const
Examines a given type, and returns whether the type itself is address discriminated,...
Definition ASTContext.h:642
QualType getFunctionTypeWithoutPtrSizes(QualType T)
Get a function type and produce the equivalent function type where pointer size address spaces in the...
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.
SelectorTable & Selectors
Definition ASTContext.h:738
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...
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:924
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)
TagDecl * MSTypeInfoTagDecl
TypedefDecl * getBOOLDecl() const
Retrieve declaration of 'BOOL' typedef.
CanQualType SatShortFractTy
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...
TemplateTemplateParmDecl * insertCanonicalTemplateTemplateParmDeclInternal(TemplateTemplateParmDecl *CanonTTP) const
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
QualType getObjCInstanceType()
Retrieve the Objective-C "instancetype" type.
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:852
CanQualType Ibm128Ty
void setASTMutationListener(ASTMutationListener *Listener)
Attach an AST mutation listener to the AST context.
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:859
CanQualType getCanonicalSizeType() const
bool typesAreBlockPointerCompatible(QualType, QualType)
CanQualType SatUnsignedAccumTy
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.
friend class ASTReader
Definition ASTContext.h:517
QualType getObjCProtoType() const
Retrieve the type of the Objective-C Protocol class.
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)
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
CanQualType ObjCBuiltinIdTy
overridden_cxx_method_iterator overridden_methods_end(const CXXMethodDecl *Method) const
VTableContextBase * getVTableContext()
void setBOOLDecl(TypedefDecl *TD)
Save declaration of 'BOOL' typedef.
llvm::SetVector< const ValueDecl * > CUDAExternalDeviceDeclODRUsedByHost
Keep track of CUDA/HIP external kernels or device variables ODR-used by host code.
ComparisonCategories CompCategories
Types and expressions required to build C++2a three-way comparisons using operator<=>,...
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
CanQualType BoolTy
void cacheRawCommentForDecl(const Decl &OriginalD, const RawComment &Comment) const
Attaches Comment to OriginalD and to its redeclaration chain and removes the redeclaration chain from...
void attachCommentsToJustParsedDecls(ArrayRef< Decl * > Decls, const Preprocessor *PP)
Searches existing comments for doc comments that should be attached to Decls.
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth,...
llvm::BumpPtrAllocator & getAllocator() const
Definition ASTContext.h:807
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
friend class ASTDeclReader
Definition ASTContext.h:516
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:901
struct clang::ASTContext::CUDAConstantEvalContext CUDAConstantEvalCtx
IdentifierInfo * getNSObjectName() const
Retrieve the identifier 'NSObject'.
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.
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
CanQualType UnsignedFractTy
QualType getjmp_bufType() const
Retrieve the C jmp_buf type.
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.
void addOverriddenMethod(const CXXMethodDecl *Method, const CXXMethodDecl *Overridden)
Note that the given C++ Method overrides the given Overridden method.
TemplateTemplateParmDecl * findCanonicalTemplateTemplateParmDeclInternal(TemplateTemplateParmDecl *TTP) const
const TargetInfo * getAuxTargetInfo() const
Definition ASTContext.h:857
CanQualType Float128Ty
CanQualType ObjCBuiltinClassTy
unsigned NumImplicitDefaultConstructorsDeclared
The number of implicitly-declared default constructors for which declarations were built.
CanQualType UnresolvedTemplateTy
void setucontext_tDecl(TypeDecl *ucontext_tDecl)
Set the type for the C ucontext_t type.
OMPTraitInfo & getNewOMPTraitInfo()
Return a new OMPTraitInfo object owned by this context.
friend class CXXRecordDecl
Definition ASTContext.h:520
CanQualType UnsignedLongTy
llvm::DenseSet< const FunctionDecl * > CUDAImplicitHostDeviceFunUsedByDevice
Keep track of CUDA/HIP implicit host device functions used on device side in device compilation.
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
const TranslationUnitKind TUKind
Definition ASTContext.h:740
QualType getQualifiedType(const Type *T, Qualifiers Qs) const
Return a type with additional qualifiers.
CanQualType UnsignedLongAccumTy
QualType AutoRRefDeductTy
QualType getRestrictType(QualType T) const
Return the uniqued reference to the type for a restrict qualified type.
TypeInfo getTypeInfo(const Type *T) const
Get the size and alignment of the specified complete type in bits.
CanQualType ShortFractTy
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.
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,...
CanQualType BoundMemberTy
CanQualType SatUnsignedShortFractTy
CanQualType CharTy
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:927
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.
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.
CanQualType IntTy
llvm::DenseSet< const VarDecl * > CUDADeviceVarODRUsedByHost
Keep track of CUDA/HIP device-side variables ODR-used by host code.
CanQualType PseudoObjectTy
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
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.
unsigned NumImplicitDestructors
The number of implicitly-declared destructors.
CanQualType Float16Ty
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
bool isAlignmentRequired(const Type *T) const
Determine if the alignment the type has was required using an alignment attribute.
TagDecl * MSGuidTagDecl
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
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
ASTMutationListener * Listener
Definition ASTContext.h:743
void setNonKeyFunction(const CXXMethodDecl *method)
Observe that the given method cannot be a key function.
CanQualType ObjCBuiltinBoolTy
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.
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:799
CanQualType OverloadTy
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.
CanQualType OCLClkEventTy
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.
const clang::PrintingPolicy & getPrintingPolicy() const
Definition ASTContext.h:790
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)
llvm::FixedPointSemantics getFixedPointSemantics(QualType Ty) const
CanQualType SatUnsignedShortAccumTy
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.
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.
GVALinkage GetGVALinkageForVariable(const VarDecl *VD) const
llvm::PointerUnion< VarTemplateDecl *, MemberSpecializationInfo * > TemplateOrSpecializationInfo
A type synonym for the TemplateOrInstantiation mapping.
Definition ASTContext.h:512
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)...
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.
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.
QualType getCorrespondingUnsaturatedType(QualType Ty) const
comments::FullComment * getCommentForDecl(const Decl *D, const Preprocessor *PP) const
Return parsed documentation comment attached to a given declaration.
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.
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.
CanQualType UnsignedInt128Ty
CanQualType BuiltinFnTy
ObjCInterfaceDecl * getObjCProtocolDecl() const
Retrieve the Objective-C class declaration corresponding to the predefined Protocol class.
unsigned NumImplicitDefaultConstructors
The number of implicitly-declared default constructors.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
llvm::iterator_range< overridden_cxx_method_iterator > overridden_method_range
unsigned NumImplicitMoveAssignmentOperatorsDeclared
The number of implicitly-declared move assignment operators for which declarations were built.
void setManglingNumber(const NamedDecl *ND, unsigned Number)
llvm::DenseMap< const Decl *, const RawComment * > DeclRawComments
Mapping from declaration to directly attached comment.
Definition ASTContext.h:933
CanQualType OCLSamplerTy
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
CanQualType getCanonicalTypeDeclType(const TypeDecl *TD) const
CanQualType VoidTy
QualType getPackExpansionType(QualType Pattern, UnsignedOrNone NumExpansions, bool ExpectPackInType=true) const
Form a pack expansion type with the given pattern.
CanQualType UnsignedCharTy
CanQualType UnsignedShortFractTy
BuiltinTemplateDecl * buildBuiltinTemplateDecl(BuiltinTemplateKind BTK, const IdentifierInfo *II) const
void * Allocate(size_t Size, unsigned Align=8) const
Definition ASTContext.h:811
bool canBuiltinBeRedeclared(const FunctionDecl *) const
Return whether a declaration to a builtin is allowed to be overloaded/redeclared.
CanQualType UnsignedIntTy
unsigned NumImplicitMoveConstructors
The number of implicitly-declared move constructors.
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.
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.
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...
TagDecl * getMSGuidTagDecl() const
Retrieve the implicitly-predeclared 'struct _GUID' declaration.
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
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
CanQualType UnsignedLongLongTy
QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error, unsigned *IntegerConstantArgs=nullptr) const
Return the type for the specified builtin.
CanQualType OCLReserveIDTy
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:845
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
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
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.
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
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)
CanQualType getDecayedType(CanQualType T) const
QualType getObjCIdRedefinitionType() const
Retrieve the type that id has been defined to, which may be different from the built-in id if id has ...
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.
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.
CanQualType getMSGuidType() const
Retrieve the implicitly-predeclared 'struct _GUID' type.
const VariableArrayType * getAsVariableArrayType(QualType T) const
QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType, UnaryTransformType::UTTKind UKind) const
Unary type transforms.
const Type * getCanonicalType(const Type *T) const
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
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'.
bool hasDirectOwnershipQualifier(QualType Ty) const
Return true if the type has been explicitly qualified with ObjC ownership.
CanQualType FractTy
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()
DiagnosticsEngine & getDiagnostics() const
llvm::StringRef backupStr(llvm::StringRef S) const
Definition ASTContext.h:819
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...
CanQualType LongAccumTy
interp::Context & getInterpContext()
Returns the clang bytecode interpreter context.
CanQualType Char32Ty
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.
UnnamedGlobalConstantDecl * getUnnamedGlobalConstantDecl(QualType Ty, const APValue &Value) const
Return a declaration for a uniquified anonymous global constant corresponding to a given APValue.
CanQualType SatFractTy
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
const TargetInfo & getTargetInfo() const
Definition ASTContext.h:856
void setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst, FieldDecl *Tmpl)
CanQualType OCLQueueTy
CanQualType LongFractTy
CanQualType SatShortAccumTy
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
CanQualType BFloat16Ty
unsigned NumImplicitCopyConstructors
The number of implicitly-declared copy constructors.
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
CanQualType IncompleteMatrixIdxTy
std::optional< CharUnits > getTypeSizeInCharsIfKnown(QualType Ty) const
friend class DeclarationNameTable
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.
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
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.
void setjmp_bufDecl(TypeDecl *jmp_bufDecl)
Set the type for the C jmp_buf type.
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.
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.
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.
uint64_t getConstantArrayElementCount(const ConstantArrayType *CA) const
Return number of constant array elements.
CanQualType SatUnsignedLongAccumTy
QualType getUnconstrainedType(QualType T) const
Remove any type constraints from a template parameter type, for equivalence comparison of template pa...
CanQualType LongLongTy
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.
llvm::DenseMap< const Decl *, const Decl * > CommentlessRedeclChains
Keeps track of redeclaration chains that don't have any comment attached.
Definition ASTContext.h:949
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.
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()
CanQualType WCharTy
bool hasSameNullabilityTypeQualifier(QualType SubT, QualType SuperT, bool IsParam) const
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.
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:814
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:940
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.
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)
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'.
friend class DeclContext
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)
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.
@ GE_Missing_stdio
Missing a type from <stdio.h>
@ GE_Missing_type
Missing a type.
@ GE_Missing_ucontext
Missing a type from <ucontext.h>
@ GE_Missing_setjmp
Missing a type from <setjmp.h>
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
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
CanQualType UnsignedAccumTy
void setObjCMethodRedeclaration(const ObjCMethodDecl *MD, const ObjCMethodDecl *Redecl)
void addTypedefNameForUnnamedTagDecl(TagDecl *TD, TypedefNameDecl *TND)
bool isDependenceAllowed() const
Definition ASTContext.h:897
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.
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.
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
void setPrintingPolicy(const clang::PrintingPolicy &Policy)
Definition ASTContext.h:794
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
RawComment * getRawCommentForDeclNoCacheImpl(const Decl *D, const SourceLocation RepresentativeLocForDecl, const std::map< unsigned, RawComment * > &CommentsInFile) const
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
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'.
void setIsDestroyingOperatorDelete(const FunctionDecl *FD, bool IsDestroying)
uint64_t getCharWidth() const
Return the size of the character type, in bits.
CanQualType getPointerType(CanQualType T) const
QualType getUnqualifiedArrayType(QualType T) const
import_range local_imports() const
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
unsigned NumImplicitMoveAssignmentOperators
The number of implicitly-declared move assignment operators.
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
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:3720
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:3164
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)
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
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:3758
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
The name of a declaration.
Represents a ValueDecl that came out of a declarator.
Definition Decl.h:779
Represents an array type in C++ whose size is a value-dependent expression.
Definition TypeBase.h:4009
Represents a dependent template name that cannot be resolved prior to template instantiation.
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:5264
A class which abstracts out some details necessary for making a call.
Definition TypeBase.h:4571
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition TypeBase.h:4460
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:3907
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
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...
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:7903
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
PredefinedSugarKind Kind
Definition TypeBase.h:8196
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
A (possibly-)qualified type.
Definition TypeBase.h:937
PointerAuthQualifier getPointerAuth() const
Definition TypeBase.h:1453
A qualifier set is used to build a set of qualifiers.
Definition TypeBase.h:8225
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
Definition TypeBase.h:8232
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.
clang::DiagStorageAllocator DiagStorageAllocator
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
TagTypeKind TagKind
Definition Decl.h:3719
Kind
The basic C++ ABI kind.
Exposes information about the current target.
Definition TargetInfo.h:226
A convenient class for passing around template argument information.
Represents a template argument.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Represents a C++ template name within the type system.
A template parameter object.
Stores a list of template parameters for a TemplateDecl and its derived classes.
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:8256
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:2225
bool isObjCNSObjectType() const
Definition Type.cpp:5279
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition TypeBase.h:2782
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
Definition Type.cpp:2436
std::optional< NullabilityKind > getNullability() const
Determine the nullability of the given type.
Definition Type.cpp:5022
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.
Represents the dependent type named by a dependently-scoped typename using declaration,...
Definition TypeBase.h:5980
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:3964
Represents a GCC generic vector type.
Definition TypeBase.h:4173
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
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.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
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)
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.
Definition Specifiers.h:352
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
Definition Specifiers.h:357
@ NonNull
Values of this type can never be null.
Definition Specifiers.h:350
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
Definition Parser.h:61
TypeOfKind
The kind of 'typeof' expression we're after.
Definition TypeBase.h:918
SmallVector< Attr *, 4 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
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...
Definition Linkage.h:54
Selector GetUnarySelector(StringRef name, ASTContext &Ctx)
Utility function for constructing an unary selector.
@ Result
The result type of a method or function.
Definition TypeBase.h:905
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition TypeBase.h:3717
const FunctionProtoType * T
@ Template
We are parsing a template declaration.
Definition Parser.h:81
Selector GetNullarySelector(StringRef name, ASTContext &Ctx)
Utility function for constructing a nullary selector.
@ Class
The "class" keyword.
Definition TypeBase.h:5899
BuiltinTemplateKind
Kinds of BuiltinTemplateDecl.
Definition Builtins.h:462
@ Keyword
The name has been typo-corrected to a keyword.
Definition Sema.h:560
LangAS
Defines the address space values used by the address space qualifier of QualType.
TranslationUnitKind
Describes the kind of translation unit being processed.
@ TU_Incremental
The translation unit is a is a complete translation unit that we might incrementally extend later.
FloatModeKind
Definition TargetInfo.h:75
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
U cast(CodeGen::Address addr)
Definition Address.h:327
AlignRequirementKind
Definition ASTContext.h:144
@ None
The alignment was not explicit in code.
Definition ASTContext.h:146
@ RequiredByEnum
The alignment comes from an alignment attribute on a enum type.
Definition ASTContext.h:155
@ RequiredByTypedef
The alignment comes from an alignment attribute on a typedef.
Definition ASTContext.h:149
@ RequiredByRecord
The alignment comes from an alignment attribute on a record type.
Definition ASTContext.h:152
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition TypeBase.h:5863
@ None
No keyword precedes the qualified type name.
Definition TypeBase.h:5884
@ Other
Other implicit parameter.
Definition Decl.h:1745
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
BuiltinVectorTypeInfo(QualType ElementType, llvm::ElementCount EC, unsigned NumVectors)
CUDAConstantEvalContextRAII(ASTContext &Ctx_, bool NoWrongSidedVars)
Definition ASTContext.h:755
BuiltinVectorTypeInfo(QualType ElementType, llvm::ElementCount EC, unsigned NumVectors)
CUDAConstantEvalContextRAII(ASTContext &Ctx_, bool NoWrongSidedVars)
Definition ASTContext.h:755
bool NoWrongSidedVars
Do not allow wrong-sided variables in constant expressions.
Definition ASTContext.h:750
SourceLocation PragmaSectionLocation
SectionInfo(NamedDecl *Decl, SourceLocation PragmaSectionLocation, int SectionFlags)
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:5321
Extra information about a function prototype.
Definition TypeBase.h:5349
A cache of the value of this pointer, in the most recent generation in which we queried it.
static ValueType makeValue(const ASTContext &Ctx, T Value)
Create the representation of a LazyGenerationalUpdatePtr.
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.
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
TypeInfo(uint64_t Width, unsigned Align, AlignRequirementKind AlignRequirement)
Definition ASTContext.h:164