14 #ifndef LLVM_CLANG_AST_MANGLE_H 15 #define LLVM_CLANG_AST_MANGLE_H 19 #include "llvm/ADT/DenseMap.h" 20 #include "llvm/Support/Casting.h" 29 class CXXConstructorDecl;
30 class CXXDestructorDecl;
36 struct ThisAdjustment;
50 virtual void anchor();
56 llvm::DenseMap<const BlockDecl*, unsigned> GlobalBlockIds;
57 llvm::DenseMap<const BlockDecl*, unsigned> LocalBlockIds;
58 llvm::DenseMap<const TagDecl*, uint64_t> AnonStructIds;
66 : Context(Context), Diags(Diags), Kind(Kind) {}
77 llvm::DenseMap<const BlockDecl *, unsigned> &BlockIds
78 = Local? LocalBlockIds : GlobalBlockIds;
79 std::pair<llvm::DenseMap<const BlockDecl *, unsigned>::iterator,
bool>
80 Result = BlockIds.insert(std::make_pair(BD, BlockIds.size()));
81 return Result.first->second;
85 std::pair<llvm::DenseMap<const TagDecl *, uint64_t>::iterator,
bool>
86 Result = AnonStructIds.insert(std::make_pair(TD, AnonStructIds.size()));
87 return Result.first->second;
93 bool shouldMangleDeclName(
const NamedDecl *D);
94 virtual bool shouldMangleCXXName(
const NamedDecl *D) = 0;
95 virtual bool shouldMangleStringLiteral(
const StringLiteral *SL) = 0;
98 void mangleName(
const NamedDecl *D, raw_ostream &);
99 virtual void mangleCXXName(
const NamedDecl *D, raw_ostream &) = 0;
106 virtual void mangleReferenceTemporary(
const VarDecl *D,
107 unsigned ManglingNumber,
109 virtual void mangleCXXRTTI(
QualType T, raw_ostream &) = 0;
110 virtual void mangleCXXRTTIName(
QualType T, raw_ostream &) = 0;
115 virtual void mangleStringLiteral(
const StringLiteral *SL, raw_ostream &) = 0;
117 void mangleGlobalBlock(
const BlockDecl *BD,
127 void mangleObjCMethodNameWithoutSize(
const ObjCMethodDecl *MD, raw_ostream &);
128 void mangleObjCMethodName(
const ObjCMethodDecl *MD, raw_ostream &);
130 virtual void mangleStaticGuardVariable(
const VarDecl *D, raw_ostream &) = 0;
132 virtual void mangleDynamicInitializer(
const VarDecl *D, raw_ostream &) = 0;
134 virtual void mangleDynamicAtExitDestructor(
const VarDecl *D,
137 virtual void mangleSEHFilterExpression(
const NamedDecl *EnclosingDecl,
138 raw_ostream &Out) = 0;
140 virtual void mangleSEHFinallyBlock(
const NamedDecl *EnclosingDecl,
141 raw_ostream &Out) = 0;
147 virtual void mangleTypeName(
QualType T, raw_ostream &) = 0;
157 virtual void mangleCXXVTable(
const CXXRecordDecl *RD, raw_ostream &) = 0;
158 virtual void mangleCXXVTT(
const CXXRecordDecl *RD, raw_ostream &) = 0;
162 virtual void mangleItaniumThreadLocalInit(
const VarDecl *D,
164 virtual void mangleItaniumThreadLocalWrapper(
const VarDecl *D,
173 return C->
getKind() == MK_Itanium;
190 raw_ostream &Out) = 0;
197 raw_ostream &Out) = 0;
199 virtual void mangleThreadSafeStaticGuardVariable(
const VarDecl *VD,
201 raw_ostream &Out) = 0;
203 virtual void mangleVirtualMemPtrThunk(
const CXXMethodDecl *MD,
206 virtual void mangleCXXVirtualDisplacementMap(
const CXXRecordDecl *SrcRD,
208 raw_ostream &Out) = 0;
210 virtual void mangleCXXThrowInfo(
QualType T,
bool IsConst,
bool IsVolatile,
211 bool IsUnaligned, uint32_t NumEntries,
212 raw_ostream &Out) = 0;
214 virtual void mangleCXXCatchableTypeArray(
QualType T, uint32_t NumEntries,
215 raw_ostream &Out) = 0;
219 uint32_t NVOffset, int32_t VBPtrOffset,
220 uint32_t VBIndex, raw_ostream &Out) = 0;
222 virtual void mangleCXXRTTIBaseClassDescriptor(
223 const CXXRecordDecl *Derived, uint32_t NVOffset, int32_t VBPtrOffset,
224 uint32_t VBTableOffset, uint32_t Flags, raw_ostream &Out) = 0;
226 virtual void mangleCXXRTTIBaseClassArray(
const CXXRecordDecl *Derived,
227 raw_ostream &Out) = 0;
229 mangleCXXRTTIClassHierarchyDescriptor(
const CXXRecordDecl *Derived,
230 raw_ostream &Out) = 0;
233 mangleCXXRTTICompleteObjectLocator(
const CXXRecordDecl *Derived,
235 raw_ostream &Out) = 0;
238 return C->
getKind() == MK_Microsoft;
A (possibly-)qualified type.
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
C Language Family Type Representation.
The base class of the type hierarchy.
Represents a C++ constructor within a class.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
A this pointer adjustment.
ObjCMethodDecl - Represents an instance or class method declaration.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
The this pointer adjustment as well as an optional return adjustment for a thunk. ...
static bool classof(const MangleContext *C)
Concrete class used by the front-end to report problems and issues.
Enums/classes describing ABI related information about constructors, destructors and thunks...
MangleContext(ASTContext &Context, DiagnosticsEngine &Diags, ManglerKind Kind)
CXXDtorType
C++ destructor types.
ASTContext & getASTContext() const
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
const FunctionProtoType * T
Represents a C++ destructor within a class.
virtual void startNewFunction()
unsigned getBlockId(const BlockDecl *BD, bool Local)
TagDecl - Represents the declaration of a struct/union/class/enum.
Represents a static or instance method of a struct/union/class.
MangleContext - Context for tracking state which persists across multiple calls to the C++ name mangl...
uint64_t getAnonymousStructId(const TagDecl *TD)
CXXCtorType
C++ constructor types.
MicrosoftMangleContext(ASTContext &C, DiagnosticsEngine &D)
Dataflow Directional Tag Classes.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
static bool classof(const MangleContext *C)
DiagnosticsEngine & getDiags() const
std::unique_ptr< DiagnosticConsumer > create(StringRef OutputFile, DiagnosticOptions *Diags, bool MergeChildRecords=false)
Returns a DiagnosticConsumer that serializes diagnostics to a bitcode file.
ItaniumMangleContext(ASTContext &C, DiagnosticsEngine &D)
Represents a C++ struct/union/class.
StringLiteral - This represents a string literal expression, e.g.
NamedDecl - This represents a decl with a name.
ManglerKind getKind() const