27#include "llvm/ADT/FoldingSet.h"
28#include "llvm/ADT/iterator.h"
47 assert(RT &&
"type of VarDecl is expected to be RecordType.");
48 assert(RT->
getDecl()->
isUnion() &&
"RecordType is expected to be a union.");
50 return FD->getIdentifier();
57struct DecompositionDeclName {
65 : llvm::iterator_adaptor_base<Iterator, BindingArray::const_iterator,
66 std::random_access_iterator_tag,
67 const IdentifierInfo *> {
68 Iterator(BindingArray::const_iterator It) : iterator_adaptor_base(It) {}
70 return (*this->I)->getIdentifier();
73 Iterator begin()
const {
return Iterator(
Bindings.begin()); }
74 Iterator end()
const {
return Iterator(
Bindings.end()); }
80 return llvm::DenseMapInfo<T>::isEqual(
81 V, llvm::DenseMapInfo<T>::getEmptyKey());
84 return llvm::DenseMapInfo<T>::isEqual(
85 V, llvm::DenseMapInfo<T>::getTombstoneKey());
92 if (LHSEmpty || RHSEmpty)
93 return LHSEmpty && RHSEmpty;
97 if (LHSTombstone || RHSTombstone)
98 return LHSTombstone && RHSTombstone;
104struct DenseMapInfo<DecompositionDeclName> {
105 using ArrayInfo = llvm::DenseMapInfo<ArrayRef<const BindingDecl*>>;
107 return {ArrayInfo::getEmptyKey()};
110 return {ArrayInfo::getTombstoneKey()};
113 assert(!isEqual(Key, getEmptyKey()) && !isEqual(Key, getTombstoneKey()));
114 return llvm::hash_combine_range(Key.begin(), Key.end());
116 static bool isEqual(DecompositionDeclName LHS, DecompositionDeclName RHS) {
117 if (std::optional<bool> Result =
121 return LHS.Bindings.size() == RHS.Bindings.size() &&
122 std::equal(LHS.begin(), LHS.end(), RHS.begin());
133 llvm::StringMap<unsigned> LambdaManglingNumbers;
134 unsigned BlockManglingNumber = 0;
135 llvm::DenseMap<const IdentifierInfo *, unsigned> VarManglingNumbers;
136 llvm::DenseMap<const IdentifierInfo *, unsigned> TagManglingNumbers;
137 llvm::DenseMap<DecompositionDeclName, unsigned>
138 DecompsitionDeclManglingNumbers;
150 llvm::raw_svector_ostream Out(LambdaSig);
153 return ++LambdaManglingNumbers[LambdaSig];
157 return ++BlockManglingNumber;
166 if (
auto *DD = dyn_cast<DecompositionDecl>(VD)) {
167 DecompositionDeclName Name{DD->bindings()};
168 return ++DecompsitionDeclManglingNumbers[Name];
175 Identifier = findAnonymousUnionVarDeclName(*VD);
189class ItaniumSYCLNumberingContext :
public ItaniumNumberingContext {
190 llvm::DenseMap<const CXXMethodDecl *, unsigned> ManglingNumbers;
191 using ManglingItr =
decltype(ManglingNumbers)::iterator;
195 : ItaniumNumberingContext(Mangler) {}
197 unsigned getManglingNumber(
const CXXMethodDecl *CallOperator)
override {
198 unsigned Number = ItaniumNumberingContext::getManglingNumber(CallOperator);
199 std::pair<ManglingItr, bool> emplace_result =
200 ManglingNumbers.try_emplace(CallOperator, Number);
201 (void)emplace_result;
202 assert(emplace_result.second &&
"Lambda number set multiple times?");
206 using ItaniumNumberingContext::getManglingNumber;
208 unsigned getDeviceManglingNumber(
const CXXMethodDecl *CallOperator)
override {
209 ManglingItr Itr = ManglingNumbers.find(CallOperator);
210 assert(Itr != ManglingNumbers.end() &&
"Lambda not yet mangled?");
216class ItaniumCXXABI :
public CXXABI {
218 std::unique_ptr<MangleContext> Mangler;
223 : Mangler(Ctx.createMangleContext()), Context(Ctx) {}
229 MemberPointerInfo MPI;
230 MPI.Width =
Target.getTypeWidth(PtrDiff);
231 MPI.Align =
Target.getTypeAlign(PtrDiff);
232 MPI.HasPadding =
false;
240 if (!isVariadic &&
T.isWindowsGNUEnvironment() &&
241 T.getArch() == llvm::Triple::x86)
282 std::unique_ptr<MangleNumberingContext>
285 return std::make_unique<ItaniumSYCLNumberingContext>(
286 cast<ItaniumMangleContext>(Mangler.get()));
287 return std::make_unique<ItaniumNumberingContext>(
288 cast<ItaniumMangleContext>(Mangler.get()));
294 return new ItaniumCXXABI(Ctx);
297std::unique_ptr<MangleNumberingContext>
299 return std::make_unique<ItaniumNumberingContext>(
300 cast<ItaniumMangleContext>(Mangler));
Defines the clang::ASTContext interface.
clang::CharUnits operator*(clang::CharUnits::QuantityType Scale, const clang::CharUnits &CU)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
llvm::MachO::Target Target
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D,...
const LangOptions & getLangOpts() const
const TargetInfo & getTargetInfo() const
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
CharUnits getNonVirtualSize() const
getNonVirtualSize - Get the non-virtual size (in chars) of an object, which is the size of the object...
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Implements C++ ABI-specific semantic analysis functions.
virtual void addTypedefNameForUnnamedTagDecl(TagDecl *TD, TypedefNameDecl *DD)=0
virtual MemberPointerInfo getMemberPointerInfo(const MemberPointerType *MPT) const =0
Returns the width and alignment of a member pointer in bits, as well as whether it has padding.
virtual std::unique_ptr< MangleNumberingContext > createMangleNumberingContext() const =0
Returns a new mangling number context for this C++ ABI.
virtual CallingConv getDefaultMethodCallConv(bool isVariadic) const =0
Returns the default calling convention for C++ methods.
virtual void addDeclaratorForUnnamedTagDecl(TagDecl *TD, DeclaratorDecl *DD)=0
virtual TypedefNameDecl * getTypedefNameForUnnamedTagDecl(const TagDecl *TD)=0
virtual const CXXConstructorDecl * getCopyConstructorForExceptionObject(CXXRecordDecl *)=0
Retrieves the mapping from class to copy constructor for this C++ ABI.
virtual void addCopyConstructorForExceptionObject(CXXRecordDecl *, CXXConstructorDecl *)=0
Adds a mapping from class to copy constructor for this C++ ABI.
virtual DeclaratorDecl * getDeclaratorForUnnamedTagDecl(const TagDecl *TD)=0
virtual bool isNearlyEmpty(const CXXRecordDecl *RD) const =0
Returns whether the given class is nearly empty, with just virtual pointers and no data except possib...
Represents a C++ constructor within a class.
Represents a static or instance method of a struct/union/class.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Represents a C++ struct/union/class.
bool isLambda() const
Determine whether this class describes a lambda function object.
bool isDynamicClass() const
CharUnits - This is an opaque type for sizes expressed in character units.
Represents a ValueDecl that came out of a declarator.
Represents a member of a struct/union/class.
One of these records is kept for each identifier that is lexed.
virtual void mangleLambdaSig(const CXXRecordDecl *Lambda, raw_ostream &)=0
MangleContext - Context for tracking state which persists across multiple calls to the C++ name mangl...
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
virtual unsigned getManglingNumber(const CXXMethodDecl *CallOperator)=0
Retrieve the mangling number of a new lambda expression with the given call operator within this cont...
virtual unsigned getStaticLocalNumber(const VarDecl *VD)=0
Static locals are numbered by source order.
A pointer to member type per C++ 8.3.3 - Pointers to members.
bool isMemberFunctionPointer() const
Returns true if the member type (i.e.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
const FieldDecl * findFirstNamedDataMember() const
Finds the first data member which has a name.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
Represents the declaration of a struct/union/class/enum.
Exposes information about the current target.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
uint64_t getPointerWidth(LangAS AddrSpace) const
Return the width of pointers on this target, for the specified address space.
virtual CallingConv getDefaultCallingConv() const
Gets the default calling convention for the given target and declaration context.
IntType getPtrDiffType(LangAS AddrSpace) const
const T * getAs() const
Member-template getAs<specific type>'.
Base class for declarations which introduce a typedef-name.
Represents a variable declaration or definition.
Defines the clang::TargetInfo interface.
The JSON file list parser is used to communicate input to InstallAPI.
std::unique_ptr< MangleNumberingContext > createItaniumNumberingContext(MangleContext *)
CXXABI * CreateItaniumCXXABI(ASTContext &Ctx)
Creates an instance of a C++ ABI class.
const FunctionProtoType * T
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Diagnostic wrappers for TextAPI types for error reporting.
bool isDenseMapKeyEmpty(T V)
bool isDenseMapKeyTombstone(T V)
std::optional< bool > areDenseMapKeysEqualSpecialValues(T LHS, T RHS)
IntType
===-— Target Data Type Query Methods ----------------------------—===//
static DecompositionDeclName getTombstoneKey()
llvm::DenseMapInfo< ArrayRef< const BindingDecl * > > ArrayInfo
static DecompositionDeclName getEmptyKey()
static bool isEqual(DecompositionDeclName LHS, DecompositionDeclName RHS)
static unsigned getHashValue(DecompositionDeclName Key)