13#ifndef LLVM_CLANG_AST_MANGLE_H
14#define LLVM_CLANG_AST_MANGLE_H
20#include "llvm/ADT/DenseMap.h"
21#include "llvm/Support/Casting.h"
31 class CXXConstructorDecl;
32 class CXXDestructorDecl;
35 struct MethodVFTableLocation;
39 struct ThisAdjustment;
53 virtual void anchor();
62 llvm::DenseMap<const BlockDecl*, unsigned> GlobalBlockIds;
63 llvm::DenseMap<const BlockDecl*, unsigned> LocalBlockIds;
64 llvm::DenseMap<const NamedDecl*, uint64_t> AnonStructIds;
65 llvm::DenseMap<const FunctionDecl*, unsigned> FuncAnonStructSize;
70 bool isAux()
const {
return IsAux; }
74 : Context(Context), Diags(Diags), Kind(Kind), IsAux(IsAux) {}
85 llvm::DenseMap<const BlockDecl *, unsigned> &BlockIds
86 = Local? LocalBlockIds : GlobalBlockIds;
87 std::pair<llvm::DenseMap<const BlockDecl *, unsigned>::iterator,
bool>
88 Result = BlockIds.insert(std::make_pair(BD, BlockIds.size()));
89 return Result.first->second;
94 auto FindResult = AnonStructIds.find(
D);
95 if (FindResult != AnonStructIds.end())
96 return FindResult->second;
100 unsigned Id = FD ? FuncAnonStructSize[FD]++ : AnonStructIds.size();
101 std::pair<llvm::DenseMap<const NamedDecl *, uint64_t>::iterator,
bool>
102 Result = AnonStructIds.insert(std::make_pair(
D,
Id));
103 return Result.first->second;
107 llvm::DenseMap<const NamedDecl *, uint64_t>::iterator
Result =
108 AnonStructIds.find(
D);
110 if (
Result == AnonStructIds.end())
134 bool ElideOverrideInfo, raw_ostream &) = 0;
137 bool ElideOverrideInfo, raw_ostream &) = 0;
139 unsigned ManglingNumber,
144 bool NormalizeIntegers =
false) = 0;
159 bool includePrefixByte =
true,
160 bool includeCategoryNamespace =
true);
172 raw_ostream &Out) = 0;
175 raw_ostream &Out) = 0;
182 bool NormalizeIntegers =
false) = 0;
241 raw_ostream &Out) = 0;
248 raw_ostream &Out) = 0;
252 raw_ostream &Out) = 0;
256 raw_ostream &Out) = 0;
260 raw_ostream &Out) = 0;
263 bool IsUnaligned, uint32_t NumEntries,
264 raw_ostream &Out) = 0;
267 raw_ostream &Out) = 0;
271 uint32_t NVOffset, int32_t VBPtrOffset,
272 uint32_t VBIndex, raw_ostream &Out) = 0;
275 const CXXRecordDecl *Derived, uint32_t NVOffset, int32_t VBPtrOffset,
276 uint32_t VBTableOffset, uint32_t Flags, raw_ostream &Out) = 0;
279 raw_ostream &Out) = 0;
282 raw_ostream &Out) = 0;
287 raw_ostream &Out) = 0;
315 std::unique_ptr<Implementation> Impl;
Enums/classes describing ABI related information about constructors, destructors and thunks.
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
std::string getName(const Decl *D)
bool writeName(const Decl *D, raw_ostream &OS)
Writes name for D to OS.
std::vector< std::string > getAllManglings(const Decl *D)
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Represents a C++ constructor within a class.
Represents a C++ destructor within a class.
Represents a static or instance method of a struct/union/class.
Represents a C++ struct/union/class.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Decl - This represents one declaration (or definition), e.g.
Concrete class used by the front-end to report problems and issues.
Represents a function declaration or definition.
GlobalDecl - represents a global declaration.
virtual DiscriminatorOverrideTy getDiscriminatorOverride() const =0
virtual void mangleDynamicStermFinalizer(const VarDecl *D, raw_ostream &)=0
virtual void mangleCXXVTT(const CXXRecordDecl *RD, raw_ostream &)=0
ItaniumMangleContext(ASTContext &C, DiagnosticsEngine &D, bool IsAux=false)
virtual void mangleItaniumThreadLocalInit(const VarDecl *D, raw_ostream &)=0
virtual void mangleCXXCtorComdat(const CXXConstructorDecl *D, raw_ostream &)=0
virtual void mangleLambdaSig(const CXXRecordDecl *Lambda, raw_ostream &)=0
virtual void mangleCXXDtorComdat(const CXXDestructorDecl *D, raw_ostream &)=0
virtual void mangleItaniumThreadLocalWrapper(const VarDecl *D, raw_ostream &)=0
static ItaniumMangleContext * create(ASTContext &Context, DiagnosticsEngine &Diags, bool IsAux=false)
virtual void mangleCXXCtorVTable(const CXXRecordDecl *RD, int64_t Offset, const CXXRecordDecl *Type, raw_ostream &)=0
virtual void mangleModuleInitializer(const Module *Module, raw_ostream &)=0
std::optional< unsigned >(*)(ASTContext &, const NamedDecl *) DiscriminatorOverrideTy
static bool classof(const MangleContext *C)
MangleContext - Context for tracking state which persists across multiple calls to the C++ name mangl...
void mangleBlock(const DeclContext *DC, const BlockDecl *BD, raw_ostream &Out)
virtual void mangleCXXDtorThunk(const CXXDestructorDecl *DD, CXXDtorType Type, const ThunkInfo &Thunk, bool ElideOverrideInfo, raw_ostream &)=0
virtual void mangleCXXRTTI(QualType T, raw_ostream &)=0
unsigned getBlockId(const BlockDecl *BD, bool Local)
virtual std::string getLambdaString(const CXXRecordDecl *Lambda)=0
virtual bool shouldMangleStringLiteral(const StringLiteral *SL)=0
void mangleCtorBlock(const CXXConstructorDecl *CD, CXXCtorType CT, const BlockDecl *BD, raw_ostream &Out)
ASTContext & getASTContext() const
uint64_t getAnonymousStructIdForDebugInfo(const NamedDecl *D)
virtual void mangleDynamicAtExitDestructor(const VarDecl *D, raw_ostream &)=0
void mangleGlobalBlock(const BlockDecl *BD, const NamedDecl *ID, raw_ostream &Out)
virtual bool isUniqueInternalLinkageDecl(const NamedDecl *ND)
uint64_t getAnonymousStructId(const NamedDecl *D, const FunctionDecl *FD=nullptr)
bool shouldMangleDeclName(const NamedDecl *D)
virtual void mangleSEHFilterExpression(GlobalDecl EnclosingDecl, raw_ostream &Out)=0
virtual void mangleThunk(const CXXMethodDecl *MD, const ThunkInfo &Thunk, bool ElideOverrideInfo, raw_ostream &)=0
void mangleName(GlobalDecl GD, raw_ostream &)
virtual void mangleCanonicalTypeName(QualType T, raw_ostream &, bool NormalizeIntegers=false)=0
Generates a unique string for an externally visible type for use with TBAA or type uniquing.
void mangleObjCMethodNameAsSourceName(const ObjCMethodDecl *MD, raw_ostream &)
virtual void mangleStringLiteral(const StringLiteral *SL, raw_ostream &)=0
virtual void mangleCXXName(GlobalDecl GD, raw_ostream &)=0
ManglerKind getKind() const
virtual void needsUniqueInternalLinkageNames()
virtual void mangleReferenceTemporary(const VarDecl *D, unsigned ManglingNumber, raw_ostream &)=0
virtual void startNewFunction()
DiagnosticsEngine & getDiags() const
virtual bool shouldMangleCXXName(const NamedDecl *D)=0
virtual void mangleCXXRTTIName(QualType T, raw_ostream &, bool NormalizeIntegers=false)=0
virtual void mangleDynamicInitializer(const VarDecl *D, raw_ostream &)=0
void mangleObjCMethodName(const ObjCMethodDecl *MD, raw_ostream &OS, bool includePrefixByte=true, bool includeCategoryNamespace=true)
void mangleDtorBlock(const CXXDestructorDecl *CD, CXXDtorType DT, const BlockDecl *BD, raw_ostream &Out)
virtual void mangleMSGuidDecl(const MSGuidDecl *GD, raw_ostream &)
virtual void mangleCXXVTable(const CXXRecordDecl *RD, raw_ostream &)=0
MangleContext(ASTContext &Context, DiagnosticsEngine &Diags, ManglerKind Kind, bool IsAux=false)
virtual void mangleSEHFinallyBlock(GlobalDecl EnclosingDecl, raw_ostream &Out)=0
virtual void mangleStaticGuardVariable(const VarDecl *D, raw_ostream &)=0
virtual void mangleCXXVFTable(const CXXRecordDecl *Derived, ArrayRef< const CXXRecordDecl * > BasePath, raw_ostream &Out)=0
Mangle vftable symbols.
virtual void mangleVirtualMemPtrThunk(const CXXMethodDecl *MD, const MethodVFTableLocation &ML, raw_ostream &Out)=0
virtual void mangleCXXRTTICompleteObjectLocator(const CXXRecordDecl *Derived, ArrayRef< const CXXRecordDecl * > BasePath, raw_ostream &Out)=0
virtual void mangleCXXThrowInfo(QualType T, bool IsConst, bool IsVolatile, bool IsUnaligned, uint32_t NumEntries, raw_ostream &Out)=0
static bool classof(const MangleContext *C)
virtual void mangleCXXVBTable(const CXXRecordDecl *Derived, ArrayRef< const CXXRecordDecl * > BasePath, raw_ostream &Out)=0
Mangle vbtable symbols.
virtual void mangleCXXRTTIClassHierarchyDescriptor(const CXXRecordDecl *Derived, raw_ostream &Out)=0
virtual void mangleThreadSafeStaticGuardVariable(const VarDecl *VD, unsigned GuardNum, raw_ostream &Out)=0
static MicrosoftMangleContext * create(ASTContext &Context, DiagnosticsEngine &Diags, bool IsAux=false)
virtual void mangleCXXCatchableTypeArray(QualType T, uint32_t NumEntries, raw_ostream &Out)=0
virtual void mangleCXXRTTIBaseClassDescriptor(const CXXRecordDecl *Derived, uint32_t NVOffset, int32_t VBPtrOffset, uint32_t VBTableOffset, uint32_t Flags, raw_ostream &Out)=0
virtual void mangleCXXCatchableType(QualType T, const CXXConstructorDecl *CD, CXXCtorType CT, uint32_t Size, uint32_t NVOffset, int32_t VBPtrOffset, uint32_t VBIndex, raw_ostream &Out)=0
virtual void mangleCXXRTTIBaseClassArray(const CXXRecordDecl *Derived, raw_ostream &Out)=0
virtual void mangleCXXVirtualDisplacementMap(const CXXRecordDecl *SrcRD, const CXXRecordDecl *DstRD, raw_ostream &Out)=0
MicrosoftMangleContext(ASTContext &C, DiagnosticsEngine &D, bool IsAux=false)
Describes a module or submodule.
This represents a decl that may have a name.
ObjCMethodDecl - Represents an instance or class method declaration.
A (possibly-)qualified type.
StringLiteral - This represents a string literal expression, e.g.
The base class of the type hierarchy.
Represents a variable declaration or definition.
The JSON file list parser is used to communicate input to InstallAPI.
CXXCtorType
C++ constructor types.
@ Result
The result type of a method or function.
CXXDtorType
C++ destructor types.
const FunctionProtoType * T
Diagnostic wrappers for TextAPI types for error reporting.
The this pointer adjustment as well as an optional return adjustment for a thunk.