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