Thanks to visit codestin.com
Credit goes to clang.llvm.org

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"
29#include "clang/Basic/LLVM.h"
32#include "llvm/ADT/DenseMap.h"
33#include "llvm/ADT/DenseMapInfo.h"
34#include "llvm/ADT/DenseSet.h"
35#include "llvm/ADT/FoldingSet.h"
36#include "llvm/ADT/IntrusiveRefCntPtr.h"
37#include "llvm/ADT/MapVector.h"
38#include "llvm/ADT/PointerIntPair.h"
39#include "llvm/ADT/PointerUnion.h"
40#include "llvm/ADT/SetVector.h"
41#include "llvm/ADT/SmallVector.h"
42#include "llvm/ADT/StringMap.h"
43#include "llvm/ADT/StringRef.h"
44#include "llvm/ADT/StringSet.h"
45#include "llvm/ADT/TinyPtrVector.h"
46#include "llvm/Support/TypeSize.h"
47#include <optional>
48
49namespace llvm {
50
51class APFixedPoint;
53struct fltSemantics;
54template <typename T, unsigned N> class SmallPtrSet;
55
58 unsigned NumElts;
59 unsigned NumFields;
60
61 bool operator==(const ScalableVecTyKey &RHS) const {
62 return EltTy == RHS.EltTy && NumElts == RHS.NumElts &&
63 NumFields == RHS.NumFields;
64 }
65};
66
67// Provide a DenseMapInfo specialization so that ScalableVecTyKey can be used
68// as a key in DenseMap.
69template <> struct DenseMapInfo<ScalableVecTyKey> {
70 static inline ScalableVecTyKey getEmptyKey() {
71 return {DenseMapInfo<clang::QualType>::getEmptyKey(), ~0U, ~0U};
72 }
74 return {DenseMapInfo<clang::QualType>::getTombstoneKey(), ~0U, ~0U};
75 }
76 static unsigned getHashValue(const ScalableVecTyKey &Val) {
77 return hash_combine(DenseMapInfo<clang::QualType>::getHashValue(Val.EltTy),
78 Val.NumElts, Val.NumFields);
79 }
80 static bool isEqual(const ScalableVecTyKey &LHS,
81 const ScalableVecTyKey &RHS) {
82 return LHS == RHS;
83 }
84};
85
86} // namespace llvm
87
88namespace clang {
89
90class APValue;
92class ASTRecordLayout;
93class AtomicExpr;
94class BlockExpr;
95struct BlockVarCopyInit;
97class CharUnits;
98class ConceptDecl;
99class CXXABI;
101class CXXMethodDecl;
102class CXXRecordDecl;
104class DynTypedNodeList;
105class Expr;
106enum class FloatModeKind;
107class GlobalDecl;
108class IdentifierTable;
109class LangOptions;
110class MangleContext;
113class Module;
114struct MSGuidDeclParts;
116class NoSanitizeList;
117class ObjCCategoryDecl;
120class ObjCImplDecl;
123class ObjCIvarDecl;
124class ObjCMethodDecl;
125class ObjCPropertyDecl;
127class ObjCProtocolDecl;
129class OMPTraitInfo;
130class ParentMapContext;
131struct ParsedTargetAttr;
132class Preprocessor;
133class ProfileList;
134class StoredDeclsMap;
135class TargetAttr;
136class TargetInfo;
137class TemplateDecl;
141class TypeConstraint;
143class UsingShadowDecl;
144class VarTemplateDecl;
147
148/// A simple array of base specifiers.
150
151namespace Builtin {
152
153class Context;
154
155} // namespace Builtin
156
158enum OpenCLTypeKind : uint8_t;
159
160namespace comments {
161
162class FullComment;
163
164} // namespace comments
165
166namespace interp {
167
168class Context;
169
170} // namespace interp
171
172namespace serialization {
173template <class> class AbstractTypeReader;
174} // namespace serialization
175
177 /// The alignment was not explicit in code.
179
180 /// The alignment comes from an alignment attribute on a typedef.
182
183 /// The alignment comes from an alignment attribute on a record type.
185
186 /// The alignment comes from an alignment attribute on a enum type.
188};
189
203
217
218/// Holds long-lived AST nodes (such as types and decls) that can be
219/// referred to throughout the semantic analysis of a file.
220class ASTContext : public RefCountedBase<ASTContext> {
222
223 mutable SmallVector<Type *, 0> Types;
224 mutable llvm::FoldingSet<ExtQuals> ExtQualNodes;
225 mutable llvm::FoldingSet<ComplexType> ComplexTypes;
226 mutable llvm::FoldingSet<PointerType> PointerTypes{GeneralTypesLog2InitSize};
227 mutable llvm::FoldingSet<AdjustedType> AdjustedTypes;
228 mutable llvm::FoldingSet<BlockPointerType> BlockPointerTypes;
229 mutable llvm::FoldingSet<LValueReferenceType> LValueReferenceTypes;
230 mutable llvm::FoldingSet<RValueReferenceType> RValueReferenceTypes;
231 mutable llvm::FoldingSet<MemberPointerType> MemberPointerTypes;
232 mutable llvm::ContextualFoldingSet<ConstantArrayType, ASTContext &>
233 ConstantArrayTypes;
234 mutable llvm::FoldingSet<IncompleteArrayType> IncompleteArrayTypes;
235 mutable std::vector<VariableArrayType*> VariableArrayTypes;
236 mutable llvm::ContextualFoldingSet<DependentSizedArrayType, ASTContext &>
237 DependentSizedArrayTypes;
238 mutable llvm::ContextualFoldingSet<DependentSizedExtVectorType, ASTContext &>
239 DependentSizedExtVectorTypes;
240 mutable llvm::ContextualFoldingSet<DependentAddressSpaceType, ASTContext &>
241 DependentAddressSpaceTypes;
242 mutable llvm::FoldingSet<VectorType> VectorTypes;
243 mutable llvm::ContextualFoldingSet<DependentVectorType, ASTContext &>
244 DependentVectorTypes;
245 mutable llvm::FoldingSet<ConstantMatrixType> MatrixTypes;
246 mutable llvm::ContextualFoldingSet<DependentSizedMatrixType, ASTContext &>
247 DependentSizedMatrixTypes;
248 mutable llvm::FoldingSet<FunctionNoProtoType> FunctionNoProtoTypes;
249 mutable llvm::ContextualFoldingSet<FunctionProtoType, ASTContext&>
250 FunctionProtoTypes;
251 mutable llvm::ContextualFoldingSet<DependentTypeOfExprType, ASTContext &>
252 DependentTypeOfExprTypes;
253 mutable llvm::ContextualFoldingSet<DependentDecltypeType, ASTContext &>
254 DependentDecltypeTypes;
255
256 mutable llvm::ContextualFoldingSet<PackIndexingType, ASTContext &>
257 DependentPackIndexingTypes;
258
259 mutable llvm::FoldingSet<TemplateTypeParmType> TemplateTypeParmTypes;
260 mutable llvm::FoldingSet<ObjCTypeParamType> ObjCTypeParamTypes;
261 mutable llvm::FoldingSet<SubstTemplateTypeParmType>
262 SubstTemplateTypeParmTypes;
263 mutable llvm::FoldingSet<SubstTemplateTypeParmPackType>
264 SubstTemplateTypeParmPackTypes;
265 mutable llvm::FoldingSet<SubstBuiltinTemplatePackType>
266 SubstBuiltinTemplatePackTypes;
267 mutable llvm::ContextualFoldingSet<TemplateSpecializationType, ASTContext&>
268 TemplateSpecializationTypes;
269 mutable llvm::FoldingSet<ParenType> ParenTypes{GeneralTypesLog2InitSize};
270 mutable llvm::FoldingSet<TagTypeFoldingSetPlaceholder> TagTypes;
271 mutable llvm::FoldingSet<FoldingSetPlaceholder<UnresolvedUsingType>>
272 UnresolvedUsingTypes;
273 mutable llvm::FoldingSet<UsingType> UsingTypes;
274 mutable llvm::FoldingSet<FoldingSetPlaceholder<TypedefType>> TypedefTypes;
275 mutable llvm::FoldingSet<DependentNameType> DependentNameTypes;
276 mutable llvm::FoldingSet<PackExpansionType> PackExpansionTypes;
277 mutable llvm::FoldingSet<ObjCObjectTypeImpl> ObjCObjectTypes;
278 mutable llvm::FoldingSet<ObjCObjectPointerType> ObjCObjectPointerTypes;
279 mutable llvm::FoldingSet<UnaryTransformType> UnaryTransformTypes;
280 // An AutoType can have a dependency on another AutoType via its template
281 // arguments. Since both dependent and dependency are on the same set,
282 // we can end up in an infinite recursion when looking for a node if we used
283 // a `FoldingSet`, since both could end up in the same bucket.
284 mutable llvm::DenseMap<llvm::FoldingSetNodeID, AutoType *> AutoTypes;
285 mutable llvm::FoldingSet<DeducedTemplateSpecializationType>
286 DeducedTemplateSpecializationTypes;
287 mutable llvm::FoldingSet<AtomicType> AtomicTypes;
288 mutable llvm::FoldingSet<AttributedType> AttributedTypes;
289 mutable llvm::FoldingSet<PipeType> PipeTypes;
290 mutable llvm::FoldingSet<BitIntType> BitIntTypes;
291 mutable llvm::ContextualFoldingSet<DependentBitIntType, ASTContext &>
292 DependentBitIntTypes;
293 mutable llvm::FoldingSet<BTFTagAttributedType> BTFTagAttributedTypes;
294 llvm::FoldingSet<HLSLAttributedResourceType> HLSLAttributedResourceTypes;
295 llvm::FoldingSet<HLSLInlineSpirvType> HLSLInlineSpirvTypes;
296
297 mutable llvm::FoldingSet<CountAttributedType> CountAttributedTypes;
298
299 mutable llvm::FoldingSet<QualifiedTemplateName> QualifiedTemplateNames;
300 mutable llvm::FoldingSet<DependentTemplateName> DependentTemplateNames;
301 mutable llvm::FoldingSet<SubstTemplateTemplateParmStorage>
302 SubstTemplateTemplateParms;
303 mutable llvm::ContextualFoldingSet<SubstTemplateTemplateParmPackStorage,
304 ASTContext&>
305 SubstTemplateTemplateParmPacks;
306 mutable llvm::ContextualFoldingSet<DeducedTemplateStorage, ASTContext &>
307 DeducedTemplates;
308
309 mutable llvm::ContextualFoldingSet<ArrayParameterType, ASTContext &>
310 ArrayParameterTypes;
311
312 /// Store the unique Type corresponding to each Kind.
313 mutable std::array<Type *,
314 llvm::to_underlying(PredefinedSugarType::Kind::Last) + 1>
315 PredefinedSugarTypes{};
316
317 /// Internal storage for NestedNameSpecifiers.
318 ///
319 /// This set is managed by the NestedNameSpecifier class.
320 mutable llvm::FoldingSet<NamespaceAndPrefixStorage>
321 NamespaceAndPrefixStorages;
322
323 /// A cache mapping from RecordDecls to ASTRecordLayouts.
324 ///
325 /// This is lazily created. This is intentionally not serialized.
326 mutable llvm::DenseMap<const RecordDecl*, const ASTRecordLayout*>
327 ASTRecordLayouts;
328 mutable llvm::DenseMap<const ObjCInterfaceDecl *, const ASTRecordLayout *>
329 ObjCLayouts;
330
331 /// A cache from types to size and alignment information.
332 using TypeInfoMap = llvm::DenseMap<const Type *, struct TypeInfo>;
333 mutable TypeInfoMap MemoizedTypeInfo;
334
335 /// A cache from types to unadjusted alignment information. Only ARM and
336 /// AArch64 targets need this information, keeping it separate prevents
337 /// imposing overhead on TypeInfo size.
338 using UnadjustedAlignMap = llvm::DenseMap<const Type *, unsigned>;
339 mutable UnadjustedAlignMap MemoizedUnadjustedAlign;
340
341 /// A cache mapping from CXXRecordDecls to key functions.
342 llvm::DenseMap<const CXXRecordDecl*, LazyDeclPtr> KeyFunctions;
343
344 /// Mapping from ObjCContainers to their ObjCImplementations.
345 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*> ObjCImpls;
346
347 /// Mapping from ObjCMethod to its duplicate declaration in the same
348 /// interface.
349 llvm::DenseMap<const ObjCMethodDecl*,const ObjCMethodDecl*> ObjCMethodRedecls;
350
351 /// Mapping from __block VarDecls to BlockVarCopyInit.
352 llvm::DenseMap<const VarDecl *, BlockVarCopyInit> BlockVarCopyInits;
353
354 /// Mapping from GUIDs to the corresponding MSGuidDecl.
355 mutable llvm::FoldingSet<MSGuidDecl> MSGuidDecls;
356
357 /// Mapping from APValues to the corresponding UnnamedGlobalConstantDecl.
358 mutable llvm::FoldingSet<UnnamedGlobalConstantDecl>
359 UnnamedGlobalConstantDecls;
360
361 /// Mapping from APValues to the corresponding TemplateParamObjects.
362 mutable llvm::FoldingSet<TemplateParamObjectDecl> TemplateParamObjectDecls;
363
364 /// A cache mapping a string value to a StringLiteral object with the same
365 /// value.
366 ///
367 /// This is lazily created. This is intentionally not serialized.
368 mutable llvm::StringMap<StringLiteral *> StringLiteralCache;
369
370 mutable llvm::DenseSet<const FunctionDecl *> DestroyingOperatorDeletes;
371 mutable llvm::DenseSet<const FunctionDecl *> TypeAwareOperatorNewAndDeletes;
372
373 /// The next string literal "version" to allocate during constant evaluation.
374 /// This is used to distinguish between repeated evaluations of the same
375 /// string literal.
376 ///
377 /// We don't need to serialize this because constants get re-evaluated in the
378 /// current file before they are compared locally.
379 unsigned NextStringLiteralVersion = 0;
380
381 /// MD5 hash of CUID. It is calculated when first used and cached by this
382 /// data member.
383 mutable std::string CUIDHash;
384
385 /// Representation of a "canonical" template template parameter that
386 /// is used in canonical template names.
387 class CanonicalTemplateTemplateParm : public llvm::FoldingSetNode {
388 TemplateTemplateParmDecl *Parm;
389
390 public:
391 CanonicalTemplateTemplateParm(TemplateTemplateParmDecl *Parm)
392 : Parm(Parm) {}
393
394 TemplateTemplateParmDecl *getParam() const { return Parm; }
395
396 void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &C) {
397 Profile(ID, C, Parm);
398 }
399
400 static void Profile(llvm::FoldingSetNodeID &ID,
401 const ASTContext &C,
402 TemplateTemplateParmDecl *Parm);
403 };
404 mutable llvm::ContextualFoldingSet<CanonicalTemplateTemplateParm,
405 const ASTContext&>
406 CanonTemplateTemplateParms;
407
408 /// The typedef for the __int128_t type.
409 mutable TypedefDecl *Int128Decl = nullptr;
410
411 /// The typedef for the __uint128_t type.
412 mutable TypedefDecl *UInt128Decl = nullptr;
413
414 /// The typedef for the target specific predefined
415 /// __builtin_va_list type.
416 mutable TypedefDecl *BuiltinVaListDecl = nullptr;
417
418 /// The typedef for the predefined \c __builtin_ms_va_list type.
419 mutable TypedefDecl *BuiltinMSVaListDecl = nullptr;
420
421 /// The typedef for the predefined \c id type.
422 mutable TypedefDecl *ObjCIdDecl = nullptr;
423
424 /// The typedef for the predefined \c SEL type.
425 mutable TypedefDecl *ObjCSelDecl = nullptr;
426
427 /// The typedef for the predefined \c Class type.
428 mutable TypedefDecl *ObjCClassDecl = nullptr;
429
430 /// The typedef for the predefined \c Protocol class in Objective-C.
431 mutable ObjCInterfaceDecl *ObjCProtocolClassDecl = nullptr;
432
433 /// The typedef for the predefined 'BOOL' type.
434 mutable TypedefDecl *BOOLDecl = nullptr;
435
436 // Typedefs which may be provided defining the structure of Objective-C
437 // pseudo-builtins
438 QualType ObjCIdRedefinitionType;
439 QualType ObjCClassRedefinitionType;
440 QualType ObjCSelRedefinitionType;
441
442 /// The identifier 'bool'.
443 mutable IdentifierInfo *BoolName = nullptr;
444
445 /// The identifier 'NSObject'.
446 mutable IdentifierInfo *NSObjectName = nullptr;
447
448 /// The identifier 'NSCopying'.
449 IdentifierInfo *NSCopyingName = nullptr;
450
451#define BuiltinTemplate(BTName) mutable IdentifierInfo *Name##BTName = nullptr;
452#include "clang/Basic/BuiltinTemplates.inc"
453
454 QualType ObjCConstantStringType;
455 mutable RecordDecl *CFConstantStringTagDecl = nullptr;
456 mutable TypedefDecl *CFConstantStringTypeDecl = nullptr;
457
458 mutable QualType ObjCSuperType;
459
460 QualType ObjCNSStringType;
461
462 /// The typedef declaration for the Objective-C "instancetype" type.
463 TypedefDecl *ObjCInstanceTypeDecl = nullptr;
464
465 /// The type for the C FILE type.
466 TypeDecl *FILEDecl = nullptr;
467
468 /// The type for the C jmp_buf type.
469 TypeDecl *jmp_bufDecl = nullptr;
470
471 /// The type for the C sigjmp_buf type.
472 TypeDecl *sigjmp_bufDecl = nullptr;
473
474 /// The type for the C ucontext_t type.
475 TypeDecl *ucontext_tDecl = nullptr;
476
477 /// Type for the Block descriptor for Blocks CodeGen.
478 ///
479 /// Since this is only used for generation of debug info, it is not
480 /// serialized.
481 mutable RecordDecl *BlockDescriptorType = nullptr;
482
483 /// Type for the Block descriptor for Blocks CodeGen.
484 ///
485 /// Since this is only used for generation of debug info, it is not
486 /// serialized.
487 mutable RecordDecl *BlockDescriptorExtendedType = nullptr;
488
489 /// Declaration for the CUDA cudaConfigureCall function.
490 FunctionDecl *cudaConfigureCallDecl = nullptr;
491
492 /// Keeps track of all declaration attributes.
493 ///
494 /// Since so few decls have attrs, we keep them in a hash map instead of
495 /// wasting space in the Decl class.
496 llvm::DenseMap<const Decl*, AttrVec*> DeclAttrs;
497
498 /// A mapping from non-redeclarable declarations in modules that were
499 /// merged with other declarations to the canonical declaration that they were
500 /// merged into.
501 llvm::DenseMap<Decl*, Decl*> MergedDecls;
502
503 /// A mapping from a defining declaration to a list of modules (other
504 /// than the owning module of the declaration) that contain merged
505 /// definitions of that entity.
506 llvm::DenseMap<NamedDecl*, llvm::TinyPtrVector<Module*>> MergedDefModules;
507
508 /// Initializers for a module, in order. Each Decl will be either
509 /// something that has a semantic effect on startup (such as a variable with
510 /// a non-constant initializer), or an ImportDecl (which recursively triggers
511 /// initialization of another module).
512 struct PerModuleInitializers {
513 llvm::SmallVector<Decl*, 4> Initializers;
514 llvm::SmallVector<GlobalDeclID, 4> LazyInitializers;
515
516 void resolve(ASTContext &Ctx);
517 };
518 llvm::DenseMap<Module*, PerModuleInitializers*> ModuleInitializers;
519
520 /// This is the top-level (C++20) Named module we are building.
521 Module *CurrentCXXNamedModule = nullptr;
522
523 /// Help structures to decide whether two `const Module *` belongs
524 /// to the same conceptual module to avoid the expensive to string comparison
525 /// if possible.
526 ///
527 /// Not serialized intentionally.
528 mutable llvm::StringMap<const Module *> PrimaryModuleNameMap;
529 mutable llvm::DenseMap<const Module *, const Module *> SameModuleLookupSet;
530
531 static constexpr unsigned ConstantArrayTypesLog2InitSize = 8;
532 static constexpr unsigned GeneralTypesLog2InitSize = 9;
533 static constexpr unsigned FunctionProtoTypesLog2InitSize = 12;
534
535 /// A mapping from an ObjC class to its subclasses.
536 llvm::DenseMap<const ObjCInterfaceDecl *,
537 SmallVector<const ObjCInterfaceDecl *, 4>>
538 ObjCSubClasses;
539
540 // A mapping from Scalable Vector Type keys to their corresponding QualType.
541 mutable llvm::DenseMap<llvm::ScalableVecTyKey, QualType> ScalableVecTyMap;
542
543 ASTContext &this_() { return *this; }
544
545public:
546 /// A type synonym for the TemplateOrInstantiation mapping.
548 llvm::PointerUnion<VarTemplateDecl *, MemberSpecializationInfo *>;
549
550private:
551 friend class ASTDeclReader;
552 friend class ASTReader;
553 friend class ASTWriter;
554 template <class> friend class serialization::AbstractTypeReader;
555 friend class CXXRecordDecl;
556 friend class IncrementalParser;
557
558 /// A mapping to contain the template or declaration that
559 /// a variable declaration describes or was instantiated from,
560 /// respectively.
561 ///
562 /// For non-templates, this value will be NULL. For variable
563 /// declarations that describe a variable template, this will be a
564 /// pointer to a VarTemplateDecl. For static data members
565 /// of class template specializations, this will be the
566 /// MemberSpecializationInfo referring to the member variable that was
567 /// instantiated or specialized. Thus, the mapping will keep track of
568 /// the static data member templates from which static data members of
569 /// class template specializations were instantiated.
570 ///
571 /// Given the following example:
572 ///
573 /// \code
574 /// template<typename T>
575 /// struct X {
576 /// static T value;
577 /// };
578 ///
579 /// template<typename T>
580 /// T X<T>::value = T(17);
581 ///
582 /// int *x = &X<int>::value;
583 /// \endcode
584 ///
585 /// This mapping will contain an entry that maps from the VarDecl for
586 /// X<int>::value to the corresponding VarDecl for X<T>::value (within the
587 /// class template X) and will be marked TSK_ImplicitInstantiation.
588 llvm::DenseMap<const VarDecl *, TemplateOrSpecializationInfo>
589 TemplateOrInstantiation;
590
591 /// Keeps track of the declaration from which a using declaration was
592 /// created during instantiation.
593 ///
594 /// The source and target declarations are always a UsingDecl, an
595 /// UnresolvedUsingValueDecl, or an UnresolvedUsingTypenameDecl.
596 ///
597 /// For example:
598 /// \code
599 /// template<typename T>
600 /// struct A {
601 /// void f();
602 /// };
603 ///
604 /// template<typename T>
605 /// struct B : A<T> {
606 /// using A<T>::f;
607 /// };
608 ///
609 /// template struct B<int>;
610 /// \endcode
611 ///
612 /// This mapping will contain an entry that maps from the UsingDecl in
613 /// B<int> to the UnresolvedUsingDecl in B<T>.
614 llvm::DenseMap<NamedDecl *, NamedDecl *> InstantiatedFromUsingDecl;
615
616 /// Like InstantiatedFromUsingDecl, but for using-enum-declarations. Maps
617 /// from the instantiated using-enum to the templated decl from whence it
618 /// came.
619 /// Note that using-enum-declarations cannot be dependent and
620 /// thus will never be instantiated from an "unresolved"
621 /// version thereof (as with using-declarations), so each mapping is from
622 /// a (resolved) UsingEnumDecl to a (resolved) UsingEnumDecl.
623 llvm::DenseMap<UsingEnumDecl *, UsingEnumDecl *>
624 InstantiatedFromUsingEnumDecl;
625
626 /// Similarly maps instantiated UsingShadowDecls to their origin.
627 llvm::DenseMap<UsingShadowDecl*, UsingShadowDecl*>
628 InstantiatedFromUsingShadowDecl;
629
630 llvm::DenseMap<FieldDecl *, FieldDecl *> InstantiatedFromUnnamedFieldDecl;
631
632 /// Mapping that stores the methods overridden by a given C++
633 /// member function.
634 ///
635 /// Since most C++ member functions aren't virtual and therefore
636 /// don't override anything, we store the overridden functions in
637 /// this map on the side rather than within the CXXMethodDecl structure.
638 using CXXMethodVector = llvm::TinyPtrVector<const CXXMethodDecl *>;
639 llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector> OverriddenMethods;
640
641 /// Mapping from each declaration context to its corresponding
642 /// mangling numbering context (used for constructs like lambdas which
643 /// need to be consistently numbered for the mangler).
644 llvm::DenseMap<const DeclContext *, std::unique_ptr<MangleNumberingContext>>
645 MangleNumberingContexts;
646 llvm::DenseMap<const Decl *, std::unique_ptr<MangleNumberingContext>>
647 ExtraMangleNumberingContexts;
648
649 /// Side-table of mangling numbers for declarations which rarely
650 /// need them (like static local vars).
651 llvm::MapVector<const NamedDecl *, unsigned> MangleNumbers;
652 llvm::MapVector<const VarDecl *, unsigned> StaticLocalNumbers;
653 /// Mapping the associated device lambda mangling number if present.
654 mutable llvm::DenseMap<const CXXRecordDecl *, unsigned>
655 DeviceLambdaManglingNumbers;
656
657 /// Mapping that stores parameterIndex values for ParmVarDecls when
658 /// that value exceeds the bitfield size of ParmVarDeclBits.ParameterIndex.
659 using ParameterIndexTable = llvm::DenseMap<const VarDecl *, unsigned>;
660 ParameterIndexTable ParamIndices;
661
662public:
667 std::optional<CXXRecordDeclRelocationInfo>
671
672 /// Examines a given type, and returns whether the type itself
673 /// is address discriminated, or any transitively embedded types
674 /// contain data that is address discriminated. This includes
675 /// implicitly authenticated values like vtable pointers, as well as
676 /// explicitly qualified fields.
678 if (!isPointerAuthenticationAvailable())
679 return false;
680 return findPointerAuthContent(T) != PointerAuthContent::None;
681 }
682
683 /// Examines a given type, and returns whether the type itself
684 /// or any data it transitively contains has a pointer authentication
685 /// schema that is not safely relocatable. e.g. any data or fields
686 /// with address discrimination other than any otherwise similar
687 /// vtable pointers.
689 if (!isPointerAuthenticationAvailable())
690 return false;
691 return findPointerAuthContent(T) != PointerAuthContent::None;
692 }
693
694private:
695 llvm::DenseMap<const CXXRecordDecl *, CXXRecordDeclRelocationInfo>
696 RelocatableClasses;
697
698 // FIXME: store in RecordDeclBitfields in future?
699 enum class PointerAuthContent : uint8_t {
700 None,
701 AddressDiscriminatedVTable,
702 AddressDiscriminatedData
703 };
704
705 // A simple helper function to short circuit pointer auth checks.
706 bool isPointerAuthenticationAvailable() const {
707 return LangOpts.PointerAuthCalls || LangOpts.PointerAuthIntrinsics;
708 }
709 PointerAuthContent findPointerAuthContent(QualType T) const;
710 mutable llvm::DenseMap<const RecordDecl *, PointerAuthContent>
711 RecordContainsAddressDiscriminatedPointerAuth;
712
713 ImportDecl *FirstLocalImport = nullptr;
714 ImportDecl *LastLocalImport = nullptr;
715
716 TranslationUnitDecl *TUDecl = nullptr;
717 mutable ExternCContextDecl *ExternCContext = nullptr;
718
719#define BuiltinTemplate(BTName) \
720 mutable BuiltinTemplateDecl *Decl##BTName = nullptr;
721#include "clang/Basic/BuiltinTemplates.inc"
722
723 /// The associated SourceManager object.
724 SourceManager &SourceMgr;
725
726 /// The language options used to create the AST associated with
727 /// this ASTContext object.
728 LangOptions &LangOpts;
729
730 /// NoSanitizeList object that is used by sanitizers to decide which
731 /// entities should not be instrumented.
732 std::unique_ptr<NoSanitizeList> NoSanitizeL;
733
734 /// Function filtering mechanism to determine whether a given function
735 /// should be imbued with the XRay "always" or "never" attributes.
736 std::unique_ptr<XRayFunctionFilter> XRayFilter;
737
738 /// ProfileList object that is used by the profile instrumentation
739 /// to decide which entities should be instrumented.
740 std::unique_ptr<ProfileList> ProfList;
741
742 /// The allocator used to create AST objects.
743 ///
744 /// AST objects are never destructed; rather, all memory associated with the
745 /// AST objects will be released when the ASTContext itself is destroyed.
746 mutable llvm::BumpPtrAllocator BumpAlloc;
747
748 /// Allocator for partial diagnostics.
750
751 /// The current C++ ABI.
752 std::unique_ptr<CXXABI> ABI;
753 CXXABI *createCXXABI(const TargetInfo &T);
754
755 /// Address space map mangling must be used with language specific
756 /// address spaces (e.g. OpenCL/CUDA)
757 bool AddrSpaceMapMangling;
758
759 /// For performance, track whether any function effects are in use.
760 mutable bool AnyFunctionEffects = false;
761
762 const TargetInfo *Target = nullptr;
763 const TargetInfo *AuxTarget = nullptr;
764 clang::PrintingPolicy PrintingPolicy;
765 std::unique_ptr<interp::Context> InterpContext;
766 std::unique_ptr<ParentMapContext> ParentMapCtx;
767
768 /// Keeps track of the deallocated DeclListNodes for future reuse.
769 DeclListNode *ListNodeFreeList = nullptr;
770
771public:
779
780 /// Returns the clang bytecode interpreter context.
782
784 /// Do not allow wrong-sided variables in constant expressions.
785 bool NoWrongSidedVars = false;
796
797 /// Returns the dynamic AST node parent map context.
799
800 // A traversal scope limits the parts of the AST visible to certain analyses.
801 // RecursiveASTVisitor only visits specified children of TranslationUnitDecl.
802 // getParents() will only observe reachable parent edges.
803 //
804 // The scope is defined by a set of "top-level" declarations which will be
805 // visible under the TranslationUnitDecl.
806 // Initially, it is the entire TU, represented by {getTranslationUnitDecl()}.
807 //
808 // After setTraversalScope({foo, bar}), the exposed AST looks like:
809 // TranslationUnitDecl
810 // - foo
811 // - ...
812 // - bar
813 // - ...
814 // All other siblings of foo and bar are pruned from the tree.
815 // (However they are still accessible via TranslationUnitDecl->decls())
816 //
817 // Changing the scope clears the parent cache, which is expensive to rebuild.
818 ArrayRef<Decl *> getTraversalScope() const { return TraversalScope; }
819 void setTraversalScope(const std::vector<Decl *> &);
820
821 /// Forwards to get node parents from the ParentMapContext. New callers should
822 /// use ParentMapContext::getParents() directly.
823 template <typename NodeT> DynTypedNodeList getParents(const NodeT &Node);
824
826 return PrintingPolicy;
827 }
828
830 PrintingPolicy = Policy;
831 }
832
833 SourceManager& getSourceManager() { return SourceMgr; }
834 const SourceManager& getSourceManager() const { return SourceMgr; }
835
836 // Cleans up some of the data structures. This allows us to do cleanup
837 // normally done in the destructor earlier. Renders much of the ASTContext
838 // unusable, mostly the actual AST nodes, so should be called when we no
839 // longer need access to the AST.
840 void cleanup();
841
842 llvm::BumpPtrAllocator &getAllocator() const {
843 return BumpAlloc;
844 }
845
846 void *Allocate(size_t Size, unsigned Align = 8) const {
847 return BumpAlloc.Allocate(Size, Align);
848 }
849 template <typename T> T *Allocate(size_t Num = 1) const {
850 return static_cast<T *>(Allocate(Num * sizeof(T), alignof(T)));
851 }
852 void Deallocate(void *Ptr) const {}
853
854 llvm::StringRef backupStr(llvm::StringRef S) const {
855 char *Buf = new (*this) char[S.size()];
856 llvm::copy(S, Buf);
857 return llvm::StringRef(Buf, S.size());
858 }
859
860 /// Allocates a \c DeclListNode or returns one from the \c ListNodeFreeList
861 /// pool.
863 if (DeclListNode *Alloc = ListNodeFreeList) {
864 ListNodeFreeList = dyn_cast_if_present<DeclListNode *>(Alloc->Rest);
865 Alloc->D = ND;
866 Alloc->Rest = nullptr;
867 return Alloc;
868 }
869 return new (*this) DeclListNode(ND);
870 }
871 /// Deallocates a \c DeclListNode by returning it to the \c ListNodeFreeList
872 /// pool.
874 N->Rest = ListNodeFreeList;
875 ListNodeFreeList = N;
876 }
877
878 /// Return the total amount of physical memory allocated for representing
879 /// AST nodes and type information.
880 size_t getASTAllocatedMemory() const {
881 return BumpAlloc.getTotalMemory();
882 }
883
884 /// Return the total memory used for various side tables.
885 size_t getSideTableAllocatedMemory() const;
886
888 return DiagAllocator;
889 }
890
891 const TargetInfo &getTargetInfo() const { return *Target; }
892 const TargetInfo *getAuxTargetInfo() const { return AuxTarget; }
893
894 const QualType GetHigherPrecisionFPType(QualType ElementType) const {
895 const auto *CurrentBT = cast<BuiltinType>(ElementType);
896 switch (CurrentBT->getKind()) {
897 case BuiltinType::Kind::Half:
898 case BuiltinType::Kind::Float16:
899 return FloatTy;
900 case BuiltinType::Kind::Float:
901 case BuiltinType::Kind::BFloat16:
902 return DoubleTy;
903 case BuiltinType::Kind::Double:
904 return LongDoubleTy;
905 default:
906 return ElementType;
907 }
908 return ElementType;
909 }
910
911 /// getIntTypeForBitwidth -
912 /// sets integer QualTy according to specified details:
913 /// bitwidth, signed/unsigned.
914 /// Returns empty type if there is no appropriate target types.
915 QualType getIntTypeForBitwidth(unsigned DestWidth,
916 unsigned Signed) const;
917
918 /// getRealTypeForBitwidth -
919 /// sets floating point QualTy according to specified bitwidth.
920 /// Returns empty type if there is no appropriate target types.
921 QualType getRealTypeForBitwidth(unsigned DestWidth,
922 FloatModeKind ExplicitType) const;
923
924 bool AtomicUsesUnsupportedLibcall(const AtomicExpr *E) const;
925
926 const LangOptions& getLangOpts() const { return LangOpts; }
927
928 // If this condition is false, typo correction must be performed eagerly
929 // rather than delayed in many places, as it makes use of dependent types.
930 // the condition is false for clang's C-only codepath, as it doesn't support
931 // dependent types yet.
932 bool isDependenceAllowed() const {
933 return LangOpts.CPlusPlus || LangOpts.RecoveryAST;
934 }
935
936 const NoSanitizeList &getNoSanitizeList() const { return *NoSanitizeL; }
937
939 const QualType &Ty) const;
940
942 return *XRayFilter;
943 }
944
945 const ProfileList &getProfileList() const { return *ProfList; }
946
948
950 return FullSourceLoc(Loc,SourceMgr);
951 }
952
953 /// Return the C++ ABI kind that should be used. The C++ ABI can be overriden
954 /// at compile time with `-fc++-abi=`. If this is not provided, we instead use
955 /// the default ABI set by the target.
957
958 /// All comments in this translation unit.
960
961 /// True if comments are already loaded from ExternalASTSource.
962 mutable bool CommentsLoaded = false;
963
964 /// Mapping from declaration to directly attached comment.
965 ///
966 /// Raw comments are owned by Comments list. This mapping is populated
967 /// lazily.
968 mutable llvm::DenseMap<const Decl *, const RawComment *> DeclRawComments;
969
970 /// Mapping from canonical declaration to the first redeclaration in chain
971 /// that has a comment attached.
972 ///
973 /// Raw comments are owned by Comments list. This mapping is populated
974 /// lazily.
975 mutable llvm::DenseMap<const Decl *, const Decl *> RedeclChainComments;
976
977 /// Keeps track of redeclaration chains that don't have any comment attached.
978 /// Mapping from canonical declaration to redeclaration chain that has no
979 /// comments attached to any redeclaration. Specifically it's mapping to
980 /// the last redeclaration we've checked.
981 ///
982 /// Shall not contain declarations that have comments attached to any
983 /// redeclaration in their chain.
984 mutable llvm::DenseMap<const Decl *, const Decl *> CommentlessRedeclChains;
985
986 /// Mapping from declarations to parsed comments attached to any
987 /// redeclaration.
988 mutable llvm::DenseMap<const Decl *, comments::FullComment *> ParsedComments;
989
990 /// Attaches \p Comment to \p OriginalD and to its redeclaration chain
991 /// and removes the redeclaration chain from the set of commentless chains.
992 ///
993 /// Don't do anything if a comment has already been attached to \p OriginalD
994 /// or its redeclaration chain.
995 void cacheRawCommentForDecl(const Decl &OriginalD,
996 const RawComment &Comment) const;
997
998 /// \returns searches \p CommentsInFile for doc comment for \p D.
999 ///
1000 /// \p RepresentativeLocForDecl is used as a location for searching doc
1001 /// comments. \p CommentsInFile is a mapping offset -> comment of files in the
1002 /// same file where \p RepresentativeLocForDecl is.
1004 const Decl *D, const SourceLocation RepresentativeLocForDecl,
1005 const std::map<unsigned, RawComment *> &CommentsInFile) const;
1006
1007 /// Return the documentation comment attached to a given declaration,
1008 /// without looking into cache.
1010
1011public:
1012 void addComment(const RawComment &RC);
1013
1014 /// Return the documentation comment attached to a given declaration.
1015 /// Returns nullptr if no comment is attached.
1016 ///
1017 /// \param OriginalDecl if not nullptr, is set to declaration AST node that
1018 /// had the comment, if the comment we found comes from a redeclaration.
1019 const RawComment *
1021 const Decl **OriginalDecl = nullptr) const;
1022
1023 /// Searches existing comments for doc comments that should be attached to \p
1024 /// Decls. If any doc comment is found, it is parsed.
1025 ///
1026 /// Requirement: All \p Decls are in the same file.
1027 ///
1028 /// If the last comment in the file is already attached we assume
1029 /// there are not comments left to be attached to \p Decls.
1031 const Preprocessor *PP);
1032
1033 /// Return parsed documentation comment attached to a given declaration.
1034 /// Returns nullptr if no comment is attached.
1035 ///
1036 /// \param PP the Preprocessor used with this TU. Could be nullptr if
1037 /// preprocessor is not available.
1039 const Preprocessor *PP) const;
1040
1041 /// Return parsed documentation comment attached to a given declaration.
1042 /// Returns nullptr if no comment is attached. Does not look at any
1043 /// redeclarations of the declaration.
1045
1047 const Decl *D) const;
1048
1049private:
1050 mutable comments::CommandTraits CommentCommandTraits;
1051
1052 /// Iterator that visits import declarations.
1053 class import_iterator {
1054 ImportDecl *Import = nullptr;
1055
1056 public:
1057 using value_type = ImportDecl *;
1058 using reference = ImportDecl *;
1059 using pointer = ImportDecl *;
1060 using difference_type = int;
1061 using iterator_category = std::forward_iterator_tag;
1062
1063 import_iterator() = default;
1064 explicit import_iterator(ImportDecl *Import) : Import(Import) {}
1065
1066 reference operator*() const { return Import; }
1067 pointer operator->() const { return Import; }
1068
1069 import_iterator &operator++() {
1070 Import = ASTContext::getNextLocalImport(Import);
1071 return *this;
1072 }
1073
1074 import_iterator operator++(int) {
1075 import_iterator Other(*this);
1076 ++(*this);
1077 return Other;
1078 }
1079
1080 friend bool operator==(import_iterator X, import_iterator Y) {
1081 return X.Import == Y.Import;
1082 }
1083
1084 friend bool operator!=(import_iterator X, import_iterator Y) {
1085 return X.Import != Y.Import;
1086 }
1087 };
1088
1089public:
1091 return CommentCommandTraits;
1092 }
1093
1094 /// Retrieve the attributes for the given declaration.
1095 AttrVec& getDeclAttrs(const Decl *D);
1096
1097 /// Erase the attributes corresponding to the given declaration.
1098 void eraseDeclAttrs(const Decl *D);
1099
1100 /// If this variable is an instantiated static data member of a
1101 /// class template specialization, returns the templated static data member
1102 /// from which it was instantiated.
1103 // FIXME: Remove ?
1105 const VarDecl *Var);
1106
1107 /// Note that the static data member \p Inst is an instantiation of
1108 /// the static data member template \p Tmpl of a class template.
1111 SourceLocation PointOfInstantiation = SourceLocation());
1112
1115
1118
1119 /// If the given using decl \p Inst is an instantiation of
1120 /// another (possibly unresolved) using decl, return it.
1122
1123 /// Remember that the using decl \p Inst is an instantiation
1124 /// of the using decl \p Pattern of a class template.
1125 void setInstantiatedFromUsingDecl(NamedDecl *Inst, NamedDecl *Pattern);
1126
1127 /// If the given using-enum decl \p Inst is an instantiation of
1128 /// another using-enum decl, return it.
1130
1131 /// Remember that the using enum decl \p Inst is an instantiation
1132 /// of the using enum decl \p Pattern of a class template.
1134 UsingEnumDecl *Pattern);
1135
1138 UsingShadowDecl *Pattern);
1139
1141
1143
1144 // Access to the set of methods overridden by the given C++ method.
1145 using overridden_cxx_method_iterator = CXXMethodVector::const_iterator;
1148
1151
1152 unsigned overridden_methods_size(const CXXMethodDecl *Method) const;
1153
1155 llvm::iterator_range<overridden_cxx_method_iterator>;
1156
1158
1159 /// Note that the given C++ \p Method overrides the given \p
1160 /// Overridden method.
1162 const CXXMethodDecl *Overridden);
1163
1164 /// Return C++ or ObjC overridden methods for the given \p Method.
1165 ///
1166 /// An ObjC method is considered to override any method in the class's
1167 /// base classes, its protocols, or its categories' protocols, that has
1168 /// the same selector and is of the same kind (class or instance).
1169 /// A method in an implementation is not considered as overriding the same
1170 /// method in the interface or its categories.
1172 const NamedDecl *Method,
1173 SmallVectorImpl<const NamedDecl *> &Overridden) const;
1174
1175 /// Notify the AST context that a new import declaration has been
1176 /// parsed or implicitly created within this translation unit.
1177 void addedLocalImportDecl(ImportDecl *Import);
1178
1180 return Import->getNextLocalImport();
1181 }
1182
1183 using import_range = llvm::iterator_range<import_iterator>;
1184
1186 return import_range(import_iterator(FirstLocalImport), import_iterator());
1187 }
1188
1190 Decl *Result = MergedDecls.lookup(D);
1191 return Result ? Result : D;
1192 }
1193 void setPrimaryMergedDecl(Decl *D, Decl *Primary) {
1194 MergedDecls[D] = Primary;
1195 }
1196
1197 /// Note that the definition \p ND has been merged into module \p M,
1198 /// and should be visible whenever \p M is visible.
1200 bool NotifyListeners = true);
1201
1202 /// Clean up the merged definition list. Call this if you might have
1203 /// added duplicates into the list.
1205
1206 /// Get the additional modules in which the definition \p Def has
1207 /// been merged.
1209
1210 /// Add a declaration to the list of declarations that are initialized
1211 /// for a module. This will typically be a global variable (with internal
1212 /// linkage) that runs module initializers, such as the iostream initializer,
1213 /// or an ImportDecl nominating another module that has initializers.
1215
1217
1218 /// Get the initializations to perform when importing a module, if any.
1220
1221 /// Set the (C++20) module we are building.
1223
1224 /// Get module under construction, nullptr if this is not a C++20 module.
1225 Module *getCurrentNamedModule() const { return CurrentCXXNamedModule; }
1226
1227 /// If the two module \p M1 and \p M2 are in the same module.
1228 ///
1229 /// FIXME: The signature may be confusing since `clang::Module` means to
1230 /// a module fragment or a module unit but not a C++20 module.
1231 bool isInSameModule(const Module *M1, const Module *M2) const;
1232
1234 assert(TUDecl->getMostRecentDecl() == TUDecl &&
1235 "The active TU is not current one!");
1236 return TUDecl->getMostRecentDecl();
1237 }
1239 assert(!TUDecl || TUKind == TU_Incremental);
1241 if (TraversalScope.empty() || TraversalScope.back() == TUDecl)
1242 TraversalScope = {NewTUDecl};
1243 if (TUDecl)
1244 NewTUDecl->setPreviousDecl(TUDecl);
1245 TUDecl = NewTUDecl;
1246 }
1247
1249
1250#define BuiltinTemplate(BTName) BuiltinTemplateDecl *get##BTName##Decl() const;
1251#include "clang/Basic/BuiltinTemplates.inc"
1252
1253 // Builtin Types.
1257 CanQualType WCharTy; // [C++ 3.9.1p5].
1258 CanQualType WideCharTy; // Same as WCharTy in C++, integer type in C99.
1259 CanQualType WIntTy; // [C99 7.24.1], integer type unchanged by default promotions.
1260 CanQualType Char8Ty; // [C++20 proposal]
1261 CanQualType Char16Ty; // [C++0x 3.9.1p5], integer type in C99.
1262 CanQualType Char32Ty; // [C++0x 3.9.1p5], integer type in C99.
1268 LongAccumTy; // ISO/IEC JTC1 SC22 WG14 N1169 Extension
1278 CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
1280 CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
1288#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1289 CanQualType SingletonId;
1290#include "clang/Basic/OpenCLImageTypes.def"
1296#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1297 CanQualType Id##Ty;
1298#include "clang/Basic/OpenCLExtensionTypes.def"
1299#define SVE_TYPE(Name, Id, SingletonId) \
1300 CanQualType SingletonId;
1301#include "clang/Basic/AArch64ACLETypes.def"
1302#define PPC_VECTOR_TYPE(Name, Id, Size) \
1303 CanQualType Id##Ty;
1304#include "clang/Basic/PPCTypes.def"
1305#define RVV_TYPE(Name, Id, SingletonId) \
1306 CanQualType SingletonId;
1307#include "clang/Basic/RISCVVTypes.def"
1308#define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
1309#include "clang/Basic/WebAssemblyReferenceTypes.def"
1310#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
1311 CanQualType SingletonId;
1312#include "clang/Basic/AMDGPUTypes.def"
1313#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
1314#include "clang/Basic/HLSLIntangibleTypes.def"
1315
1316 // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand.
1317 mutable QualType AutoDeductTy; // Deduction against 'auto'.
1318 mutable QualType AutoRRefDeductTy; // Deduction against 'auto &&'.
1319
1320 // Decl used to help define __builtin_va_list for some targets.
1321 // The decl is built when constructing 'BuiltinVaListDecl'.
1322 mutable Decl *VaListTagDecl = nullptr;
1323
1324 // Implicitly-declared type 'struct _GUID'.
1325 mutable TagDecl *MSGuidTagDecl = nullptr;
1326
1327 // Implicitly-declared type 'struct type_info'.
1328 mutable TagDecl *MSTypeInfoTagDecl = nullptr;
1329
1330 /// Keep track of CUDA/HIP device-side variables ODR-used by host code.
1331 /// This does not include extern shared variables used by device host
1332 /// functions as addresses of shared variables are per warp, therefore
1333 /// cannot be accessed by host code.
1334 llvm::DenseSet<const VarDecl *> CUDADeviceVarODRUsedByHost;
1335
1336 /// Keep track of CUDA/HIP external kernels or device variables ODR-used by
1337 /// host code. SetVector is used to maintain the order.
1338 llvm::SetVector<const ValueDecl *> CUDAExternalDeviceDeclODRUsedByHost;
1339
1340 /// Keep track of CUDA/HIP implicit host device functions used on device side
1341 /// in device compilation.
1342 llvm::DenseSet<const FunctionDecl *> CUDAImplicitHostDeviceFunUsedByDevice;
1343
1344 /// Map of SYCL kernels indexed by the unique type used to name the kernel.
1345 /// Entries are not serialized but are recreated on deserialization of a
1346 /// sycl_kernel_entry_point attributed function declaration.
1347 llvm::DenseMap<CanQualType, SYCLKernelInfo> SYCLKernels;
1348
1349 /// For capturing lambdas with an explicit object parameter whose type is
1350 /// derived from the lambda type, we need to perform derived-to-base
1351 /// conversion so we can access the captures; the cast paths for that
1352 /// are stored here.
1353 llvm::DenseMap<const CXXMethodDecl *, CXXCastPath> LambdaCastPaths;
1354
1356 SelectorTable &sels, Builtin::Context &builtins,
1358 ASTContext(const ASTContext &) = delete;
1359 ASTContext &operator=(const ASTContext &) = delete;
1360 ~ASTContext();
1361
1362 /// Attach an external AST source to the AST context.
1363 ///
1364 /// The external AST source provides the ability to load parts of
1365 /// the abstract syntax tree as needed from some external storage,
1366 /// e.g., a precompiled header.
1368
1369 /// Retrieve a pointer to the external AST source associated
1370 /// with this AST context, if any.
1372 return ExternalSource.get();
1373 }
1374
1375 /// Retrieve a pointer to the external AST source associated
1376 /// with this AST context, if any. Returns as an IntrusiveRefCntPtr.
1380
1381 /// Attach an AST mutation listener to the AST context.
1382 ///
1383 /// The AST mutation listener provides the ability to track modifications to
1384 /// the abstract syntax tree entities committed after they were initially
1385 /// created.
1387 this->Listener = Listener;
1388 }
1389
1390 /// Retrieve a pointer to the AST mutation listener associated
1391 /// with this AST context, if any.
1393
1394 void PrintStats() const;
1395 const SmallVectorImpl<Type *>& getTypes() const { return Types; }
1396
1398 const IdentifierInfo *II) const;
1399
1400 /// Create a new implicit TU-level CXXRecordDecl or RecordDecl
1401 /// declaration.
1403 StringRef Name,
1404 RecordDecl::TagKind TK = RecordDecl::TagKind::Struct) const;
1405
1406 /// Create a new implicit TU-level typedef declaration.
1407 TypedefDecl *buildImplicitTypedef(QualType T, StringRef Name) const;
1408
1409 /// Retrieve the declaration for the 128-bit signed integer type.
1410 TypedefDecl *getInt128Decl() const;
1411
1412 /// Retrieve the declaration for the 128-bit unsigned integer type.
1413 TypedefDecl *getUInt128Decl() const;
1414
1415 //===--------------------------------------------------------------------===//
1416 // Type Constructors
1417 //===--------------------------------------------------------------------===//
1418
1419private:
1420 /// Return a type with extended qualifiers.
1421 QualType getExtQualType(const Type *Base, Qualifiers Quals) const;
1422
1423 QualType getPipeType(QualType T, bool ReadOnly) const;
1424
1425public:
1426 /// Return the uniqued reference to the type for an address space
1427 /// qualified type with the specified type and address space.
1428 ///
1429 /// The resulting type has a union of the qualifiers from T and the address
1430 /// space. If T already has an address space specifier, it is silently
1431 /// replaced.
1432 QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const;
1433
1434 /// Remove any existing address space on the type and returns the type
1435 /// with qualifiers intact (or that's the idea anyway)
1436 ///
1437 /// The return type should be T with all prior qualifiers minus the address
1438 /// space.
1440
1441 /// Return the "other" discriminator used for the pointer auth schema used for
1442 /// vtable pointers in instances of the requested type.
1443 uint16_t
1445
1446 /// Return the "other" type-specific discriminator for the given type.
1448
1449 /// Apply Objective-C protocol qualifiers to the given type.
1450 /// \param allowOnPointerType specifies if we can apply protocol
1451 /// qualifiers on ObjCObjectPointerType. It can be set to true when
1452 /// constructing the canonical type of a Objective-C type parameter.
1454 ArrayRef<ObjCProtocolDecl *> protocols, bool &hasError,
1455 bool allowOnPointerType = false) const;
1456
1457 /// Return the uniqued reference to the type for an Objective-C
1458 /// gc-qualified type.
1459 ///
1460 /// The resulting type has a union of the qualifiers from T and the gc
1461 /// attribute.
1463
1464 /// Remove the existing address space on the type if it is a pointer size
1465 /// address space and return the type with qualifiers intact.
1467
1468 /// Return the uniqued reference to the type for a \c restrict
1469 /// qualified type.
1470 ///
1471 /// The resulting type has a union of the qualifiers from \p T and
1472 /// \c restrict.
1474 return T.withFastQualifiers(Qualifiers::Restrict);
1475 }
1476
1477 /// Return the uniqued reference to the type for a \c volatile
1478 /// qualified type.
1479 ///
1480 /// The resulting type has a union of the qualifiers from \p T and
1481 /// \c volatile.
1483 return T.withFastQualifiers(Qualifiers::Volatile);
1484 }
1485
1486 /// Return the uniqued reference to the type for a \c const
1487 /// qualified type.
1488 ///
1489 /// The resulting type has a union of the qualifiers from \p T and \c const.
1490 ///
1491 /// It can be reasonably expected that this will always be equivalent to
1492 /// calling T.withConst().
1493 QualType getConstType(QualType T) const { return T.withConst(); }
1494
1495 /// Rebuild a type, preserving any existing type sugar. For function types,
1496 /// you probably want to just use \c adjustFunctionResultType and friends
1497 /// instead.
1499 llvm::function_ref<QualType(QualType)> Adjust) const;
1500
1501 /// Change the ExtInfo on a function type.
1503 FunctionType::ExtInfo EInfo);
1504
1505 /// Change the result type of a function type, preserving sugar such as
1506 /// attributed types.
1508 QualType NewResultType);
1509
1510 /// Adjust the given function result type.
1512
1513 /// Change the result type of a function type once it is deduced.
1515
1516 /// Get a function type and produce the equivalent function type with the
1517 /// specified exception specification. Type sugar that can be present on a
1518 /// declaration of a function with an exception specification is permitted
1519 /// and preserved. Other type sugar (for instance, typedefs) is not.
1521 QualType Orig, const FunctionProtoType::ExceptionSpecInfo &ESI) const;
1522
1523 /// Determine whether two function types are the same, ignoring
1524 /// exception specifications in cases where they're part of the type.
1526
1527 /// Change the exception specification on a function once it is
1528 /// delay-parsed, instantiated, or computed.
1531 bool AsWritten = false);
1532
1533 /// Get a function type and produce the equivalent function type where
1534 /// pointer size address spaces in the return type and parameter types are
1535 /// replaced with the default address space.
1537
1538 /// Determine whether two function types are the same, ignoring pointer sizes
1539 /// in the return type and parameter types.
1541
1542 /// Get or construct a function type that is equivalent to the input type
1543 /// except that the parameter ABI annotations are stripped.
1545
1546 /// Determine if two function types are the same, ignoring parameter ABI
1547 /// annotations.
1549
1550 /// Return the uniqued reference to the type for a complex
1551 /// number with the specified element type.
1556
1557 /// Return the uniqued reference to the type for a pointer to
1558 /// the specified type.
1563
1564 QualType
1565 getCountAttributedType(QualType T, Expr *CountExpr, bool CountInBytes,
1566 bool OrNull,
1567 ArrayRef<TypeCoupledDeclRefInfo> DependentDecls) const;
1568
1569 /// Return the uniqued reference to a type adjusted from the original
1570 /// type to a new type.
1576
1577 /// Return the uniqued reference to the decayed version of the given
1578 /// type. Can only be called on array and function types which decay to
1579 /// pointer types.
1584 /// Return the uniqued reference to a specified decay from the original
1585 /// type to the decayed type.
1586 QualType getDecayedType(QualType Orig, QualType Decayed) const;
1587
1588 /// Return the uniqued reference to a specified array parameter type from the
1589 /// original array type.
1591
1592 /// Return the uniqued reference to the atomic type for the specified
1593 /// type.
1595
1596 /// Return the uniqued reference to the type for a block of the
1597 /// specified type.
1599
1600 /// Gets the struct used to keep track of the descriptor for pointer to
1601 /// blocks.
1603
1604 /// Return a read_only pipe type for the specified type.
1606
1607 /// Return a write_only pipe type for the specified type.
1609
1610 /// Return a bit-precise integer type with the specified signedness and bit
1611 /// count.
1612 QualType getBitIntType(bool Unsigned, unsigned NumBits) const;
1613
1614 /// Return a dependent bit-precise integer type with the specified signedness
1615 /// and bit count.
1616 QualType getDependentBitIntType(bool Unsigned, Expr *BitsExpr) const;
1617
1619
1620 /// Gets the struct used to keep track of the extended descriptor for
1621 /// pointer to blocks.
1623
1624 /// Map an AST Type to an OpenCLTypeKind enum value.
1625 OpenCLTypeKind getOpenCLTypeKind(const Type *T) const;
1626
1627 /// Get address space for OpenCL type.
1628 LangAS getOpenCLTypeAddrSpace(const Type *T) const;
1629
1630 /// Returns default address space based on OpenCL version and enabled features
1632 return LangOpts.OpenCLGenericAddressSpace ? LangAS::opencl_generic
1634 }
1635
1637 cudaConfigureCallDecl = FD;
1638 }
1639
1641 return cudaConfigureCallDecl;
1642 }
1643
1644 /// Returns true iff we need copy/dispose helpers for the given type.
1645 bool BlockRequiresCopying(QualType Ty, const VarDecl *D);
1646
1647 /// Returns true, if given type has a known lifetime. HasByrefExtendedLayout
1648 /// is set to false in this case. If HasByrefExtendedLayout returns true,
1649 /// byref variable has extended lifetime.
1650 bool getByrefLifetime(QualType Ty,
1651 Qualifiers::ObjCLifetime &Lifetime,
1652 bool &HasByrefExtendedLayout) const;
1653
1654 /// Return the uniqued reference to the type for an lvalue reference
1655 /// to the specified type.
1656 QualType getLValueReferenceType(QualType T, bool SpelledAsLValue = true)
1657 const;
1658
1659 /// Return the uniqued reference to the type for an rvalue reference
1660 /// to the specified type.
1662
1663 /// Return the uniqued reference to the type for a member pointer to
1664 /// the specified type in the specified nested name.
1666 const CXXRecordDecl *Cls) const;
1667
1668 /// Return a non-unique reference to the type for a variable array of
1669 /// the specified element type.
1672 unsigned IndexTypeQuals) const;
1673
1674 /// Return a non-unique reference to the type for a dependently-sized
1675 /// array of the specified element type.
1676 ///
1677 /// FIXME: We will need these to be uniqued, or at least comparable, at some
1678 /// point.
1681 unsigned IndexTypeQuals) const;
1682
1683 /// Return a unique reference to the type for an incomplete array of
1684 /// the specified element type.
1686 unsigned IndexTypeQuals) const;
1687
1688 /// Return the unique reference to the type for a constant array of
1689 /// the specified element type.
1690 QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize,
1691 const Expr *SizeExpr, ArraySizeModifier ASM,
1692 unsigned IndexTypeQuals) const;
1693
1694 /// Return a type for a constant array for a string literal of the
1695 /// specified element type and length.
1696 QualType getStringLiteralArrayType(QualType EltTy, unsigned Length) const;
1697
1698 /// Returns a vla type where known sizes are replaced with [*].
1700
1701 // Convenience struct to return information about a builtin vector type.
1710
1711 /// Returns the element type, element count and number of vectors
1712 /// (in case of tuple) for a builtin vector type.
1713 BuiltinVectorTypeInfo
1714 getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const;
1715
1716 /// Return the unique reference to a scalable vector type of the specified
1717 /// element type and scalable number of elements.
1718 /// For RISC-V, number of fields is also provided when it fetching for
1719 /// tuple type.
1720 ///
1721 /// \pre \p EltTy must be a built-in type.
1722 QualType getScalableVectorType(QualType EltTy, unsigned NumElts,
1723 unsigned NumFields = 1) const;
1724
1725 /// Return a WebAssembly externref type.
1727
1728 /// Return the unique reference to a vector type of the specified
1729 /// element type and size.
1730 ///
1731 /// \pre \p VectorType must be a built-in type.
1732 QualType getVectorType(QualType VectorType, unsigned NumElts,
1733 VectorKind VecKind) const;
1734 /// Return the unique reference to the type for a dependently sized vector of
1735 /// the specified element type.
1737 SourceLocation AttrLoc,
1738 VectorKind VecKind) const;
1739
1740 /// Return the unique reference to an extended vector type
1741 /// of the specified element type and size.
1742 ///
1743 /// \pre \p VectorType must be a built-in type.
1744 QualType getExtVectorType(QualType VectorType, unsigned NumElts) const;
1745
1746 /// \pre Return a non-unique reference to the type for a dependently-sized
1747 /// vector of the specified element type.
1748 ///
1749 /// FIXME: We will need these to be uniqued, or at least comparable, at some
1750 /// point.
1752 Expr *SizeExpr,
1753 SourceLocation AttrLoc) const;
1754
1755 /// Return the unique reference to the matrix type of the specified element
1756 /// type and size
1757 ///
1758 /// \pre \p ElementType must be a valid matrix element type (see
1759 /// MatrixType::isValidElementType).
1760 QualType getConstantMatrixType(QualType ElementType, unsigned NumRows,
1761 unsigned NumColumns) const;
1762
1763 /// Return the unique reference to the matrix type of the specified element
1764 /// type and size
1765 QualType getDependentSizedMatrixType(QualType ElementType, Expr *RowExpr,
1766 Expr *ColumnExpr,
1767 SourceLocation AttrLoc) const;
1768
1770 Expr *AddrSpaceExpr,
1771 SourceLocation AttrLoc) const;
1772
1773 /// Return a K&R style C function type like 'int()'.
1775 const FunctionType::ExtInfo &Info) const;
1776
1780
1781 /// Return a normal function type with a typed argument list.
1783 const FunctionProtoType::ExtProtoInfo &EPI) const {
1784 return getFunctionTypeInternal(ResultTy, Args, EPI, false);
1785 }
1786
1788
1789private:
1790 /// Return a normal function type with a typed argument list.
1791 QualType getFunctionTypeInternal(QualType ResultTy, ArrayRef<QualType> Args,
1793 bool OnlyWantCanonical) const;
1794 QualType
1795 getAutoTypeInternal(QualType DeducedType, AutoTypeKeyword Keyword,
1796 bool IsDependent, bool IsPack = false,
1797 TemplateDecl *TypeConstraintConcept = nullptr,
1798 ArrayRef<TemplateArgument> TypeConstraintArgs = {},
1799 bool IsCanon = false) const;
1800
1801public:
1803 NestedNameSpecifier Qualifier,
1804 const TypeDecl *Decl) const;
1805
1806 /// Return the unique reference to the type for the specified type
1807 /// declaration.
1808 QualType getTypeDeclType(const TypeDecl *Decl) const;
1809
1810 /// Use the normal 'getFooBarType' constructors to obtain these types.
1811 QualType getTypeDeclType(const TagDecl *) const = delete;
1812 QualType getTypeDeclType(const TypedefDecl *) const = delete;
1813 QualType getTypeDeclType(const TypeAliasDecl *) const = delete;
1815
1817
1819 NestedNameSpecifier Qualifier, const UsingShadowDecl *D,
1820 QualType UnderlyingType = QualType()) const;
1821
1822 /// Return the unique reference to the type for the specified
1823 /// typedef-name decl.
1824 /// FIXME: TypeMatchesDeclOrNone is a workaround for a serialization issue:
1825 /// The decl underlying type might still not be available.
1828 const TypedefNameDecl *Decl, QualType UnderlyingType = QualType(),
1829 std::optional<bool> TypeMatchesDeclOrNone = std::nullopt) const;
1830
1831 CanQualType getCanonicalTagType(const TagDecl *TD) const;
1833 NestedNameSpecifier Qualifier, const TagDecl *TD,
1834 bool OwnsTag) const;
1835
1836private:
1837 UnresolvedUsingType *getUnresolvedUsingTypeInternal(
1839 const UnresolvedUsingTypenameDecl *D, void *InsertPos,
1840 const Type *CanonicalType) const;
1841
1842 TagType *getTagTypeInternal(ElaboratedTypeKeyword Keyword,
1843 NestedNameSpecifier Qualifier, const TagDecl *Tag,
1844 bool OwnsTag, bool IsInjected,
1845 const Type *CanonicalType,
1846 bool WithFoldingSetNode) const;
1847
1848public:
1849 /// Compute BestType and BestPromotionType for an enum based on the highest
1850 /// number of negative and positive bits of its elements.
1851 /// Returns true if enum width is too large.
1852 bool computeBestEnumTypes(bool IsPacked, unsigned NumNegativeBits,
1853 unsigned NumPositiveBits, QualType &BestType,
1854 QualType &BestPromotionType);
1855
1856 /// Determine whether the given integral value is representable within
1857 /// the given type T.
1858 bool isRepresentableIntegerValue(llvm::APSInt &Value, QualType T);
1859
1860 /// Compute NumNegativeBits and NumPositiveBits for an enum based on
1861 /// the constant values of its enumerators.
1862 template <typename RangeT>
1863 bool computeEnumBits(RangeT EnumConstants, unsigned &NumNegativeBits,
1864 unsigned &NumPositiveBits) {
1865 NumNegativeBits = 0;
1866 NumPositiveBits = 0;
1867 bool MembersRepresentableByInt = true;
1868 for (auto *Elem : EnumConstants) {
1869 EnumConstantDecl *ECD = cast_or_null<EnumConstantDecl>(Elem);
1870 if (!ECD)
1871 continue; // Already issued a diagnostic.
1872
1873 llvm::APSInt InitVal = ECD->getInitVal();
1874 if (InitVal.isUnsigned() || InitVal.isNonNegative()) {
1875 // If the enumerator is zero that should still be counted as a positive
1876 // bit since we need a bit to store the value zero.
1877 unsigned ActiveBits = InitVal.getActiveBits();
1878 NumPositiveBits = std::max({NumPositiveBits, ActiveBits, 1u});
1879 } else {
1880 NumNegativeBits =
1881 std::max(NumNegativeBits, InitVal.getSignificantBits());
1882 }
1883
1884 MembersRepresentableByInt &= isRepresentableIntegerValue(InitVal, IntTy);
1885 }
1886
1887 // If we have an empty set of enumerators we still need one bit.
1888 // From [dcl.enum]p8
1889 // If the enumerator-list is empty, the values of the enumeration are as if
1890 // the enumeration had a single enumerator with value 0
1891 if (!NumPositiveBits && !NumNegativeBits)
1892 NumPositiveBits = 1;
1893
1894 return MembersRepresentableByInt;
1895 }
1896
1900 NestedNameSpecifier Qualifier,
1901 const UnresolvedUsingTypenameDecl *D) const;
1902
1903 QualType getAttributedType(attr::Kind attrKind, QualType modifiedType,
1904 QualType equivalentType,
1905 const Attr *attr = nullptr) const;
1906
1907 QualType getAttributedType(const Attr *attr, QualType modifiedType,
1908 QualType equivalentType) const;
1909
1910 QualType getAttributedType(NullabilityKind nullability, QualType modifiedType,
1911 QualType equivalentType);
1912
1913 QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr,
1914 QualType Wrapped) const;
1915
1917 QualType Wrapped, QualType Contained,
1918 const HLSLAttributedResourceType::Attributes &Attrs);
1919
1920 QualType getHLSLInlineSpirvType(uint32_t Opcode, uint32_t Size,
1921 uint32_t Alignment,
1922 ArrayRef<SpirvOperand> Operands);
1923
1925 Decl *AssociatedDecl, unsigned Index,
1926 UnsignedOrNone PackIndex,
1927 bool Final) const;
1929 unsigned Index, bool Final,
1930 const TemplateArgument &ArgPack);
1932
1933 QualType
1934 getTemplateTypeParmType(unsigned Depth, unsigned Index,
1935 bool ParameterPack,
1936 TemplateTypeParmDecl *ParmDecl = nullptr) const;
1937
1940 ArrayRef<TemplateArgument> CanonicalArgs) const;
1941
1942 QualType
1944 ArrayRef<TemplateArgument> SpecifiedArgs,
1945 ArrayRef<TemplateArgument> CanonicalArgs,
1946 QualType Underlying = QualType()) const;
1947
1948 QualType
1950 ArrayRef<TemplateArgumentLoc> SpecifiedArgs,
1951 ArrayRef<TemplateArgument> CanonicalArgs,
1952 QualType Canon = QualType()) const;
1953
1955 ElaboratedTypeKeyword Keyword, SourceLocation ElaboratedKeywordLoc,
1956 NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKeywordLoc,
1958 const TemplateArgumentListInfo &SpecifiedArgs,
1959 ArrayRef<TemplateArgument> CanonicalArgs,
1960 QualType Canon = QualType()) const;
1961
1962 QualType getParenType(QualType NamedType) const;
1963
1965 const IdentifierInfo *MacroII) const;
1966
1969 const IdentifierInfo *Name) const;
1970
1972
1973 /// Form a pack expansion type with the given pattern.
1974 /// \param NumExpansions The number of expansions for the pack, if known.
1975 /// \param ExpectPackInType If \c false, we should not expect \p Pattern to
1976 /// contain an unexpanded pack. This only makes sense if the pack
1977 /// expansion is used in a context where the arity is inferred from
1978 /// elsewhere, such as if the pattern contains a placeholder type or
1979 /// if this is the canonical type of another pack expansion type.
1981 bool ExpectPackInType = true) const;
1982
1984 ObjCInterfaceDecl *PrevDecl = nullptr) const;
1985
1986 /// Legacy interface: cannot provide type arguments or __kindof.
1988 ObjCProtocolDecl * const *Protocols,
1989 unsigned NumProtocols) const;
1990
1992 ArrayRef<QualType> typeArgs,
1994 bool isKindOf) const;
1995
1997 ArrayRef<ObjCProtocolDecl *> protocols) const;
1999 ObjCTypeParamDecl *New) const;
2000
2002
2003 /// QIdProtocolsAdoptObjCObjectProtocols - Checks that protocols in
2004 /// QT's qualified-id protocol list adopt all protocols in IDecl's list
2005 /// of protocols.
2007 ObjCInterfaceDecl *IDecl);
2008
2009 /// Return a ObjCObjectPointerType type for the given ObjCObjectType.
2011
2012 /// C23 feature and GCC extension.
2013 QualType getTypeOfExprType(Expr *E, TypeOfKind Kind) const;
2014 QualType getTypeOfType(QualType QT, TypeOfKind Kind) const;
2015
2016 QualType getReferenceQualifiedType(const Expr *e) const;
2017
2018 /// C++11 decltype.
2019 QualType getDecltypeType(Expr *e, QualType UnderlyingType) const;
2020
2021 QualType getPackIndexingType(QualType Pattern, Expr *IndexExpr,
2022 bool FullySubstituted = false,
2023 ArrayRef<QualType> Expansions = {},
2024 UnsignedOrNone Index = std::nullopt) const;
2025
2026 /// Unary type transforms
2027 QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType,
2028 UnaryTransformType::UTTKind UKind) const;
2029
2030 /// C++11 deduced auto type.
2031 QualType
2032 getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent,
2033 bool IsPack = false,
2034 TemplateDecl *TypeConstraintConcept = nullptr,
2035 ArrayRef<TemplateArgument> TypeConstraintArgs = {}) const;
2036
2037 /// C++11 deduction pattern for 'auto' type.
2038 QualType getAutoDeductType() const;
2039
2040 /// C++11 deduction pattern for 'auto &&' type.
2041 QualType getAutoRRefDeductType() const;
2042
2043 /// Remove any type constraints from a template parameter type, for
2044 /// equivalence comparison of template parameters.
2045 QualType getUnconstrainedType(QualType T) const;
2046
2047 /// C++17 deduced class template specialization type.
2050 QualType DeducedType,
2051 bool IsDependent) const;
2052
2053private:
2054 QualType getDeducedTemplateSpecializationTypeInternal(
2056 QualType DeducedType, bool IsDependent, QualType Canon) const;
2057
2058public:
2059 /// Return the unique type for "size_t" (C99 7.17), defined in
2060 /// <stddef.h>.
2061 ///
2062 /// The sizeof operator requires this (C99 6.5.3.4p4).
2063 QualType getSizeType() const;
2064
2066
2067 /// Return the unique signed counterpart of
2068 /// the integer type corresponding to size_t.
2069 QualType getSignedSizeType() const;
2070
2071 /// Return the unique type for "intmax_t" (C99 7.18.1.5), defined in
2072 /// <stdint.h>.
2073 CanQualType getIntMaxType() const;
2074
2075 /// Return the unique type for "uintmax_t" (C99 7.18.1.5), defined in
2076 /// <stdint.h>.
2078
2079 /// Return the unique wchar_t type available in C++ (and available as
2080 /// __wchar_t as a Microsoft extension).
2081 QualType getWCharType() const { return WCharTy; }
2082
2083 /// Return the type of wide characters. In C++, this returns the
2084 /// unique wchar_t type. In C99, this returns a type compatible with the type
2085 /// defined in <stddef.h> as defined by the target.
2087
2088 /// Return the type of "signed wchar_t".
2089 ///
2090 /// Used when in C++, as a GCC extension.
2092
2093 /// Return the type of "unsigned wchar_t".
2094 ///
2095 /// Used when in C++, as a GCC extension.
2097
2098 /// In C99, this returns a type compatible with the type
2099 /// defined in <stddef.h> as defined by the target.
2100 QualType getWIntType() const { return WIntTy; }
2101
2102 /// Return a type compatible with "intptr_t" (C99 7.18.1.4),
2103 /// as defined by the target.
2104 QualType getIntPtrType() const;
2105
2106 /// Return a type compatible with "uintptr_t" (C99 7.18.1.4),
2107 /// as defined by the target.
2108 QualType getUIntPtrType() const;
2109
2110 /// Return the unique type for "ptrdiff_t" (C99 7.17) defined in
2111 /// <stddef.h>. Pointer - pointer requires this (C99 6.5.6p9).
2113
2114 /// Return the unique unsigned counterpart of "ptrdiff_t"
2115 /// integer type. The standard (C11 7.21.6.1p7) refers to this type
2116 /// in the definition of %tu format specifier.
2118
2119 /// Return the unique type for "pid_t" defined in
2120 /// <sys/types.h>. We need this to compute the correct type for vfork().
2121 QualType getProcessIDType() const;
2122
2123 /// Return the C structure type used to represent constant CFStrings.
2125
2126 /// Returns the C struct type for objc_super
2127 QualType getObjCSuperType() const;
2128 void setObjCSuperType(QualType ST) { ObjCSuperType = ST; }
2129
2130 /// Get the structure type used to representation CFStrings, or NULL
2131 /// if it hasn't yet been built.
2133 if (CFConstantStringTypeDecl)
2135 /*Qualifier=*/std::nullopt,
2136 CFConstantStringTypeDecl);
2137 return QualType();
2138 }
2142
2143 // This setter/getter represents the ObjC type for an NSConstantString.
2146 return ObjCConstantStringType;
2147 }
2148
2150 return ObjCNSStringType;
2151 }
2152
2154 ObjCNSStringType = T;
2155 }
2156
2157 /// Retrieve the type that \c id has been defined to, which may be
2158 /// different from the built-in \c id if \c id has been typedef'd.
2160 if (ObjCIdRedefinitionType.isNull())
2161 return getObjCIdType();
2162 return ObjCIdRedefinitionType;
2163 }
2164
2165 /// Set the user-written type that redefines \c id.
2167 ObjCIdRedefinitionType = RedefType;
2168 }
2169
2170 /// Retrieve the type that \c Class has been defined to, which may be
2171 /// different from the built-in \c Class if \c Class has been typedef'd.
2173 if (ObjCClassRedefinitionType.isNull())
2174 return getObjCClassType();
2175 return ObjCClassRedefinitionType;
2176 }
2177
2178 /// Set the user-written type that redefines 'SEL'.
2180 ObjCClassRedefinitionType = RedefType;
2181 }
2182
2183 /// Retrieve the type that 'SEL' has been defined to, which may be
2184 /// different from the built-in 'SEL' if 'SEL' has been typedef'd.
2186 if (ObjCSelRedefinitionType.isNull())
2187 return getObjCSelType();
2188 return ObjCSelRedefinitionType;
2189 }
2190
2191 /// Set the user-written type that redefines 'SEL'.
2193 ObjCSelRedefinitionType = RedefType;
2194 }
2195
2196 /// Retrieve the identifier 'NSObject'.
2198 if (!NSObjectName) {
2199 NSObjectName = &Idents.get("NSObject");
2200 }
2201
2202 return NSObjectName;
2203 }
2204
2205 /// Retrieve the identifier 'NSCopying'.
2207 if (!NSCopyingName) {
2208 NSCopyingName = &Idents.get("NSCopying");
2209 }
2210
2211 return NSCopyingName;
2212 }
2213
2215
2217
2218 /// Retrieve the identifier 'bool'.
2220 if (!BoolName)
2221 BoolName = &Idents.get("bool");
2222 return BoolName;
2223 }
2224
2225#define BuiltinTemplate(BTName) \
2226 IdentifierInfo *get##BTName##Name() const { \
2227 if (!Name##BTName) \
2228 Name##BTName = &Idents.get(#BTName); \
2229 return Name##BTName; \
2230 }
2231#include "clang/Basic/BuiltinTemplates.inc"
2232
2233 /// Retrieve the Objective-C "instancetype" type.
2236 /*Qualifier=*/std::nullopt,
2238 }
2239
2240 /// Retrieve the typedef declaration corresponding to the Objective-C
2241 /// "instancetype" type.
2243
2244 /// Set the type for the C FILE type.
2245 void setFILEDecl(TypeDecl *FILEDecl) { this->FILEDecl = FILEDecl; }
2246
2247 /// Retrieve the C FILE type.
2249 if (FILEDecl)
2251 /*Qualifier=*/std::nullopt, FILEDecl);
2252 return QualType();
2253 }
2254
2255 /// Set the type for the C jmp_buf type.
2256 void setjmp_bufDecl(TypeDecl *jmp_bufDecl) {
2257 this->jmp_bufDecl = jmp_bufDecl;
2258 }
2259
2260 /// Retrieve the C jmp_buf type.
2262 if (jmp_bufDecl)
2264 /*Qualifier=*/std::nullopt, jmp_bufDecl);
2265 return QualType();
2266 }
2267
2268 /// Set the type for the C sigjmp_buf type.
2269 void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl) {
2270 this->sigjmp_bufDecl = sigjmp_bufDecl;
2271 }
2272
2273 /// Retrieve the C sigjmp_buf type.
2275 if (sigjmp_bufDecl)
2277 /*Qualifier=*/std::nullopt, sigjmp_bufDecl);
2278 return QualType();
2279 }
2280
2281 /// Set the type for the C ucontext_t type.
2282 void setucontext_tDecl(TypeDecl *ucontext_tDecl) {
2283 this->ucontext_tDecl = ucontext_tDecl;
2284 }
2285
2286 /// Retrieve the C ucontext_t type.
2288 if (ucontext_tDecl)
2290 /*Qualifier=*/std::nullopt, ucontext_tDecl);
2291 return QualType();
2292 }
2293
2294 /// The result type of logical operations, '<', '>', '!=', etc.
2296 return getLangOpts().CPlusPlus ? BoolTy : IntTy;
2297 }
2298
2299 /// Emit the Objective-CC type encoding for the given type \p T into
2300 /// \p S.
2301 ///
2302 /// If \p Field is specified then record field names are also encoded.
2303 void getObjCEncodingForType(QualType T, std::string &S,
2304 const FieldDecl *Field=nullptr,
2305 QualType *NotEncodedT=nullptr) const;
2306
2307 /// Emit the Objective-C property type encoding for the given
2308 /// type \p T into \p S.
2309 void getObjCEncodingForPropertyType(QualType T, std::string &S) const;
2310
2312
2313 /// Put the string version of the type qualifiers \p QT into \p S.
2315 std::string &S) const;
2316
2317 /// Emit the encoded type for the function \p Decl into \p S.
2318 ///
2319 /// This is in the same format as Objective-C method encodings.
2320 ///
2321 /// \returns true if an error occurred (e.g., because one of the parameter
2322 /// types is incomplete), false otherwise.
2323 std::string getObjCEncodingForFunctionDecl(const FunctionDecl *Decl) const;
2324
2325 /// Emit the encoded type for the method declaration \p Decl into
2326 /// \p S.
2328 bool Extended = false) const;
2329
2330 /// Return the encoded type for this block declaration.
2331 std::string getObjCEncodingForBlock(const BlockExpr *blockExpr) const;
2332
2333 /// getObjCEncodingForPropertyDecl - Return the encoded type for
2334 /// this method declaration. If non-NULL, Container must be either
2335 /// an ObjCCategoryImplDecl or ObjCImplementationDecl; it should
2336 /// only be NULL when getting encodings for protocol properties.
2338 const Decl *Container) const;
2339
2341 ObjCProtocolDecl *rProto) const;
2342
2344 const ObjCPropertyDecl *PD,
2345 const Decl *Container) const;
2346
2347 /// Return the size of type \p T for Objective-C encoding purpose,
2348 /// in characters.
2350
2351 /// Retrieve the typedef corresponding to the predefined \c id type
2352 /// in Objective-C.
2353 TypedefDecl *getObjCIdDecl() const;
2354
2355 /// Represents the Objective-CC \c id type.
2356 ///
2357 /// This is set up lazily, by Sema. \c id is always a (typedef for a)
2358 /// pointer type, a pointer to a struct.
2361 /*Qualifier=*/std::nullopt, getObjCIdDecl());
2362 }
2363
2364 /// Retrieve the typedef corresponding to the predefined 'SEL' type
2365 /// in Objective-C.
2366 TypedefDecl *getObjCSelDecl() const;
2367
2368 /// Retrieve the type that corresponds to the predefined Objective-C
2369 /// 'SEL' type.
2372 /*Qualifier=*/std::nullopt, getObjCSelDecl());
2373 }
2374
2376
2377 /// Retrieve the typedef declaration corresponding to the predefined
2378 /// Objective-C 'Class' type.
2380
2381 /// Represents the Objective-C \c Class type.
2382 ///
2383 /// This is set up lazily, by Sema. \c Class is always a (typedef for a)
2384 /// pointer type, a pointer to a struct.
2387 /*Qualifier=*/std::nullopt, getObjCClassDecl());
2388 }
2389
2390 /// Retrieve the Objective-C class declaration corresponding to
2391 /// the predefined \c Protocol class.
2393
2394 /// Retrieve declaration of 'BOOL' typedef
2396 return BOOLDecl;
2397 }
2398
2399 /// Save declaration of 'BOOL' typedef
2401 BOOLDecl = TD;
2402 }
2403
2404 /// type of 'BOOL' type.
2407 /*Qualifier=*/std::nullopt, getBOOLDecl());
2408 }
2409
2410 /// Retrieve the type of the Objective-C \c Protocol class.
2414
2415 /// Retrieve the C type declaration corresponding to the predefined
2416 /// \c __builtin_va_list type.
2418
2419 /// Retrieve the type of the \c __builtin_va_list type.
2422 /*Qualifier=*/std::nullopt, getBuiltinVaListDecl());
2423 }
2424
2425 /// Retrieve the C type declaration corresponding to the predefined
2426 /// \c __va_list_tag type used to help define the \c __builtin_va_list type
2427 /// for some targets.
2428 Decl *getVaListTagDecl() const;
2429
2430 /// Retrieve the C type declaration corresponding to the predefined
2431 /// \c __builtin_ms_va_list type.
2433
2434 /// Retrieve the type of the \c __builtin_ms_va_list type.
2437 /*Qualifier=*/std::nullopt, getBuiltinMSVaListDecl());
2438 }
2439
2440 /// Retrieve the implicitly-predeclared 'struct _GUID' declaration.
2442
2443 /// Retrieve the implicitly-predeclared 'struct _GUID' type.
2445 assert(MSGuidTagDecl && "asked for GUID type but MS extensions disabled");
2447 }
2448
2449 /// Retrieve the implicitly-predeclared 'struct type_info' declaration.
2451 // Lazily create this type on demand - it's only needed for MS builds.
2452 if (!MSTypeInfoTagDecl)
2454 return MSTypeInfoTagDecl;
2455 }
2456
2457 /// Return whether a declaration to a builtin is allowed to be
2458 /// overloaded/redeclared.
2459 bool canBuiltinBeRedeclared(const FunctionDecl *) const;
2460
2461 /// Return a type with additional \c const, \c volatile, or
2462 /// \c restrict qualifiers.
2465 }
2466
2467 /// Un-split a SplitQualType.
2469 return getQualifiedType(split.Ty, split.Quals);
2470 }
2471
2472 /// Return a type with additional qualifiers.
2474 if (!Qs.hasNonFastQualifiers())
2475 return T.withFastQualifiers(Qs.getFastQualifiers());
2476 QualifierCollector Qc(Qs);
2477 const Type *Ptr = Qc.strip(T);
2478 return getExtQualType(Ptr, Qc);
2479 }
2480
2481 /// Return a type with additional qualifiers.
2483 if (!Qs.hasNonFastQualifiers())
2484 return QualType(T, Qs.getFastQualifiers());
2485 return getExtQualType(T, Qs);
2486 }
2487
2488 /// Return a type with the given lifetime qualifier.
2489 ///
2490 /// \pre Neither type.ObjCLifetime() nor \p lifetime may be \c OCL_None.
2492 Qualifiers::ObjCLifetime lifetime) {
2493 assert(type.getObjCLifetime() == Qualifiers::OCL_None);
2494 assert(lifetime != Qualifiers::OCL_None);
2495
2496 Qualifiers qs;
2497 qs.addObjCLifetime(lifetime);
2498 return getQualifiedType(type, qs);
2499 }
2500
2501 /// getUnqualifiedObjCPointerType - Returns version of
2502 /// Objective-C pointer type with lifetime qualifier removed.
2504 if (!type.getTypePtr()->isObjCObjectPointerType() ||
2505 !type.getQualifiers().hasObjCLifetime())
2506 return type;
2507 Qualifiers Qs = type.getQualifiers();
2508 Qs.removeObjCLifetime();
2509 return getQualifiedType(type.getUnqualifiedType(), Qs);
2510 }
2511
2512 /// \brief Return a type with the given __ptrauth qualifier.
2514 assert(!Ty.getPointerAuth());
2515 assert(PointerAuth);
2516
2517 Qualifiers Qs;
2518 Qs.setPointerAuth(PointerAuth);
2519 return getQualifiedType(Ty, Qs);
2520 }
2521
2522 unsigned char getFixedPointScale(QualType Ty) const;
2523 unsigned char getFixedPointIBits(QualType Ty) const;
2524 llvm::FixedPointSemantics getFixedPointSemantics(QualType Ty) const;
2525 llvm::APFixedPoint getFixedPointMax(QualType Ty) const;
2526 llvm::APFixedPoint getFixedPointMin(QualType Ty) const;
2527
2529 SourceLocation NameLoc) const;
2530
2532 UnresolvedSetIterator End) const;
2534
2536 bool TemplateKeyword,
2537 TemplateName Template) const;
2540
2542 Decl *AssociatedDecl,
2543 unsigned Index,
2544 UnsignedOrNone PackIndex,
2545 bool Final) const;
2547 Decl *AssociatedDecl,
2548 unsigned Index,
2549 bool Final) const;
2550
2551 /// Represents a TemplateName which had some of its default arguments
2552 /// deduced. This both represents this default argument deduction as sugar,
2553 /// and provides the support for it's equivalences through canonicalization.
2554 /// For example DeducedTemplateNames which have the same set of default
2555 /// arguments are equivalent, and are also equivalent to the underlying
2556 /// template when the deduced template arguments are the same.
2558 DefaultArguments DefaultArgs) const;
2559
2561 /// No error
2563
2564 /// Missing a type
2566
2567 /// Missing a type from <stdio.h>
2569
2570 /// Missing a type from <setjmp.h>
2572
2573 /// Missing a type from <ucontext.h>
2575 };
2576
2577 QualType DecodeTypeStr(const char *&Str, const ASTContext &Context,
2579 bool &RequireICE, bool AllowTypeModifiers) const;
2580
2581 /// Return the type for the specified builtin.
2582 ///
2583 /// If \p IntegerConstantArgs is non-null, it is filled in with a bitmask of
2584 /// arguments to the builtin that are required to be integer constant
2585 /// expressions.
2587 unsigned *IntegerConstantArgs = nullptr) const;
2588
2589 /// Types and expressions required to build C++2a three-way comparisons
2590 /// using operator<=>, including the values return by builtin <=> operators.
2592
2593private:
2594 CanQualType getFromTargetType(unsigned Type) const;
2595 TypeInfo getTypeInfoImpl(const Type *T) const;
2596
2597 //===--------------------------------------------------------------------===//
2598 // Type Predicates.
2599 //===--------------------------------------------------------------------===//
2600
2601public:
2602 /// Return one of the GCNone, Weak or Strong Objective-C garbage
2603 /// collection attributes.
2605
2606 /// Return true if the given vector types are of the same unqualified
2607 /// type or if they are equivalent to the same GCC vector type.
2608 ///
2609 /// \note This ignores whether they are target-specific (AltiVec or Neon)
2610 /// types.
2611 bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec);
2612
2613 /// Return true if the given types are an RISC-V vector builtin type and a
2614 /// VectorType that is a fixed-length representation of the RISC-V vector
2615 /// builtin type for a specific vector-length.
2616 bool areCompatibleRVVTypes(QualType FirstType, QualType SecondType);
2617
2618 /// Return true if the given vector types are lax-compatible RISC-V vector
2619 /// types as defined by -flax-vector-conversions=, which permits implicit
2620 /// conversions between vectors with different number of elements and/or
2621 /// incompatible element types, false otherwise.
2622 bool areLaxCompatibleRVVTypes(QualType FirstType, QualType SecondType);
2623
2624 /// Return true if the type has been explicitly qualified with ObjC ownership.
2625 /// A type may be implicitly qualified with ownership under ObjC ARC, and in
2626 /// some cases the compiler treats these differently.
2628
2629 /// Return true if this is an \c NSObject object with its \c NSObject
2630 /// attribute set.
2632 return Ty->isObjCNSObjectType();
2633 }
2634
2635 //===--------------------------------------------------------------------===//
2636 // Type Sizing and Analysis
2637 //===--------------------------------------------------------------------===//
2638
2639 /// Return the APFloat 'semantics' for the specified scalar floating
2640 /// point type.
2641 const llvm::fltSemantics &getFloatTypeSemantics(QualType T) const;
2642
2643 /// Get the size and alignment of the specified complete type in bits.
2644 TypeInfo getTypeInfo(const Type *T) const;
2645 TypeInfo getTypeInfo(QualType T) const { return getTypeInfo(T.getTypePtr()); }
2646
2647 /// Get default simd alignment of the specified complete type in bits.
2648 unsigned getOpenMPDefaultSimdAlign(QualType T) const;
2649
2650 /// Return the size of the specified (complete) type \p T, in bits.
2651 uint64_t getTypeSize(QualType T) const { return getTypeInfo(T).Width; }
2652 uint64_t getTypeSize(const Type *T) const { return getTypeInfo(T).Width; }
2653
2654 /// Return the size of the character type, in bits.
2655 uint64_t getCharWidth() const {
2656 return getTypeSize(CharTy);
2657 }
2658
2659 /// Convert a size in bits to a size in characters.
2660 CharUnits toCharUnitsFromBits(int64_t BitSize) const;
2661
2662 /// Convert a size in characters to a size in bits.
2663 int64_t toBits(CharUnits CharSize) const;
2664
2665 /// Return the size of the specified (complete) type \p T, in
2666 /// characters.
2668 CharUnits getTypeSizeInChars(const Type *T) const;
2669
2670 std::optional<CharUnits> getTypeSizeInCharsIfKnown(QualType Ty) const {
2671 if (Ty->isIncompleteType() || Ty->isDependentType())
2672 return std::nullopt;
2673 return getTypeSizeInChars(Ty);
2674 }
2675
2676 std::optional<CharUnits> getTypeSizeInCharsIfKnown(const Type *Ty) const {
2677 return getTypeSizeInCharsIfKnown(QualType(Ty, 0));
2678 }
2679
2680 /// Return the ABI-specified alignment of a (complete) type \p T, in
2681 /// bits.
2682 unsigned getTypeAlign(QualType T) const { return getTypeInfo(T).Align; }
2683 unsigned getTypeAlign(const Type *T) const { return getTypeInfo(T).Align; }
2684
2685 /// Return the ABI-specified natural alignment of a (complete) type \p T,
2686 /// before alignment adjustments, in bits.
2687 ///
2688 /// This alignment is currently used only by ARM and AArch64 when passing
2689 /// arguments of a composite type.
2691 return getTypeUnadjustedAlign(T.getTypePtr());
2692 }
2693 unsigned getTypeUnadjustedAlign(const Type *T) const;
2694
2695 /// Return the alignment of a type, in bits, or 0 if
2696 /// the type is incomplete and we cannot determine the alignment (for
2697 /// example, from alignment attributes). The returned alignment is the
2698 /// Preferred alignment if NeedsPreferredAlignment is true, otherwise is the
2699 /// ABI alignment.
2701 bool NeedsPreferredAlignment = false) const;
2702
2703 /// Return the ABI-specified alignment of a (complete) type \p T, in
2704 /// characters.
2706 CharUnits getTypeAlignInChars(const Type *T) const;
2707
2708 /// Return the PreferredAlignment of a (complete) type \p T, in
2709 /// characters.
2713
2714 /// getTypeUnadjustedAlignInChars - Return the ABI-specified alignment of a type,
2715 /// in characters, before alignment adjustments. This method does not work on
2716 /// incomplete types.
2719
2720 // getTypeInfoDataSizeInChars - Return the size of a type, in chars. If the
2721 // type is a record, its data size is returned.
2723
2724 TypeInfoChars getTypeInfoInChars(const Type *T) const;
2726
2727 /// Determine if the alignment the type has was required using an
2728 /// alignment attribute.
2729 bool isAlignmentRequired(const Type *T) const;
2730 bool isAlignmentRequired(QualType T) const;
2731
2732 /// More type predicates useful for type checking/promotion
2733 bool isPromotableIntegerType(QualType T) const; // C99 6.3.1.1p2
2734
2735 /// Return the "preferred" alignment of the specified type \p T for
2736 /// the current target, in bits.
2737 ///
2738 /// This can be different than the ABI alignment in cases where it is
2739 /// beneficial for performance or backwards compatibility preserving to
2740 /// overalign a data type. (Note: despite the name, the preferred alignment
2741 /// is ABI-impacting, and not an optimization.)
2743 return getPreferredTypeAlign(T.getTypePtr());
2744 }
2745 unsigned getPreferredTypeAlign(const Type *T) const;
2746
2747 /// Return the default alignment for __attribute__((aligned)) on
2748 /// this target, to be used if no alignment value is specified.
2750
2751 /// Return the alignment in bits that should be given to a
2752 /// global variable with type \p T. If \p VD is non-null it will be
2753 /// considered specifically for the query.
2754 unsigned getAlignOfGlobalVar(QualType T, const VarDecl *VD) const;
2755
2756 /// Return the alignment in characters that should be given to a
2757 /// global variable with type \p T. If \p VD is non-null it will be
2758 /// considered specifically for the query.
2760
2761 /// Return the minimum alignment as specified by the target. If \p VD is
2762 /// non-null it may be used to identify external or weak variables.
2763 unsigned getMinGlobalAlignOfVar(uint64_t Size, const VarDecl *VD) const;
2764
2765 /// Return a conservative estimate of the alignment of the specified
2766 /// decl \p D.
2767 ///
2768 /// \pre \p D must not be a bitfield type, as bitfields do not have a valid
2769 /// alignment.
2770 ///
2771 /// If \p ForAlignof, references are treated like their underlying type
2772 /// and large arrays don't get any special treatment. If not \p ForAlignof
2773 /// it computes the value expected by CodeGen: references are treated like
2774 /// pointers and large arrays get extra alignment.
2775 CharUnits getDeclAlign(const Decl *D, bool ForAlignof = false) const;
2776
2777 /// Return the alignment (in bytes) of the thrown exception object. This is
2778 /// only meaningful for targets that allocate C++ exceptions in a system
2779 /// runtime, such as those using the Itanium C++ ABI.
2781
2782 /// Get or compute information about the layout of the specified
2783 /// record (struct/union/class) \p D, which indicates its size and field
2784 /// position information.
2785 const ASTRecordLayout &getASTRecordLayout(const RecordDecl *D) const;
2786
2787 /// Get or compute information about the layout of the specified
2788 /// Objective-C interface.
2790 const;
2791
2792 void DumpRecordLayout(const RecordDecl *RD, raw_ostream &OS,
2793 bool Simple = false) const;
2794
2795 /// Get our current best idea for the key function of the
2796 /// given record decl, or nullptr if there isn't one.
2797 ///
2798 /// The key function is, according to the Itanium C++ ABI section 5.2.3:
2799 /// ...the first non-pure virtual function that is not inline at the
2800 /// point of class definition.
2801 ///
2802 /// Other ABIs use the same idea. However, the ARM C++ ABI ignores
2803 /// virtual functions that are defined 'inline', which means that
2804 /// the result of this computation can change.
2806
2807 /// Observe that the given method cannot be a key function.
2808 /// Checks the key-function cache for the method's class and clears it
2809 /// if matches the given declaration.
2810 ///
2811 /// This is used in ABIs where out-of-line definitions marked
2812 /// inline are not considered to be key functions.
2813 ///
2814 /// \param method should be the declaration from the class definition
2815 void setNonKeyFunction(const CXXMethodDecl *method);
2816
2817 /// Loading virtual member pointers using the virtual inheritance model
2818 /// always results in an adjustment using the vbtable even if the index is
2819 /// zero.
2820 ///
2821 /// This is usually OK because the first slot in the vbtable points
2822 /// backwards to the top of the MDC. However, the MDC might be reusing a
2823 /// vbptr from an nv-base. In this case, the first slot in the vbtable
2824 /// points to the start of the nv-base which introduced the vbptr and *not*
2825 /// the MDC. Modify the NonVirtualBaseAdjustment to account for this.
2827
2828 /// Get the offset of a FieldDecl or IndirectFieldDecl, in bits.
2829 uint64_t getFieldOffset(const ValueDecl *FD) const;
2830
2831 /// Get the offset of an ObjCIvarDecl in bits.
2832 uint64_t lookupFieldBitOffset(const ObjCInterfaceDecl *OID,
2833 const ObjCIvarDecl *Ivar) const;
2834
2835 /// Find the 'this' offset for the member path in a pointer-to-member
2836 /// APValue.
2838
2839 bool isNearlyEmpty(const CXXRecordDecl *RD) const;
2840
2842
2843 /// If \p T is null pointer, assume the target in ASTContext.
2844 MangleContext *createMangleContext(const TargetInfo *T = nullptr);
2845
2846 /// Creates a device mangle context to correctly mangle lambdas in a mixed
2847 /// architecture compile by setting the lambda mangling number source to the
2848 /// DeviceLambdaManglingNumber. Currently this asserts that the TargetInfo
2849 /// (from the AuxTargetInfo) is a an itanium target.
2851
2852 void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass,
2854
2855 unsigned CountNonClassIvars(const ObjCInterfaceDecl *OI) const;
2856 void CollectInheritedProtocols(const Decl *CDecl,
2858
2859 /// Return true if the specified type has unique object representations
2860 /// according to (C++17 [meta.unary.prop]p9)
2861 bool
2863 bool CheckIfTriviallyCopyable = true) const;
2864
2865 //===--------------------------------------------------------------------===//
2866 // Type Operators
2867 //===--------------------------------------------------------------------===//
2868
2869 /// Return the canonical (structural) type corresponding to the
2870 /// specified potentially non-canonical type \p T.
2871 ///
2872 /// The non-canonical version of a type may have many "decorated" versions of
2873 /// types. Decorators can include typedefs, 'typeof' operators, etc. The
2874 /// returned type is guaranteed to be free of any of these, allowing two
2875 /// canonical types to be compared for exact equality with a simple pointer
2876 /// comparison.
2878 return CanQualType::CreateUnsafe(T.getCanonicalType());
2879 }
2880
2881 const Type *getCanonicalType(const Type *T) const {
2882 return T->getCanonicalTypeInternal().getTypePtr();
2883 }
2884
2885 /// Return the canonical parameter type corresponding to the specific
2886 /// potentially non-canonical one.
2887 ///
2888 /// Qualifiers are stripped off, functions are turned into function
2889 /// pointers, and arrays decay one level into pointers.
2891
2892 /// Determine whether the given types \p T1 and \p T2 are equivalent.
2893 bool hasSameType(QualType T1, QualType T2) const {
2894 return getCanonicalType(T1) == getCanonicalType(T2);
2895 }
2896 bool hasSameType(const Type *T1, const Type *T2) const {
2897 return getCanonicalType(T1) == getCanonicalType(T2);
2898 }
2899
2900 /// Determine whether the given expressions \p X and \p Y are equivalent.
2901 bool hasSameExpr(const Expr *X, const Expr *Y) const;
2902
2903 /// Return this type as a completely-unqualified array type,
2904 /// capturing the qualifiers in \p Quals.
2905 ///
2906 /// This will remove the minimal amount of sugaring from the types, similar
2907 /// to the behavior of QualType::getUnqualifiedType().
2908 ///
2909 /// \param T is the qualified type, which may be an ArrayType
2910 ///
2911 /// \param Quals will receive the full set of qualifiers that were
2912 /// applied to the array.
2913 ///
2914 /// \returns if this is an array type, the completely unqualified array type
2915 /// that corresponds to it. Otherwise, returns T.getUnqualifiedType().
2918 Qualifiers Quals;
2919 return getUnqualifiedArrayType(T, Quals);
2920 }
2921
2922 /// Determine whether the given types are equivalent after
2923 /// cvr-qualifiers have been removed.
2925 return getCanonicalType(T1).getTypePtr() ==
2927 }
2928
2930 bool IsParam) const {
2931 auto SubTnullability = SubT->getNullability();
2932 auto SuperTnullability = SuperT->getNullability();
2933 if (SubTnullability.has_value() == SuperTnullability.has_value()) {
2934 // Neither has nullability; return true
2935 if (!SubTnullability)
2936 return true;
2937 // Both have nullability qualifier.
2938 if (*SubTnullability == *SuperTnullability ||
2939 *SubTnullability == NullabilityKind::Unspecified ||
2940 *SuperTnullability == NullabilityKind::Unspecified)
2941 return true;
2942
2943 if (IsParam) {
2944 // Ok for the superclass method parameter to be "nonnull" and the subclass
2945 // method parameter to be "nullable"
2946 return (*SuperTnullability == NullabilityKind::NonNull &&
2947 *SubTnullability == NullabilityKind::Nullable);
2948 }
2949 // For the return type, it's okay for the superclass method to specify
2950 // "nullable" and the subclass method specify "nonnull"
2951 return (*SuperTnullability == NullabilityKind::Nullable &&
2952 *SubTnullability == NullabilityKind::NonNull);
2953 }
2954 return true;
2955 }
2956
2957 bool ObjCMethodsAreEqual(const ObjCMethodDecl *MethodDecl,
2958 const ObjCMethodDecl *MethodImp);
2959
2960 bool UnwrapSimilarTypes(QualType &T1, QualType &T2,
2961 bool AllowPiMismatch = true) const;
2963 bool AllowPiMismatch = true) const;
2964
2965 /// Determine if two types are similar, according to the C++ rules. That is,
2966 /// determine if they are the same other than qualifiers on the initial
2967 /// sequence of pointer / pointer-to-member / array (and in Clang, object
2968 /// pointer) types and their element types.
2969 ///
2970 /// Clang offers a number of qualifiers in addition to the C++ qualifiers;
2971 /// those qualifiers are also ignored in the 'similarity' check.
2972 bool hasSimilarType(QualType T1, QualType T2) const;
2973
2974 /// Determine if two types are similar, ignoring only CVR qualifiers.
2975 bool hasCvrSimilarType(QualType T1, QualType T2);
2976
2977 /// Retrieves the default calling convention for the current context.
2978 ///
2979 /// The context's default calling convention may differ from the current
2980 /// target's default calling convention if the -fdefault-calling-conv option
2981 /// is used; to get the target's default calling convention, e.g. for built-in
2982 /// functions, call getTargetInfo().getDefaultCallingConv() instead.
2984 bool IsCXXMethod) const;
2985
2986 /// Retrieves the "canonical" template name that refers to a
2987 /// given template.
2988 ///
2989 /// The canonical template name is the simplest expression that can
2990 /// be used to refer to a given template. For most templates, this
2991 /// expression is just the template declaration itself. For example,
2992 /// the template std::vector can be referred to via a variety of
2993 /// names---std::vector, \::std::vector, vector (if vector is in
2994 /// scope), etc.---but all of these names map down to the same
2995 /// TemplateDecl, which is used to form the canonical template name.
2996 ///
2997 /// Dependent template names are more interesting. Here, the
2998 /// template name could be something like T::template apply or
2999 /// std::allocator<T>::template rebind, where the nested name
3000 /// specifier itself is dependent. In this case, the canonical
3001 /// template name uses the shortest form of the dependent
3002 /// nested-name-specifier, which itself contains all canonical
3003 /// types, values, and templates.
3005 bool IgnoreDeduced = false) const;
3006
3007 /// Determine whether the given template names refer to the same
3008 /// template.
3009 bool hasSameTemplateName(const TemplateName &X, const TemplateName &Y,
3010 bool IgnoreDeduced = false) const;
3011
3012 /// Determine whether the two declarations refer to the same entity.
3013 bool isSameEntity(const NamedDecl *X, const NamedDecl *Y) const;
3014
3015 /// Determine whether two template parameter lists are similar enough
3016 /// that they may be used in declarations of the same template.
3018 const TemplateParameterList *Y) const;
3019
3020 /// Determine whether two template parameters are similar enough
3021 /// that they may be used in declarations of the same template.
3022 bool isSameTemplateParameter(const NamedDecl *X, const NamedDecl *Y) const;
3023
3024 /// Determine whether two 'requires' expressions are similar enough that they
3025 /// may be used in re-declarations.
3026 ///
3027 /// Use of 'requires' isn't mandatory, works with constraints expressed in
3028 /// other ways too.
3030 const AssociatedConstraint &ACY) const;
3031
3032 /// Determine whether two 'requires' expressions are similar enough that they
3033 /// may be used in re-declarations.
3034 ///
3035 /// Use of 'requires' isn't mandatory, works with constraints expressed in
3036 /// other ways too.
3037 bool isSameConstraintExpr(const Expr *XCE, const Expr *YCE) const;
3038
3039 /// Determine whether two type contraint are similar enough that they could
3040 /// used in declarations of the same template.
3041 bool isSameTypeConstraint(const TypeConstraint *XTC,
3042 const TypeConstraint *YTC) const;
3043
3044 /// Determine whether two default template arguments are similar enough
3045 /// that they may be used in declarations of the same template.
3047 const NamedDecl *Y) const;
3048
3049 /// Retrieve the "canonical" template argument.
3050 ///
3051 /// The canonical template argument is the simplest template argument
3052 /// (which may be a type, value, expression, or declaration) that
3053 /// expresses the value of the argument.
3055 const;
3056
3057 /// Canonicalize the given template argument list.
3058 ///
3059 /// Returns true if any arguments were non-canonical, false otherwise.
3060 bool
3062
3063 /// Canonicalize the given TemplateTemplateParmDecl.
3066
3068 TemplateTemplateParmDecl *TTP) const;
3070 TemplateTemplateParmDecl *CanonTTP) const;
3071
3072 /// Determine whether the given template arguments \p Arg1 and \p Arg2 are
3073 /// equivalent.
3075 const TemplateArgument &Arg2) const;
3076
3077 /// Type Query functions. If the type is an instance of the specified class,
3078 /// return the Type pointer for the underlying maximally pretty type. This
3079 /// is a member of ASTContext because this may need to do some amount of
3080 /// canonicalization, e.g. to move type qualifiers into the element type.
3081 const ArrayType *getAsArrayType(QualType T) const;
3083 return dyn_cast_or_null<ConstantArrayType>(getAsArrayType(T));
3084 }
3086 return dyn_cast_or_null<VariableArrayType>(getAsArrayType(T));
3087 }
3089 return dyn_cast_or_null<IncompleteArrayType>(getAsArrayType(T));
3090 }
3092 const {
3093 return dyn_cast_or_null<DependentSizedArrayType>(getAsArrayType(T));
3094 }
3095
3096 /// Return the innermost element type of an array type.
3097 ///
3098 /// For example, will return "int" for int[m][n]
3099 QualType getBaseElementType(const ArrayType *VAT) const;
3100
3101 /// Return the innermost element type of a type (which needn't
3102 /// actually be an array type).
3104
3105 /// Return number of constant array elements.
3106 uint64_t getConstantArrayElementCount(const ConstantArrayType *CA) const;
3107
3108 /// Return number of elements initialized in an ArrayInitLoopExpr.
3109 uint64_t
3111
3112 /// Perform adjustment on the parameter type of a function.
3113 ///
3114 /// This routine adjusts the given parameter type @p T to the actual
3115 /// parameter type used by semantic analysis (C99 6.7.5.3p[7,8],
3116 /// C++ [dcl.fct]p3). The adjusted parameter type is returned.
3118
3119 /// Retrieve the parameter type as adjusted for use in the signature
3120 /// of a function, decaying array and function types and removing top-level
3121 /// cv-qualifiers.
3123
3125
3126 /// Return the properly qualified result of decaying the specified
3127 /// array type to a pointer.
3128 ///
3129 /// This operation is non-trivial when handling typedefs etc. The canonical
3130 /// type of \p T must be an array type, this returns a pointer to a properly
3131 /// qualified element of the array.
3132 ///
3133 /// See C99 6.7.5.3p7 and C99 6.3.2.1p3.
3135
3136 /// Return the type that \p PromotableType will promote to: C99
3137 /// 6.3.1.1p2, assuming that \p PromotableType is a promotable integer type.
3138 QualType getPromotedIntegerType(QualType PromotableType) const;
3139
3140 /// Recurses in pointer/array types until it finds an Objective-C
3141 /// retainable type and returns its ownership.
3143
3144 /// Whether this is a promotable bitfield reference according
3145 /// to C99 6.3.1.1p2, bullet 2 (and GCC extensions).
3146 ///
3147 /// \returns the type this bit-field will promote to, or NULL if no
3148 /// promotion occurs.
3150
3151 /// Return the highest ranked integer type, see C99 6.3.1.8p1.
3152 ///
3153 /// If \p LHS > \p RHS, returns 1. If \p LHS == \p RHS, returns 0. If
3154 /// \p LHS < \p RHS, return -1.
3155 int getIntegerTypeOrder(QualType LHS, QualType RHS) const;
3156
3157 /// Compare the rank of the two specified floating point types,
3158 /// ignoring the domain of the type (i.e. 'double' == '_Complex double').
3159 ///
3160 /// If \p LHS > \p RHS, returns 1. If \p LHS == \p RHS, returns 0. If
3161 /// \p LHS < \p RHS, return -1.
3162 int getFloatingTypeOrder(QualType LHS, QualType RHS) const;
3163
3164 /// Compare the rank of two floating point types as above, but compare equal
3165 /// if both types have the same floating-point semantics on the target (i.e.
3166 /// long double and double on AArch64 will return 0).
3168
3169 unsigned getTargetAddressSpace(LangAS AS) const;
3170
3171 LangAS getLangASForBuiltinAddressSpace(unsigned AS) const;
3172
3173 /// Get target-dependent integer value for null pointer which is used for
3174 /// constant folding.
3175 uint64_t getTargetNullPointerValue(QualType QT) const;
3176
3178 return AddrSpaceMapMangling || isTargetAddressSpace(AS);
3179 }
3180
3181 bool hasAnyFunctionEffects() const { return AnyFunctionEffects; }
3182
3183 // Merges two exception specifications, such that the resulting
3184 // exception spec is the union of both. For example, if either
3185 // of them can throw something, the result can throw it as well.
3189 SmallVectorImpl<QualType> &ExceptionTypeStorage,
3190 bool AcceptDependent) const;
3191
3192 // For two "same" types, return a type which has
3193 // the common sugar between them. If Unqualified is true,
3194 // both types need only be the same unqualified type.
3195 // The result will drop the qualifiers which do not occur
3196 // in both types.
3198 bool Unqualified = false) const;
3199
3200private:
3201 // Helper for integer ordering
3202 unsigned getIntegerRank(const Type *T) const;
3203
3204public:
3205 //===--------------------------------------------------------------------===//
3206 // Type Compatibility Predicates
3207 //===--------------------------------------------------------------------===//
3208
3209 /// Compatibility predicates used to check assignment expressions.
3211 bool CompareUnqualified = false); // C99 6.2.7p1
3212
3215
3216 bool isObjCIdType(QualType T) const { return T == getObjCIdType(); }
3217
3218 bool isObjCClassType(QualType T) const { return T == getObjCClassType(); }
3219
3220 bool isObjCSelType(QualType T) const { return T == getObjCSelType(); }
3221
3223 const ObjCObjectPointerType *RHS,
3224 bool ForCompare);
3225
3227 const ObjCObjectPointerType *RHS);
3228
3229 // Check the safety of assignment from LHS to RHS
3231 const ObjCObjectPointerType *RHSOPT);
3233 const ObjCObjectType *RHS);
3235 const ObjCObjectPointerType *LHSOPT,
3236 const ObjCObjectPointerType *RHSOPT,
3237 bool BlockReturnType);
3240 const ObjCObjectPointerType *RHSOPT);
3242
3243 // Functions for calculating composite types
3244 QualType mergeTypes(QualType, QualType, bool OfBlockPointer = false,
3245 bool Unqualified = false, bool BlockReturnType = false,
3246 bool IsConditionalOperator = false);
3247 QualType mergeFunctionTypes(QualType, QualType, bool OfBlockPointer = false,
3248 bool Unqualified = false, bool AllowCXX = false,
3249 bool IsConditionalOperator = false);
3251 bool OfBlockPointer = false,
3252 bool Unqualified = false);
3254 bool OfBlockPointer=false,
3255 bool Unqualified = false);
3257
3259
3260 /// This function merges the ExtParameterInfo lists of two functions. It
3261 /// returns true if the lists are compatible. The merged list is returned in
3262 /// NewParamInfos.
3263 ///
3264 /// \param FirstFnType The type of the first function.
3265 ///
3266 /// \param SecondFnType The type of the second function.
3267 ///
3268 /// \param CanUseFirst This flag is set to true if the first function's
3269 /// ExtParameterInfo list can be used as the composite list of
3270 /// ExtParameterInfo.
3271 ///
3272 /// \param CanUseSecond This flag is set to true if the second function's
3273 /// ExtParameterInfo list can be used as the composite list of
3274 /// ExtParameterInfo.
3275 ///
3276 /// \param NewParamInfos The composite list of ExtParameterInfo. The list is
3277 /// empty if none of the flags are set.
3278 ///
3280 const FunctionProtoType *FirstFnType,
3281 const FunctionProtoType *SecondFnType,
3282 bool &CanUseFirst, bool &CanUseSecond,
3284
3285 void ResetObjCLayout(const ObjCInterfaceDecl *D);
3286
3288 const ObjCInterfaceDecl *SubClass) {
3289 ObjCSubClasses[D].push_back(SubClass);
3290 }
3291
3292 //===--------------------------------------------------------------------===//
3293 // Integer Predicates
3294 //===--------------------------------------------------------------------===//
3295
3296 // The width of an integer, as defined in C99 6.2.6.2. This is the number
3297 // of bits in an integer type excluding any padding bits.
3298 unsigned getIntWidth(QualType T) const;
3299
3300 // Per C99 6.2.5p6, for every signed integer type, there is a corresponding
3301 // unsigned integer type. This method takes a signed type, and returns the
3302 // corresponding unsigned integer type.
3303 // With the introduction of fixed point types in ISO N1169, this method also
3304 // accepts fixed point types and returns the corresponding unsigned type for
3305 // a given fixed point type.
3307
3308 // Per C99 6.2.5p6, for every signed integer type, there is a corresponding
3309 // unsigned integer type. This method takes an unsigned type, and returns the
3310 // corresponding signed integer type.
3311 // With the introduction of fixed point types in ISO N1169, this method also
3312 // accepts fixed point types and returns the corresponding signed type for
3313 // a given fixed point type.
3315
3316 // Per ISO N1169, this method accepts fixed point types and returns the
3317 // corresponding saturated type for a given fixed point type.
3319
3320 // Per ISO N1169, this method accepts fixed point types and returns the
3321 // corresponding non-saturated type for a given fixed point type.
3323
3324 // This method accepts fixed point types and returns the corresponding signed
3325 // type. Unlike getCorrespondingUnsignedType(), this only accepts unsigned
3326 // fixed point types because there are unsigned integer types like bool and
3327 // char8_t that don't have signed equivalents.
3329
3330 //===--------------------------------------------------------------------===//
3331 // Integer Values
3332 //===--------------------------------------------------------------------===//
3333
3334 /// Make an APSInt of the appropriate width and signedness for the
3335 /// given \p Value and integer \p Type.
3336 llvm::APSInt MakeIntValue(uint64_t Value, QualType Type) const {
3337 // If Type is a signed integer type larger than 64 bits, we need to be sure
3338 // to sign extend Res appropriately.
3339 llvm::APSInt Res(64, !Type->isSignedIntegerOrEnumerationType());
3340 Res = Value;
3341 unsigned Width = getIntWidth(Type);
3342 if (Width != Res.getBitWidth())
3343 return Res.extOrTrunc(Width);
3344 return Res;
3345 }
3346
3347 bool isSentinelNullExpr(const Expr *E);
3348
3349 /// Get the implementation of the ObjCInterfaceDecl \p D, or nullptr if
3350 /// none exists.
3352
3353 /// Get the implementation of the ObjCCategoryDecl \p D, or nullptr if
3354 /// none exists.
3356
3357 /// Return true if there is at least one \@implementation in the TU.
3359 return !ObjCImpls.empty();
3360 }
3361
3362 /// Set the implementation of ObjCInterfaceDecl.
3364 ObjCImplementationDecl *ImplD);
3365
3366 /// Set the implementation of ObjCCategoryDecl.
3368 ObjCCategoryImplDecl *ImplD);
3369
3370 /// Get the duplicate declaration of a ObjCMethod in the same
3371 /// interface, or null if none exists.
3372 const ObjCMethodDecl *
3374
3376 const ObjCMethodDecl *Redecl);
3377
3378 /// Returns the Objective-C interface that \p ND belongs to if it is
3379 /// an Objective-C method/property/ivar etc. that is part of an interface,
3380 /// otherwise returns null.
3382
3383 /// Set the copy initialization expression of a block var decl. \p CanThrow
3384 /// indicates whether the copy expression can throw or not.
3385 void setBlockVarCopyInit(const VarDecl* VD, Expr *CopyExpr, bool CanThrow);
3386
3387 /// Get the copy initialization expression of the VarDecl \p VD, or
3388 /// nullptr if none exists.
3390
3391 /// Allocate an uninitialized TypeSourceInfo.
3392 ///
3393 /// The caller should initialize the memory held by TypeSourceInfo using
3394 /// the TypeLoc wrappers.
3395 ///
3396 /// \param T the type that will be the basis for type source info. This type
3397 /// should refer to how the declarator was written in source code, not to
3398 /// what type semantic analysis resolved the declarator to.
3399 ///
3400 /// \param Size the size of the type info to create, or 0 if the size
3401 /// should be calculated based on the type.
3402 TypeSourceInfo *CreateTypeSourceInfo(QualType T, unsigned Size = 0) const;
3403
3404 /// Allocate a TypeSourceInfo where all locations have been
3405 /// initialized to a given location, which defaults to the empty
3406 /// location.
3409 SourceLocation Loc = SourceLocation()) const;
3410
3411 /// Add a deallocation callback that will be invoked when the
3412 /// ASTContext is destroyed.
3413 ///
3414 /// \param Callback A callback function that will be invoked on destruction.
3415 ///
3416 /// \param Data Pointer data that will be provided to the callback function
3417 /// when it is called.
3418 void AddDeallocation(void (*Callback)(void *), void *Data) const;
3419
3420 /// If T isn't trivially destructible, calls AddDeallocation to register it
3421 /// for destruction.
3422 template <typename T> void addDestruction(T *Ptr) const {
3423 if (!std::is_trivially_destructible<T>::value) {
3424 auto DestroyPtr = [](void *V) { static_cast<T *>(V)->~T(); };
3425 AddDeallocation(DestroyPtr, Ptr);
3426 }
3427 }
3428
3431
3432 /// Determines if the decl can be CodeGen'ed or deserialized from PCH
3433 /// lazily, only when used; this is only relevant for function or file scoped
3434 /// var definitions.
3435 ///
3436 /// \returns true if the function/var must be CodeGen'ed/deserialized even if
3437 /// it is not used.
3438 bool DeclMustBeEmitted(const Decl *D);
3439
3440 /// Visits all versions of a multiversioned function with the passed
3441 /// predicate.
3443 const FunctionDecl *FD,
3444 llvm::function_ref<void(FunctionDecl *)> Pred) const;
3445
3446 const CXXConstructorDecl *
3448
3450 CXXConstructorDecl *CD);
3451
3453
3455
3457
3459
3460 void setManglingNumber(const NamedDecl *ND, unsigned Number);
3461 unsigned getManglingNumber(const NamedDecl *ND,
3462 bool ForAuxTarget = false) const;
3463
3464 void setStaticLocalNumber(const VarDecl *VD, unsigned Number);
3465 unsigned getStaticLocalNumber(const VarDecl *VD) const;
3466
3468 return !TypeAwareOperatorNewAndDeletes.empty();
3469 }
3470 void setIsDestroyingOperatorDelete(const FunctionDecl *FD, bool IsDestroying);
3471 bool isDestroyingOperatorDelete(const FunctionDecl *FD) const;
3473 bool IsTypeAware);
3474 bool isTypeAwareOperatorNewOrDelete(const FunctionDecl *FD) const;
3475
3476 /// Retrieve the context for computing mangling numbers in the given
3477 /// DeclContext.
3481 const Decl *D);
3482
3483 std::unique_ptr<MangleNumberingContext> createMangleNumberingContext() const;
3484
3485 /// Used by ParmVarDecl to store on the side the
3486 /// index of the parameter when it exceeds the size of the normal bitfield.
3487 void setParameterIndex(const ParmVarDecl *D, unsigned index);
3488
3489 /// Used by ParmVarDecl to retrieve on the side the
3490 /// index of the parameter when it exceeds the size of the normal bitfield.
3491 unsigned getParameterIndex(const ParmVarDecl *D) const;
3492
3493 /// Return a string representing the human readable name for the specified
3494 /// function declaration or file name. Used by SourceLocExpr and
3495 /// PredefinedExpr to cache evaluated results.
3497
3498 /// Return the next version number to be used for a string literal evaluated
3499 /// as part of constant evaluation.
3500 unsigned getNextStringLiteralVersion() { return NextStringLiteralVersion++; }
3501
3502 /// Return a declaration for the global GUID object representing the given
3503 /// GUID value.
3505
3506 /// Return a declaration for a uniquified anonymous global constant
3507 /// corresponding to a given APValue.
3510
3511 /// Return the template parameter object of the given type with the given
3512 /// value.
3514 const APValue &V) const;
3515
3516 /// Parses the target attributes passed in, and returns only the ones that are
3517 /// valid feature names.
3518 ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD) const;
3519
3520 void getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap,
3521 const FunctionDecl *) const;
3522 void getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap,
3523 GlobalDecl GD) const;
3524
3525 /// Generates and stores SYCL kernel metadata for the provided
3526 /// SYCL kernel entry point function. The provided function must have
3527 /// an attached sycl_kernel_entry_point attribute that specifies a unique
3528 /// type for the name of a SYCL kernel. Callers are required to detect
3529 /// conflicting SYCL kernel names and issue a diagnostic prior to calling
3530 /// this function.
3532
3533 /// Given a type used as a SYCL kernel name, returns a reference to the
3534 /// metadata generated from the corresponding SYCL kernel entry point.
3535 /// Aborts if the provided type is not a registered SYCL kernel name.
3537
3538 /// Returns a pointer to the metadata generated from the corresponding
3539 /// SYCLkernel entry point if the provided type corresponds to a registered
3540 /// SYCL kernel name. Returns a null pointer otherwise.
3542
3543 //===--------------------------------------------------------------------===//
3544 // Statistics
3545 //===--------------------------------------------------------------------===//
3546
3547 /// The number of implicitly-declared default constructors.
3549
3550 /// The number of implicitly-declared default constructors for
3551 /// which declarations were built.
3553
3554 /// The number of implicitly-declared copy constructors.
3556
3557 /// The number of implicitly-declared copy constructors for
3558 /// which declarations were built.
3560
3561 /// The number of implicitly-declared move constructors.
3563
3564 /// The number of implicitly-declared move constructors for
3565 /// which declarations were built.
3567
3568 /// The number of implicitly-declared copy assignment operators.
3570
3571 /// The number of implicitly-declared copy assignment operators for
3572 /// which declarations were built.
3574
3575 /// The number of implicitly-declared move assignment operators.
3577
3578 /// The number of implicitly-declared move assignment operators for
3579 /// which declarations were built.
3581
3582 /// The number of implicitly-declared destructors.
3584
3585 /// The number of implicitly-declared destructors for which
3586 /// declarations were built.
3588
3589public:
3590 /// Initialize built-in types.
3591 ///
3592 /// This routine may only be invoked once for a given ASTContext object.
3593 /// It is normally invoked after ASTContext construction.
3594 ///
3595 /// \param Target The target
3596 void InitBuiltinTypes(const TargetInfo &Target,
3597 const TargetInfo *AuxTarget = nullptr);
3598
3599private:
3600 void InitBuiltinType(CanQualType &R, BuiltinType::Kind K);
3601
3602 class ObjCEncOptions {
3603 unsigned Bits;
3604
3605 ObjCEncOptions(unsigned Bits) : Bits(Bits) {}
3606
3607 public:
3608 ObjCEncOptions() : Bits(0) {}
3609
3610#define OPT_LIST(V) \
3611 V(ExpandPointedToStructures, 0) \
3612 V(ExpandStructures, 1) \
3613 V(IsOutermostType, 2) \
3614 V(EncodingProperty, 3) \
3615 V(IsStructField, 4) \
3616 V(EncodeBlockParameters, 5) \
3617 V(EncodeClassNames, 6) \
3618
3619#define V(N,I) ObjCEncOptions& set##N() { Bits |= 1 << I; return *this; }
3620OPT_LIST(V)
3621#undef V
3622
3623#define V(N,I) bool N() const { return Bits & 1 << I; }
3624OPT_LIST(V)
3625#undef V
3626
3627#undef OPT_LIST
3628
3629 [[nodiscard]] ObjCEncOptions keepingOnly(ObjCEncOptions Mask) const {
3630 return Bits & Mask.Bits;
3631 }
3632
3633 [[nodiscard]] ObjCEncOptions forComponentType() const {
3634 ObjCEncOptions Mask = ObjCEncOptions()
3635 .setIsOutermostType()
3636 .setIsStructField();
3637 return Bits & ~Mask.Bits;
3638 }
3639 };
3640
3641 // Return the Objective-C type encoding for a given type.
3642 void getObjCEncodingForTypeImpl(QualType t, std::string &S,
3643 ObjCEncOptions Options,
3644 const FieldDecl *Field,
3645 QualType *NotEncodedT = nullptr) const;
3646
3647 // Adds the encoding of the structure's members.
3648 void getObjCEncodingForStructureImpl(RecordDecl *RD, std::string &S,
3649 const FieldDecl *Field,
3650 bool includeVBases = true,
3651 QualType *NotEncodedT=nullptr) const;
3652
3653public:
3654 // Adds the encoding of a method parameter or return type.
3656 QualType T, std::string& S,
3657 bool Extended) const;
3658
3659 /// Returns true if this is an inline-initialized static data member
3660 /// which is treated as a definition for MSVC compatibility.
3661 bool isMSStaticDataMemberInlineDefinition(const VarDecl *VD) const;
3662
3664 /// Not an inline variable.
3665 None,
3666
3667 /// Weak definition of inline variable.
3669
3670 /// Weak for now, might become strong later in this TU.
3672
3673 /// Strong definition.
3675 };
3676
3677 /// Determine whether a definition of this inline variable should
3678 /// be treated as a weak or strong definition. For compatibility with
3679 /// C++14 and before, for a constexpr static data member, if there is an
3680 /// out-of-line declaration of the member, we may promote it from weak to
3681 /// strong.
3684
3685private:
3687 friend class DeclContext;
3688
3689 const ASTRecordLayout &getObjCLayout(const ObjCInterfaceDecl *D) const;
3690
3691 /// A set of deallocations that should be performed when the
3692 /// ASTContext is destroyed.
3693 // FIXME: We really should have a better mechanism in the ASTContext to
3694 // manage running destructors for types which do variable sized allocation
3695 // within the AST. In some places we thread the AST bump pointer allocator
3696 // into the datastructures which avoids this mess during deallocation but is
3697 // wasteful of memory, and here we require a lot of error prone book keeping
3698 // in order to track and run destructors while we're tearing things down.
3699 using DeallocationFunctionsAndArguments =
3700 llvm::SmallVector<std::pair<void (*)(void *), void *>, 16>;
3701 mutable DeallocationFunctionsAndArguments Deallocations;
3702
3703 // FIXME: This currently contains the set of StoredDeclMaps used
3704 // by DeclContext objects. This probably should not be in ASTContext,
3705 // but we include it here so that ASTContext can quickly deallocate them.
3706 llvm::PointerIntPair<StoredDeclsMap *, 1> LastSDM;
3707
3708 std::vector<Decl *> TraversalScope;
3709
3710 std::unique_ptr<VTableContextBase> VTContext;
3711
3712 void ReleaseDeclContextMaps();
3713
3714public:
3715 enum PragmaSectionFlag : unsigned {
3722 PSF_Invalid = 0x80000000U,
3723 };
3724
3736
3737 llvm::StringMap<SectionInfo> SectionInfos;
3738
3739 /// Return a new OMPTraitInfo object owned by this context.
3741
3742 /// Whether a C++ static variable or CUDA/HIP kernel may be externalized.
3743 bool mayExternalize(const Decl *D) const;
3744
3745 /// Whether a C++ static variable or CUDA/HIP kernel should be externalized.
3746 bool shouldExternalize(const Decl *D) const;
3747
3748 /// Resolve the root record to be used to derive the vtable pointer
3749 /// authentication policy for the specified record.
3750 const CXXRecordDecl *
3751 baseForVTableAuthentication(const CXXRecordDecl *ThisClass) const;
3752
3753 bool useAbbreviatedThunkName(GlobalDecl VirtualMethodDecl,
3754 StringRef MangledName);
3755
3756 StringRef getCUIDHash() const;
3757
3758private:
3759 /// All OMPTraitInfo objects live in this collection, one per
3760 /// `pragma omp [begin] declare variant` directive.
3761 SmallVector<std::unique_ptr<OMPTraitInfo>, 4> OMPTraitInfoVector;
3762
3763 llvm::DenseMap<GlobalDecl, llvm::StringSet<>> ThunksToBeAbbreviated;
3764};
3765
3766/// Insertion operator for diagnostics.
3768 const ASTContext::SectionInfo &Section);
3769
3770/// Utility function for constructing a nullary selector.
3771inline Selector GetNullarySelector(StringRef name, ASTContext &Ctx) {
3772 const IdentifierInfo *II = &Ctx.Idents.get(name);
3773 return Ctx.Selectors.getSelector(0, &II);
3774}
3775
3776/// Utility function for constructing an unary selector.
3777inline Selector GetUnarySelector(StringRef name, ASTContext &Ctx) {
3778 const IdentifierInfo *II = &Ctx.Idents.get(name);
3779 return Ctx.Selectors.getSelector(1, &II);
3780}
3781
3782} // namespace clang
3783
3784// operator new and delete aren't allowed inside namespaces.
3785
3786/// Placement new for using the ASTContext's allocator.
3787///
3788/// This placement form of operator new uses the ASTContext's allocator for
3789/// obtaining memory.
3790///
3791/// IMPORTANT: These are also declared in clang/AST/ASTContextAllocate.h!
3792/// Any changes here need to also be made there.
3793///
3794/// We intentionally avoid using a nothrow specification here so that the calls
3795/// to this operator will not perform a null check on the result -- the
3796/// underlying allocator never returns null pointers.
3797///
3798/// Usage looks like this (assuming there's an ASTContext 'Context' in scope):
3799/// @code
3800/// // Default alignment (8)
3801/// IntegerLiteral *Ex = new (Context) IntegerLiteral(arguments);
3802/// // Specific alignment
3803/// IntegerLiteral *Ex2 = new (Context, 4) IntegerLiteral(arguments);
3804/// @endcode
3805/// Memory allocated through this placement new operator does not need to be
3806/// explicitly freed, as ASTContext will free all of this memory when it gets
3807/// destroyed. Please note that you cannot use delete on the pointer.
3808///
3809/// @param Bytes The number of bytes to allocate. Calculated by the compiler.
3810/// @param C The ASTContext that provides the allocator.
3811/// @param Alignment The alignment of the allocated memory (if the underlying
3812/// allocator supports it).
3813/// @return The allocated memory. Could be nullptr.
3814inline void *operator new(size_t Bytes, const clang::ASTContext &C,
3815 size_t Alignment /* = 8 */) {
3816 return C.Allocate(Bytes, Alignment);
3817}
3818
3819/// Placement delete companion to the new above.
3820///
3821/// This operator is just a companion to the new above. There is no way of
3822/// invoking it directly; see the new operator for more details. This operator
3823/// is called implicitly by the compiler if a placement new expression using
3824/// the ASTContext throws in the object constructor.
3825inline void operator delete(void *Ptr, const clang::ASTContext &C, size_t) {
3826 C.Deallocate(Ptr);
3827}
3828
3829/// This placement form of operator new[] uses the ASTContext's allocator for
3830/// obtaining memory.
3831///
3832/// We intentionally avoid using a nothrow specification here so that the calls
3833/// to this operator will not perform a null check on the result -- the
3834/// underlying allocator never returns null pointers.
3835///
3836/// Usage looks like this (assuming there's an ASTContext 'Context' in scope):
3837/// @code
3838/// // Default alignment (8)
3839/// char *data = new (Context) char[10];
3840/// // Specific alignment
3841/// char *data = new (Context, 4) char[10];
3842/// @endcode
3843/// Memory allocated through this placement new[] operator does not need to be
3844/// explicitly freed, as ASTContext will free all of this memory when it gets
3845/// destroyed. Please note that you cannot use delete on the pointer.
3846///
3847/// @param Bytes The number of bytes to allocate. Calculated by the compiler.
3848/// @param C The ASTContext that provides the allocator.
3849/// @param Alignment The alignment of the allocated memory (if the underlying
3850/// allocator supports it).
3851/// @return The allocated memory. Could be nullptr.
3852inline void *operator new[](size_t Bytes, const clang::ASTContext& C,
3853 size_t Alignment /* = 8 */) {
3854 return C.Allocate(Bytes, Alignment);
3855}
3856
3857/// Placement delete[] companion to the new[] above.
3858///
3859/// This operator is just a companion to the new[] above. There is no way of
3860/// invoking it directly; see the new[] operator for more details. This operator
3861/// is called implicitly by the compiler if a placement new[] expression using
3862/// the ASTContext throws in the object constructor.
3863inline void operator delete[](void *Ptr, const clang::ASTContext &C, size_t) {
3864 C.Deallocate(Ptr);
3865}
3866
3867/// Create the representation of a LazyGenerationalUpdatePtr.
3868template <typename Owner, typename T,
3869 void (clang::ExternalASTSource::*Update)(Owner)>
3872 const clang::ASTContext &Ctx, T Value) {
3873 // Note, this is implemented here so that ExternalASTSource.h doesn't need to
3874 // include ASTContext.h. We explicitly instantiate it for all relevant types
3875 // in ASTContext.cpp.
3876 if (auto *Source = Ctx.getExternalSource())
3877 return new (Ctx) LazyData(Source, Value);
3878 return Value;
3879}
3880
3881template <> struct llvm::DenseMapInfo<llvm::FoldingSetNodeID> {
3882 static FoldingSetNodeID getEmptyKey() { return FoldingSetNodeID{}; }
3883
3884 static FoldingSetNodeID getTombstoneKey() {
3885 FoldingSetNodeID ID;
3886 for (size_t I = 0; I < sizeof(ID) / sizeof(unsigned); ++I) {
3887 ID.AddInteger(std::numeric_limits<unsigned>::max());
3888 }
3889 return ID;
3890 }
3891
3892 static unsigned getHashValue(const FoldingSetNodeID &Val) {
3893 return Val.ComputeHash();
3894 }
3895
3896 static bool isEqual(const FoldingSetNodeID &LHS,
3897 const FoldingSetNodeID &RHS) {
3898 return LHS == RHS;
3899 }
3900};
3901
3902#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)
Allows QualTypes to be sorted and hence used in maps and sets.
__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:220
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:220
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:833
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:553
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:988
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:945
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:873
DeclListNode * AllocateDeclListNode(clang::NamedDecl *ND)
Allocates a DeclListNode or returns one from the ListNodeFreeList pool.
Definition ASTContext.h:862
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:776
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:688
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:818
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:777
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:556
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:949
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:941
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:852
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:772
Builtin::Context & BuiltinInfo
Definition ASTContext.h:774
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:926
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:677
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:773
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:959
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:887
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:894
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:552
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:842
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
friend class ASTDeclReader
Definition ASTContext.h:551
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:936
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:892
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:555
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:775
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:962
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:221
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:778
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:834
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:825
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:547
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:968
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:846
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:880
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:854
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:891
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:984
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:849
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:975
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:932
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:829
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:5902
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:6814
Attr - This represents one attribute.
Definition Attr.h:44
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition Expr.h:6558
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
Implements C++ ABI-specific semantic analysis functions.
Definition CXXABI.h:29
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
Declaration of a C++20 concept.
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:5032
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:4398
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
ObjCContainerDecl - Represents a container for method declarations.
Definition DeclObjC.h:948
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:5309
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:1799
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:5361
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:4455
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:4037
Represents a C++ using-enum-declaration.
Definition DeclCXX.h:3792
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition DeclCXX.h:3399
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
Declaration of a variable template.
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:559
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:149
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:176
@ None
The alignment was not explicit in code.
Definition ASTContext.h:178
@ RequiredByEnum
The alignment comes from an alignment attribute on a enum type.
Definition ASTContext.h:187
@ RequiredByTypedef
The alignment comes from an alignment attribute on a typedef.
Definition ASTContext.h:181
@ RequiredByRecord
The alignment comes from an alignment attribute on a record type.
Definition ASTContext.h:184
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:790
BuiltinVectorTypeInfo(QualType ElementType, llvm::ElementCount EC, unsigned NumVectors)
CUDAConstantEvalContextRAII(ASTContext &Ctx_, bool NoWrongSidedVars)
Definition ASTContext.h:790
bool NoWrongSidedVars
Do not allow wrong-sided variables in constant expressions.
Definition ASTContext.h:785
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:6604
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:4373
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:207
TypeInfoChars(CharUnits Width, CharUnits Align, AlignRequirementKind AlignRequirement)
Definition ASTContext.h:210
bool isAlignRequired()
Definition ASTContext.h:199
AlignRequirementKind AlignRequirement
Definition ASTContext.h:193
TypeInfo(uint64_t Width, unsigned Align, AlignRequirementKind AlignRequirement)
Definition ASTContext.h:196
static ScalableVecTyKey getTombstoneKey()
Definition ASTContext.h:73
static ScalableVecTyKey getEmptyKey()
Definition ASTContext.h:70
static bool isEqual(const ScalableVecTyKey &LHS, const ScalableVecTyKey &RHS)
Definition ASTContext.h:80
static unsigned getHashValue(const ScalableVecTyKey &Val)
Definition ASTContext.h:76
static bool isEqual(const FoldingSetNodeID &LHS, const FoldingSetNodeID &RHS)
static FoldingSetNodeID getTombstoneKey()
static unsigned getHashValue(const FoldingSetNodeID &Val)
clang::QualType EltTy
Definition ASTContext.h:57
bool operator==(const ScalableVecTyKey &RHS) const
Definition ASTContext.h:61