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