blob: 1360d522ce7aed79b5fd93088aa7272e5438a4db [file] [log] [blame]
Charles Davis74ce8592010-06-09 23:25:41 +00001//===--- MicrosoftCXXABI.cpp - Emit LLVM Code from ASTs for a Module ------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This provides C++ code generation targetting the Microsoft Visual C++ ABI.
11// The class in this file generates structures that follow the Microsoft
12// Visual C++ ABI, which is actually not very well documented at all outside
13// of Microsoft.
14//
15//===----------------------------------------------------------------------===//
16
17#include "CGCXXABI.h"
18#include "CodeGenModule.h"
19#include "Mangle.h"
20#include "clang/AST/ASTContext.h"
21#include "clang/AST/Decl.h"
22#include "clang/AST/DeclCXX.h"
23#include "clang/AST/DeclTemplate.h"
24#include "clang/AST/ExprCXX.h"
25#include "CGVTables.h"
26
27using namespace clang;
28using namespace CodeGen;
29
30namespace {
31
Charles Davis9af2d4a2010-06-11 03:07:32 +000032/// MicrosoftCXXNameMangler - Manage the mangling of a single name for the
33/// Microsoft Visual C++ ABI.
34class MicrosoftCXXNameMangler {
35 MangleContext &Context;
36 llvm::raw_svector_ostream Out;
37
38 ASTContext &getASTContext() const { return Context.getASTContext(); }
39
40public:
41 MicrosoftCXXNameMangler(MangleContext &C, llvm::SmallVectorImpl<char> &Res)
42 : Context(C), Out(Res) { }
43
44 llvm::raw_svector_ostream &getStream() { return Out; }
45
46 void mangle(const NamedDecl *D, llvm::StringRef Prefix = "?");
47 void mangleName(const NamedDecl *ND);
Charles Davis89338af2010-06-16 05:33:16 +000048 void mangleFunctionEncoding(const FunctionDecl *FD);
Charles Davis2d7b10c2010-06-14 05:29:01 +000049 void mangleVariableEncoding(const VarDecl *VD);
Charles Davis108f5a22010-06-18 07:51:00 +000050 void mangleNumber(int64_t Number);
Charles Davis7dacc952010-06-12 08:11:16 +000051 void mangleType(QualType T);
Charles Davis9af2d4a2010-06-11 03:07:32 +000052
53private:
54 void mangleUnqualifiedName(const NamedDecl *ND) {
55 mangleUnqualifiedName(ND, ND->getDeclName());
56 }
57 void mangleUnqualifiedName(const NamedDecl *ND, DeclarationName Name);
58 void mangleSourceName(const IdentifierInfo *II);
59 void manglePostfix(const DeclContext *DC, bool NoFunction=false);
Charles Davis8c02c132010-06-17 06:47:31 +000060 void mangleOperatorName(OverloadedOperatorKind OO);
Charles Davis2d7b10c2010-06-14 05:29:01 +000061 void mangleQualifiers(Qualifiers Quals, bool IsMember);
Charles Davis9af2d4a2010-06-11 03:07:32 +000062
63 void mangleObjCMethodName(const ObjCMethodDecl *MD);
64
Charles Davis7dacc952010-06-12 08:11:16 +000065 // Declare manglers for every type class.
66#define ABSTRACT_TYPE(CLASS, PARENT)
67#define NON_CANONICAL_TYPE(CLASS, PARENT)
68#define TYPE(CLASS, PARENT) void mangleType(const CLASS##Type *T);
69#include "clang/AST/TypeNodes.def"
70
Charles Davis108f5a22010-06-18 07:51:00 +000071 void mangleType(const TagType*);
Charles Davisf4db33c2010-06-26 03:50:05 +000072 void mangleType(const FunctionType *T, bool IsStructor, bool IsInstMethod);
Charles Davis2a4773072010-06-30 08:09:57 +000073 void mangleType(const ArrayType *T, bool IsGlobal);
74 void mangleExtraDimensions(QualType T);
Charles Davis89338af2010-06-16 05:33:16 +000075 void mangleFunctionClass(const FunctionDecl *FD);
76 void mangleCallingConvention(const FunctionType *T);
77 void mangleThrowSpecification(const FunctionProtoType *T);
78
Charles Davis9af2d4a2010-06-11 03:07:32 +000079};
80
Charles Davis74ce8592010-06-09 23:25:41 +000081/// MicrosoftMangleContext - Overrides the default MangleContext for the
82/// Microsoft Visual C++ ABI.
83class MicrosoftMangleContext : public MangleContext {
84public:
85 MicrosoftMangleContext(ASTContext &Context,
86 Diagnostic &Diags) : MangleContext(Context, Diags) { }
Charles Davisb6a5a0d2010-06-11 04:25:47 +000087 virtual bool shouldMangleDeclName(const NamedDecl *D);
Charles Davis74ce8592010-06-09 23:25:41 +000088 virtual void mangleName(const NamedDecl *D, llvm::SmallVectorImpl<char> &);
89 virtual void mangleThunk(const CXXMethodDecl *MD,
90 const ThunkInfo &Thunk,
91 llvm::SmallVectorImpl<char> &);
92 virtual void mangleCXXDtorThunk(const CXXDestructorDecl *DD, CXXDtorType Type,
93 const ThisAdjustment &ThisAdjustment,
94 llvm::SmallVectorImpl<char> &);
95 virtual void mangleGuardVariable(const VarDecl *D,
96 llvm::SmallVectorImpl<char> &);
97 virtual void mangleCXXVTable(const CXXRecordDecl *RD,
98 llvm::SmallVectorImpl<char> &);
99 virtual void mangleCXXVTT(const CXXRecordDecl *RD,
100 llvm::SmallVectorImpl<char> &);
101 virtual void mangleCXXCtorVTable(const CXXRecordDecl *RD, int64_t Offset,
102 const CXXRecordDecl *Type,
103 llvm::SmallVectorImpl<char> &);
104 virtual void mangleCXXRTTI(QualType T, llvm::SmallVectorImpl<char> &);
105 virtual void mangleCXXRTTIName(QualType T, llvm::SmallVectorImpl<char> &);
106 virtual void mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type,
107 llvm::SmallVectorImpl<char> &);
108 virtual void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type,
109 llvm::SmallVectorImpl<char> &);
110};
111
112class MicrosoftCXXABI : public CXXABI {
113 MicrosoftMangleContext MangleCtx;
114public:
115 MicrosoftCXXABI(CodeGenModule &CGM)
116 : MangleCtx(CGM.getContext(), CGM.getDiags()) {}
117
118 MicrosoftMangleContext &getMangleContext() {
119 return MangleCtx;
120 }
121};
122
123}
124
Charles Davisb6a5a0d2010-06-11 04:25:47 +0000125static bool isInCLinkageSpecification(const Decl *D) {
126 D = D->getCanonicalDecl();
127 for (const DeclContext *DC = D->getDeclContext();
128 !DC->isTranslationUnit(); DC = DC->getParent()) {
129 if (const LinkageSpecDecl *Linkage = dyn_cast<LinkageSpecDecl>(DC))
130 return Linkage->getLanguage() == LinkageSpecDecl::lang_c;
131 }
Charles Davis7dacc952010-06-12 08:11:16 +0000132
Charles Davisb6a5a0d2010-06-11 04:25:47 +0000133 return false;
134}
135
136bool MicrosoftMangleContext::shouldMangleDeclName(const NamedDecl *D) {
137 // In C, functions with no attributes never need to be mangled. Fastpath them.
138 if (!getASTContext().getLangOptions().CPlusPlus && !D->hasAttrs())
139 return false;
140
141 // Any decl can be declared with __asm("foo") on it, and this takes precedence
142 // over all other naming in the .o file.
143 if (D->hasAttr<AsmLabelAttr>())
144 return true;
145
146 // Clang's "overloadable" attribute extension to C/C++ implies name mangling
147 // (always) as does passing a C++ member function and a function
148 // whose name is not a simple identifier.
149 const FunctionDecl *FD = dyn_cast<FunctionDecl>(D);
150 if (FD && (FD->hasAttr<OverloadableAttr>() || isa<CXXMethodDecl>(FD) ||
151 !FD->getDeclName().isIdentifier()))
152 return true;
153
154 // Otherwise, no mangling is done outside C++ mode.
155 if (!getASTContext().getLangOptions().CPlusPlus)
156 return false;
157
Charles Davis7dacc952010-06-12 08:11:16 +0000158 // Variables at global scope with internal linkage are not mangled.
159 if (!FD) {
160 const DeclContext *DC = D->getDeclContext();
161 if (DC->isTranslationUnit() && D->getLinkage() == InternalLinkage)
162 return false;
163 }
164
Charles Davisb6a5a0d2010-06-11 04:25:47 +0000165 // C functions and "main" are not mangled.
166 if ((FD && FD->isMain()) || isInCLinkageSpecification(D))
167 return false;
168
169 return true;
170}
171
Charles Davis9af2d4a2010-06-11 03:07:32 +0000172void MicrosoftCXXNameMangler::mangle(const NamedDecl *D,
173 llvm::StringRef Prefix) {
174 // MSVC doesn't mangle C++ names the same way it mangles extern "C" names.
175 // Therefore it's really important that we don't decorate the
176 // name with leading underscores or leading/trailing at signs. So, emit a
177 // asm marker at the start so we get the name right.
178 Out << '\01'; // LLVM IR Marker for __asm("foo")
179
180 // Any decl can be declared with __asm("foo") on it, and this takes precedence
181 // over all other naming in the .o file.
182 if (const AsmLabelAttr *ALA = D->getAttr<AsmLabelAttr>()) {
183 // If we have an asm name, then we use it as the mangling.
184 Out << ALA->getLabel();
185 return;
186 }
187
Charles Davis89338af2010-06-16 05:33:16 +0000188 // <mangled-name> ::= ? <name> <type-encoding>
Charles Davis9af2d4a2010-06-11 03:07:32 +0000189 Out << Prefix;
190 mangleName(D);
Charles Davis89338af2010-06-16 05:33:16 +0000191 if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
192 mangleFunctionEncoding(FD);
193 else if (const VarDecl *VD = dyn_cast<VarDecl>(D))
Charles Davis2d7b10c2010-06-14 05:29:01 +0000194 mangleVariableEncoding(VD);
Charles Davis89338af2010-06-16 05:33:16 +0000195 // TODO: Fields? Can MSVC even mangle them?
196}
197
198void MicrosoftCXXNameMangler::mangleFunctionEncoding(const FunctionDecl *FD) {
199 // <type-encoding> ::= <function-class> <function-type>
200
201 // Don't mangle in the type if this isn't a decl we should typically mangle.
202 if (!Context.shouldMangleDeclName(FD))
203 return;
204
205 // We should never ever see a FunctionNoProtoType at this point.
206 // We don't even know how to mangle their types anyway :).
Charles Davisf4db33c2010-06-26 03:50:05 +0000207 const FunctionProtoType *FT = cast<FunctionProtoType>(FD->getType());
Charles Davis89338af2010-06-16 05:33:16 +0000208
Charles Davisf4db33c2010-06-26 03:50:05 +0000209 bool InStructor = false, InInstMethod = false;
Charles Davis89338af2010-06-16 05:33:16 +0000210 const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD);
211 if (MD) {
Charles Davisf4db33c2010-06-26 03:50:05 +0000212 if (MD->isInstance())
213 InInstMethod = true;
Charles Davis89338af2010-06-16 05:33:16 +0000214 if (isa<CXXConstructorDecl>(MD) || isa<CXXDestructorDecl>(MD))
215 InStructor = true;
216 }
217
218 // First, the function class.
219 mangleFunctionClass(FD);
220
Charles Davisf4db33c2010-06-26 03:50:05 +0000221 mangleType(FT, InStructor, InInstMethod);
Charles Davis2d7b10c2010-06-14 05:29:01 +0000222}
223
224void MicrosoftCXXNameMangler::mangleVariableEncoding(const VarDecl *VD) {
Charles Davis89338af2010-06-16 05:33:16 +0000225 // <type-encoding> ::= <storage-class> <variable-type>
Charles Davis2d7b10c2010-06-14 05:29:01 +0000226 // <storage-class> ::= 0 # private static member
227 // ::= 1 # protected static member
228 // ::= 2 # public static member
229 // ::= 3 # global
230 // ::= 4 # static local
231
232 // The first character in the encoding (after the name) is the storage class.
233 if (VD->isStaticDataMember()) {
234 // If it's a static member, it also encodes the access level.
235 switch (VD->getAccess()) {
236 default:
237 case AS_private: Out << '0'; break;
238 case AS_protected: Out << '1'; break;
239 case AS_public: Out << '2'; break;
240 }
241 }
242 else if (!VD->isStaticLocal())
243 Out << '3';
244 else
245 Out << '4';
246 // Now mangle the type.
247 // <variable-type> ::= <type> <cvr-qualifiers>
Charles Davis2a4773072010-06-30 08:09:57 +0000248 // ::= <type> A # pointers, references, arrays
Charles Davisf4db33c2010-06-26 03:50:05 +0000249 // Pointers and references are odd. The type of 'int * const foo;' gets
250 // mangled as 'QAHA' instead of 'PAHB', for example.
Charles Davis2d7b10c2010-06-14 05:29:01 +0000251 QualType Ty = VD->getType();
Charles Davisf4db33c2010-06-26 03:50:05 +0000252 if (Ty->isPointerType() || Ty->isReferenceType()) {
253 mangleType(Ty);
254 Out << 'A';
Charles Davis2a4773072010-06-30 08:09:57 +0000255 } else if (Ty->isArrayType()) {
256 // Global arrays are funny, too.
257 mangleType(static_cast<ArrayType *>(Ty.getTypePtr()), true);
258 Out << 'A';
Charles Davisf4db33c2010-06-26 03:50:05 +0000259 } else {
260 mangleType(Ty.getLocalUnqualifiedType());
261 mangleQualifiers(Ty.getLocalQualifiers(), false);
262 }
Charles Davis9af2d4a2010-06-11 03:07:32 +0000263}
264
265void MicrosoftCXXNameMangler::mangleName(const NamedDecl *ND) {
266 // <name> ::= <unscoped-name> {[<named-scope>]+ | [<nested-name>]}? @
267 const DeclContext *DC = ND->getDeclContext();
268
269 // Always start with the unqualified name.
270 mangleUnqualifiedName(ND);
271
272 // If this is an extern variable declared locally, the relevant DeclContext
273 // is that of the containing namespace, or the translation unit.
274 if (isa<FunctionDecl>(DC) && ND->hasLinkage())
275 while (!DC->isNamespace() && !DC->isTranslationUnit())
276 DC = DC->getParent();
277
278 manglePostfix(DC);
279
280 // Terminate the whole name with an '@'.
281 Out << '@';
282}
283
Charles Davis108f5a22010-06-18 07:51:00 +0000284void MicrosoftCXXNameMangler::mangleNumber(int64_t Number) {
285 // <number> ::= [?] <decimal digit> # <= 9
286 // ::= [?] <hex digit>+ @ # > 9; A = 0, B = 1, etc...
287 if (Number < 0) {
288 Out << '?';
289 Number = -Number;
290 }
291 if (Number <= 9) {
292 Out << Number;
293 } else {
294 // We have to build up the encoding in reverse order, so it will come
295 // out right when we write it out.
296 char Encoding[16];
297 char *EndPtr = Encoding+sizeof(Encoding);
298 char *CurPtr = EndPtr;
299 while (Number) {
300 *--CurPtr = 'A' + (Number % 16);
301 Number /= 16;
302 }
303 Out.write(CurPtr, EndPtr-CurPtr);
304 Out << '@';
305 }
306}
307
Charles Davis9af2d4a2010-06-11 03:07:32 +0000308void
309MicrosoftCXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND,
310 DeclarationName Name) {
311 // <unqualified-name> ::= <operator-name>
312 // ::= <ctor-dtor-name>
313 // ::= <source-name>
314 switch (Name.getNameKind()) {
315 case DeclarationName::Identifier: {
316 if (const IdentifierInfo *II = Name.getAsIdentifierInfo()) {
317 mangleSourceName(II);
318 break;
319 }
320
321 // Otherwise, an anonymous entity. We must have a declaration.
322 assert(ND && "mangling empty name without declaration");
323
324 if (const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
325 if (NS->isAnonymousNamespace()) {
326 Out << "?A";
327 break;
328 }
329 }
330
331 // We must have an anonymous struct.
332 const TagDecl *TD = cast<TagDecl>(ND);
333 if (const TypedefDecl *D = TD->getTypedefForAnonDecl()) {
334 assert(TD->getDeclContext() == D->getDeclContext() &&
335 "Typedef should not be in another decl context!");
336 assert(D->getDeclName().getAsIdentifierInfo() &&
337 "Typedef was not named!");
338 mangleSourceName(D->getDeclName().getAsIdentifierInfo());
339 break;
340 }
341
342 // TODO: How does VC mangle anonymous structs?
343 assert(false && "Don't know how to mangle anonymous types yet!");
344 break;
345 }
346
347 case DeclarationName::ObjCZeroArgSelector:
348 case DeclarationName::ObjCOneArgSelector:
349 case DeclarationName::ObjCMultiArgSelector:
350 assert(false && "Can't mangle Objective-C selector names here!");
351 break;
352
353 case DeclarationName::CXXConstructorName:
354 assert(false && "Can't mangle constructors yet!");
355 break;
356
357 case DeclarationName::CXXDestructorName:
358 assert(false && "Can't mangle destructors yet!");
359 break;
360
361 case DeclarationName::CXXConversionFunctionName:
362 // <operator-name> ::= ?B # (cast)
363 // The target type is encoded as the return type.
364 Out << "?B";
365 break;
366
367 case DeclarationName::CXXOperatorName:
Charles Davis8c02c132010-06-17 06:47:31 +0000368 mangleOperatorName(Name.getCXXOverloadedOperator());
369 break;
Charles Davis9af2d4a2010-06-11 03:07:32 +0000370
371 case DeclarationName::CXXLiteralOperatorName:
372 // FIXME: Was this added in VS2010? Does MS even know how to mangle this?
373 assert(false && "Don't know how to mangle literal operators yet!");
374 break;
375
376 case DeclarationName::CXXUsingDirective:
377 assert(false && "Can't mangle a using directive name!");
378 break;
379 }
380}
381
382void MicrosoftCXXNameMangler::manglePostfix(const DeclContext *DC,
383 bool NoFunction) {
384 // <postfix> ::= <unqualified-name> [<postfix>]
385 // ::= <template-postfix> <template-args> [<postfix>]
386 // ::= <template-param>
387 // ::= <substitution> [<postfix>]
388
389 if (!DC) return;
390
391 while (isa<LinkageSpecDecl>(DC))
392 DC = DC->getParent();
393
394 if (DC->isTranslationUnit())
395 return;
396
397 if (const BlockDecl *BD = dyn_cast<BlockDecl>(DC)) {
398 llvm::SmallString<64> Name;
Fariborz Jahanian9b5528d2010-06-24 00:08:06 +0000399 Context.mangleBlock(GlobalDecl(), BD, Name);
Charles Davis9af2d4a2010-06-11 03:07:32 +0000400 Out << Name << '@';
401 return manglePostfix(DC->getParent(), NoFunction);
402 }
403
404 if (NoFunction && (isa<FunctionDecl>(DC) || isa<ObjCMethodDecl>(DC)))
405 return;
406 else if (const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(DC))
407 mangleObjCMethodName(Method);
408 else {
409 mangleUnqualifiedName(cast<NamedDecl>(DC));
410 manglePostfix(DC->getParent(), NoFunction);
411 }
412}
413
Charles Davis8c02c132010-06-17 06:47:31 +0000414void MicrosoftCXXNameMangler::mangleOperatorName(OverloadedOperatorKind OO) {
415 switch (OO) {
416 // ?0 # constructor
417 // ?1 # destructor
418 // <operator-name> ::= ?2 # new
419 case OO_New: Out << "?2"; break;
420 // <operator-name> ::= ?3 # delete
421 case OO_Delete: Out << "?3"; break;
422 // <operator-name> ::= ?4 # =
423 case OO_Equal: Out << "?4"; break;
424 // <operator-name> ::= ?5 # >>
425 case OO_GreaterGreater: Out << "?5"; break;
426 // <operator-name> ::= ?6 # <<
427 case OO_LessLess: Out << "?6"; break;
428 // <operator-name> ::= ?7 # !
429 case OO_Exclaim: Out << "?7"; break;
430 // <operator-name> ::= ?8 # ==
431 case OO_EqualEqual: Out << "?8"; break;
432 // <operator-name> ::= ?9 # !=
433 case OO_ExclaimEqual: Out << "?9"; break;
434 // <operator-name> ::= ?A # []
435 case OO_Subscript: Out << "?A"; break;
436 // ?B # conversion
437 // <operator-name> ::= ?C # ->
438 case OO_Arrow: Out << "?C"; break;
439 // <operator-name> ::= ?D # *
440 case OO_Star: Out << "?D"; break;
441 // <operator-name> ::= ?E # ++
442 case OO_PlusPlus: Out << "?E"; break;
443 // <operator-name> ::= ?F # --
444 case OO_MinusMinus: Out << "?F"; break;
445 // <operator-name> ::= ?G # -
446 case OO_Minus: Out << "?G"; break;
447 // <operator-name> ::= ?H # +
448 case OO_Plus: Out << "?H"; break;
449 // <operator-name> ::= ?I # &
450 case OO_Amp: Out << "?I"; break;
451 // <operator-name> ::= ?J # ->*
452 case OO_ArrowStar: Out << "?J"; break;
453 // <operator-name> ::= ?K # /
454 case OO_Slash: Out << "?K"; break;
455 // <operator-name> ::= ?L # %
456 case OO_Percent: Out << "?L"; break;
457 // <operator-name> ::= ?M # <
458 case OO_Less: Out << "?M"; break;
459 // <operator-name> ::= ?N # <=
460 case OO_LessEqual: Out << "?N"; break;
461 // <operator-name> ::= ?O # >
462 case OO_Greater: Out << "?O"; break;
463 // <operator-name> ::= ?P # >=
464 case OO_GreaterEqual: Out << "?P"; break;
465 // <operator-name> ::= ?Q # ,
466 case OO_Comma: Out << "?Q"; break;
467 // <operator-name> ::= ?R # ()
468 case OO_Call: Out << "?R"; break;
469 // <operator-name> ::= ?S # ~
470 case OO_Tilde: Out << "?S"; break;
471 // <operator-name> ::= ?T # ^
472 case OO_Caret: Out << "?T"; break;
473 // <operator-name> ::= ?U # |
474 case OO_Pipe: Out << "?U"; break;
475 // <operator-name> ::= ?V # &&
476 case OO_AmpAmp: Out << "?V"; break;
477 // <operator-name> ::= ?W # ||
478 case OO_PipePipe: Out << "?W"; break;
479 // <operator-name> ::= ?X # *=
480 case OO_StarEqual: Out << "?X"; break;
481 // <operator-name> ::= ?Y # +=
482 case OO_PlusEqual: Out << "?Y"; break;
483 // <operator-name> ::= ?Z # -=
484 case OO_MinusEqual: Out << "?Z"; break;
485 // <operator-name> ::= ?_0 # /=
486 case OO_SlashEqual: Out << "?_0"; break;
487 // <operator-name> ::= ?_1 # %=
488 case OO_PercentEqual: Out << "?_1"; break;
489 // <operator-name> ::= ?_2 # >>=
490 case OO_GreaterGreaterEqual: Out << "?_2"; break;
491 // <operator-name> ::= ?_3 # <<=
492 case OO_LessLessEqual: Out << "?_3"; break;
493 // <operator-name> ::= ?_4 # &=
494 case OO_AmpEqual: Out << "?_4"; break;
495 // <operator-name> ::= ?_5 # |=
496 case OO_PipeEqual: Out << "?_5"; break;
497 // <operator-name> ::= ?_6 # ^=
498 case OO_CaretEqual: Out << "?_6"; break;
499 // ?_7 # vftable
500 // ?_8 # vbtable
501 // ?_9 # vcall
502 // ?_A # typeof
503 // ?_B # local static guard
504 // ?_C # string
505 // ?_D # vbase destructor
506 // ?_E # vector deleting destructor
507 // ?_F # default constructor closure
508 // ?_G # scalar deleting destructor
509 // ?_H # vector constructor iterator
510 // ?_I # vector destructor iterator
511 // ?_J # vector vbase constructor iterator
512 // ?_K # virtual displacement map
513 // ?_L # eh vector constructor iterator
514 // ?_M # eh vector destructor iterator
515 // ?_N # eh vector vbase constructor iterator
516 // ?_O # copy constructor closure
517 // ?_P<name> # udt returning <name>
518 // ?_Q # <unknown>
519 // ?_R0 # RTTI Type Descriptor
520 // ?_R1 # RTTI Base Class Descriptor at (a,b,c,d)
521 // ?_R2 # RTTI Base Class Array
522 // ?_R3 # RTTI Class Hierarchy Descriptor
523 // ?_R4 # RTTI Complete Object Locator
524 // ?_S # local vftable
525 // ?_T # local vftable constructor closure
526 // <operator-name> ::= ?_U # new[]
527 case OO_Array_New: Out << "?_U"; break;
528 // <operator-name> ::= ?_V # delete[]
529 case OO_Array_Delete: Out << "?_V"; break;
530
531 case OO_Conditional:
532 assert(false && "Don't know how to mangle ?:");
533 break;
534
535 case OO_None:
536 case NUM_OVERLOADED_OPERATORS:
537 assert(false && "Not an overloaded operator");
538 break;
539 }
540}
541
Charles Davis9af2d4a2010-06-11 03:07:32 +0000542void MicrosoftCXXNameMangler::mangleSourceName(const IdentifierInfo *II) {
543 // <source name> ::= <identifier> @
544 Out << II->getName() << '@';
545}
546
547void MicrosoftCXXNameMangler::mangleObjCMethodName(const ObjCMethodDecl *MD) {
548 llvm::SmallString<64> Buffer;
549 MiscNameMangler(Context, Buffer).mangleObjCMethodName(MD);
550 Out << Buffer;
551}
552
Charles Davis2d7b10c2010-06-14 05:29:01 +0000553void MicrosoftCXXNameMangler::mangleQualifiers(Qualifiers Quals,
554 bool IsMember) {
555 // <cvr-qualifiers> ::= [E] [F] [I] <base-cvr-qualifiers>
556 // 'E' means __ptr64 (32-bit only); 'F' means __unaligned (32/64-bit only);
557 // 'I' means __restrict (32/64-bit).
558 // Note that the MSVC __restrict keyword isn't the same as the C99 restrict
559 // keyword!
560 // <base-cvr-qualifiers> ::= A # near
561 // ::= B # near const
562 // ::= C # near volatile
563 // ::= D # near const volatile
564 // ::= E # far (16-bit)
565 // ::= F # far const (16-bit)
566 // ::= G # far volatile (16-bit)
567 // ::= H # far const volatile (16-bit)
568 // ::= I # huge (16-bit)
569 // ::= J # huge const (16-bit)
570 // ::= K # huge volatile (16-bit)
571 // ::= L # huge const volatile (16-bit)
572 // ::= M <basis> # based
573 // ::= N <basis> # based const
574 // ::= O <basis> # based volatile
575 // ::= P <basis> # based const volatile
576 // ::= Q # near member
577 // ::= R # near const member
578 // ::= S # near volatile member
579 // ::= T # near const volatile member
580 // ::= U # far member (16-bit)
581 // ::= V # far const member (16-bit)
582 // ::= W # far volatile member (16-bit)
583 // ::= X # far const volatile member (16-bit)
584 // ::= Y # huge member (16-bit)
585 // ::= Z # huge const member (16-bit)
586 // ::= 0 # huge volatile member (16-bit)
587 // ::= 1 # huge const volatile member (16-bit)
588 // ::= 2 <basis> # based member
589 // ::= 3 <basis> # based const member
590 // ::= 4 <basis> # based volatile member
591 // ::= 5 <basis> # based const volatile member
592 // ::= 6 # near function (pointers only)
593 // ::= 7 # far function (pointers only)
594 // ::= 8 # near method (pointers only)
595 // ::= 9 # far method (pointers only)
596 // ::= _A <basis> # based function (pointers only)
597 // ::= _B <basis> # based function (far?) (pointers only)
598 // ::= _C <basis> # based method (pointers only)
599 // ::= _D <basis> # based method (far?) (pointers only)
600 // <basis> ::= 0 # __based(void)
601 // ::= 1 # __based(segment)?
602 // ::= 2 <name> # __based(name)
603 // ::= 3 # ?
604 // ::= 4 # ?
605 // ::= 5 # not really based
606 if (!IsMember) {
607 if (!Quals.hasVolatile()) {
608 if (!Quals.hasConst())
609 Out << 'A';
610 else
611 Out << 'B';
612 } else {
613 if (!Quals.hasConst())
614 Out << 'C';
615 else
616 Out << 'D';
617 }
618 } else {
619 if (!Quals.hasVolatile()) {
620 if (!Quals.hasConst())
621 Out << 'Q';
622 else
623 Out << 'R';
624 } else {
625 if (!Quals.hasConst())
626 Out << 'S';
627 else
628 Out << 'T';
629 }
630 }
631
632 // FIXME: For now, just drop all extension qualifiers on the floor.
633}
634
Charles Davis7dacc952010-06-12 08:11:16 +0000635void MicrosoftCXXNameMangler::mangleType(QualType T) {
636 // Only operate on the canonical type!
637 T = getASTContext().getCanonicalType(T);
638
Charles Davisf4db33c2010-06-26 03:50:05 +0000639 Qualifiers Quals = T.getLocalQualifiers();
640 if (Quals) {
641 // We have to mangle these now, while we still have enough information.
642 // <pointer-cvr-qualifiers> ::= P # pointer
643 // ::= Q # const pointer
644 // ::= R # volatile pointer
645 // ::= S # const volatile pointer
646 if (T->isPointerType()) {
647 if (!Quals.hasVolatile()) {
648 Out << 'Q';
649 } else {
650 if (!Quals.hasConst())
651 Out << 'R';
652 else
653 Out << 'S';
654 }
655 } else
656 // Just emit qualifiers like normal.
657 // NB: When we mangle a pointer/reference type, and the pointee
658 // type has no qualifiers, the lack of qualifier gets mangled
659 // in there.
660 mangleQualifiers(Quals, false);
661 }
662 else if (T->isPointerType()) {
663 Out << 'P';
664 }
Charles Davis7dacc952010-06-12 08:11:16 +0000665 switch (T->getTypeClass()) {
666#define ABSTRACT_TYPE(CLASS, PARENT)
667#define NON_CANONICAL_TYPE(CLASS, PARENT) \
668case Type::CLASS: \
669llvm_unreachable("can't mangle non-canonical type " #CLASS "Type"); \
670return;
Charles Davis2a4773072010-06-30 08:09:57 +0000671#define TYPE(CLASS, PARENT) \
672case Type::CLASS: \
673mangleType(static_cast<const CLASS##Type*>(T.getTypePtr())); \
674break;
Charles Davis7dacc952010-06-12 08:11:16 +0000675#include "clang/AST/TypeNodes.def"
Charles Davis7dacc952010-06-12 08:11:16 +0000676 }
677}
678
679void MicrosoftCXXNameMangler::mangleType(const BuiltinType *T) {
680 // <type> ::= <builtin-type>
681 // <builtin-type> ::= X # void
682 // ::= C # signed char
683 // ::= D # char
684 // ::= E # unsigned char
685 // ::= F # short
686 // ::= G # unsigned short (or wchar_t if it's not a builtin)
687 // ::= H # int
688 // ::= I # unsigned int
689 // ::= J # long
690 // ::= K # unsigned long
691 // L # <none>
692 // ::= M # float
693 // ::= N # double
694 // ::= O # long double (__float80 is mangled differently)
695 // ::= _D # __int8 (yup, it's a distinct type in MSVC)
696 // ::= _E # unsigned __int8
697 // ::= _F # __int16
698 // ::= _G # unsigned __int16
699 // ::= _H # __int32
700 // ::= _I # unsigned __int32
701 // ::= _J # long long, __int64
702 // ::= _K # unsigned long long, __int64
703 // ::= _L # __int128
704 // ::= _M # unsigned __int128
705 // ::= _N # bool
706 // _O # <array in parameter>
707 // ::= _T # __float80 (Intel)
708 // ::= _W # wchar_t
709 // ::= _Z # __float80 (Digital Mars)
710 switch (T->getKind()) {
711 case BuiltinType::Void: Out << 'X'; break;
712 case BuiltinType::SChar: Out << 'C'; break;
713 case BuiltinType::Char_U: case BuiltinType::Char_S: Out << 'D'; break;
714 case BuiltinType::UChar: Out << 'E'; break;
715 case BuiltinType::Short: Out << 'F'; break;
716 case BuiltinType::UShort: Out << 'G'; break;
717 case BuiltinType::Int: Out << 'H'; break;
718 case BuiltinType::UInt: Out << 'I'; break;
719 case BuiltinType::Long: Out << 'J'; break;
720 case BuiltinType::ULong: Out << 'K'; break;
721 case BuiltinType::Float: Out << 'M'; break;
722 case BuiltinType::Double: Out << 'N'; break;
723 // TODO: Determine size and mangle accordingly
724 case BuiltinType::LongDouble: Out << 'O'; break;
725 // TODO: __int8 and friends
726 case BuiltinType::LongLong: Out << "_J"; break;
727 case BuiltinType::ULongLong: Out << "_K"; break;
728 case BuiltinType::Int128: Out << "_L"; break;
729 case BuiltinType::UInt128: Out << "_M"; break;
730 case BuiltinType::Bool: Out << "_N"; break;
731 case BuiltinType::WChar: Out << "_W"; break;
732
733 case BuiltinType::Overload:
734 case BuiltinType::Dependent:
735 assert(false &&
736 "Overloaded and dependent types shouldn't get to name mangling");
737 break;
738 case BuiltinType::UndeducedAuto:
739 assert(0 && "Should not see undeduced auto here");
740 break;
741 case BuiltinType::ObjCId: Out << "PAUobjc_object@@"; break;
742 case BuiltinType::ObjCClass: Out << "PAUobjc_class@@"; break;
743 case BuiltinType::ObjCSel: Out << "PAUobjc_selector@@"; break;
744
745 case BuiltinType::Char16:
746 case BuiltinType::Char32:
747 case BuiltinType::NullPtr:
748 assert(false && "Don't know how to mangle this type");
749 break;
750 }
751}
752
Charles Davis89338af2010-06-16 05:33:16 +0000753// <type> ::= <function-type>
754void MicrosoftCXXNameMangler::mangleType(const FunctionProtoType *T) {
755 // Structors only appear in decls, so at this point we know it's not a
756 // structor type.
Charles Davis2a4773072010-06-30 08:09:57 +0000757 // I'll probably have mangleType(MemberPointerType) call the mangleType()
758 // method directly.
Charles Davisf4db33c2010-06-26 03:50:05 +0000759 mangleType(T, false, false);
Charles Davis89338af2010-06-16 05:33:16 +0000760}
761void MicrosoftCXXNameMangler::mangleType(const FunctionNoProtoType *T) {
762 llvm_unreachable("Can't mangle K&R function prototypes");
763}
764
765void MicrosoftCXXNameMangler::mangleType(const FunctionType *T,
Charles Davisf4db33c2010-06-26 03:50:05 +0000766 bool IsStructor,
767 bool IsInstMethod) {
768 // <function-type> ::= <this-cvr-qualifiers> <calling-convention>
769 // <return-type> <argument-list> <throw-spec>
Charles Davis89338af2010-06-16 05:33:16 +0000770 const FunctionProtoType *Proto = cast<FunctionProtoType>(T);
771
Charles Davisf4db33c2010-06-26 03:50:05 +0000772 // If this is a C++ instance method, mangle the CVR qualifiers for the
773 // this pointer.
774 if (IsInstMethod)
775 mangleQualifiers(Qualifiers::fromCVRMask(Proto->getTypeQuals()), false);
776
777 mangleCallingConvention(T);
778
779 // <return-type> ::= <type>
780 // ::= @ # structors (they have no declared return type)
Charles Davis89338af2010-06-16 05:33:16 +0000781 if (IsStructor)
782 Out << '@';
783 else
784 mangleType(Proto->getResultType());
785
786 // <argument-list> ::= X # void
787 // ::= <type>+ @
788 // ::= <type>* Z # varargs
789 if (Proto->getNumArgs() == 0 && !Proto->isVariadic()) {
790 Out << 'X';
791 } else {
792 for (FunctionProtoType::arg_type_iterator Arg = Proto->arg_type_begin(),
793 ArgEnd = Proto->arg_type_end();
794 Arg != ArgEnd; ++Arg)
795 mangleType(*Arg);
Charles Davis2a4773072010-06-30 08:09:57 +0000796
Charles Davis89338af2010-06-16 05:33:16 +0000797 // <builtin-type> ::= Z # ellipsis
798 if (Proto->isVariadic())
799 Out << 'Z';
800 else
801 Out << '@';
802 }
803
804 mangleThrowSpecification(Proto);
805}
806
807void MicrosoftCXXNameMangler::mangleFunctionClass(const FunctionDecl *FD) {
808 // <function-class> ::= A # private: near
809 // ::= B # private: far
810 // ::= C # private: static near
811 // ::= D # private: static far
812 // ::= E # private: virtual near
813 // ::= F # private: virtual far
814 // ::= G # private: thunk near
815 // ::= H # private: thunk far
816 // ::= I # protected: near
817 // ::= J # protected: far
818 // ::= K # protected: static near
819 // ::= L # protected: static far
820 // ::= M # protected: virtual near
821 // ::= N # protected: virtual far
822 // ::= O # protected: thunk near
823 // ::= P # protected: thunk far
824 // ::= Q # public: near
825 // ::= R # public: far
826 // ::= S # public: static near
827 // ::= T # public: static far
828 // ::= U # public: virtual near
829 // ::= V # public: virtual far
830 // ::= W # public: thunk near
831 // ::= X # public: thunk far
832 // ::= Y # global near
833 // ::= Z # global far
834 if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
835 switch (MD->getAccess()) {
836 default:
837 case AS_private:
838 if (MD->isStatic())
839 Out << 'C';
840 else if (MD->isVirtual())
841 Out << 'E';
842 else
843 Out << 'A';
844 break;
845 case AS_protected:
846 if (MD->isStatic())
847 Out << 'K';
848 else if (MD->isVirtual())
849 Out << 'M';
850 else
851 Out << 'I';
852 break;
853 case AS_public:
854 if (MD->isStatic())
855 Out << 'S';
856 else if (MD->isVirtual())
857 Out << 'U';
858 else
859 Out << 'Q';
860 }
861 } else
862 Out << 'Y';
863}
864void MicrosoftCXXNameMangler::mangleCallingConvention(const FunctionType *T) {
865 // <calling-convention> ::= A # __cdecl
866 // ::= B # __export __cdecl
867 // ::= C # __pascal
868 // ::= D # __export __pascal
869 // ::= E # __thiscall
870 // ::= F # __export __thiscall
871 // ::= G # __stdcall
872 // ::= H # __export __stdcall
873 // ::= I # __fastcall
874 // ::= J # __export __fastcall
875 // The 'export' calling conventions are from a bygone era
876 // (*cough*Win16*cough*) when functions were declared for export with
877 // that keyword. (It didn't actually export them, it just made them so
878 // that they could be in a DLL and somebody from another module could call
879 // them.)
880 switch (T->getCallConv()) {
881 case CC_Default:
882 case CC_C: Out << 'A'; break;
883 case CC_X86ThisCall: Out << 'E'; break;
884 case CC_X86StdCall: Out << 'G'; break;
885 case CC_X86FastCall: Out << 'I'; break;
886 }
887}
888void MicrosoftCXXNameMangler::mangleThrowSpecification(
889 const FunctionProtoType *FT) {
890 // <throw-spec> ::= Z # throw(...) (default)
891 // ::= @ # throw() or __declspec/__attribute__((nothrow))
892 // ::= <type>+
Charles Davisf4db33c2010-06-26 03:50:05 +0000893 // NOTE: Since the Microsoft compiler ignores throw specifications, they are
894 // all actually mangled as 'Z'. (They're ignored because their associated
895 // functionality isn't implemented, and probably never will be.)
896 Out << 'Z';
Charles Davis89338af2010-06-16 05:33:16 +0000897}
898
Charles Davis2a4773072010-06-30 08:09:57 +0000899void MicrosoftCXXNameMangler::mangleType(const UnresolvedUsingType *T) {
900 assert(false && "Don't know how to mangle UnresolvedUsingTypes yet!");
901}
902
Charles Davis108f5a22010-06-18 07:51:00 +0000903// <type> ::= <union-type> | <struct-type> | <class-type> | <enum-type>
904// <union-type> ::= T <name>
905// <struct-type> ::= U <name>
906// <class-type> ::= V <name>
907// <enum-type> ::= W <size> <name>
908void MicrosoftCXXNameMangler::mangleType(const EnumType *T) {
909 mangleType(static_cast<const TagType*>(T));
910}
911void MicrosoftCXXNameMangler::mangleType(const RecordType *T) {
912 mangleType(static_cast<const TagType*>(T));
913}
914void MicrosoftCXXNameMangler::mangleType(const TagType *T) {
915 switch (T->getDecl()->getTagKind()) {
916 case TTK_Union:
917 Out << 'T';
918 break;
919 case TTK_Struct:
920 Out << 'U';
921 break;
922 case TTK_Class:
923 Out << 'V';
924 break;
925 case TTK_Enum:
926 Out << 'W';
927 mangleNumber(getASTContext().getTypeSizeInChars(
928 cast<EnumDecl>(T->getDecl())->getIntegerType()).getQuantity());
929 break;
930 }
931 mangleName(T->getDecl());
932}
933
Charles Davis2a4773072010-06-30 08:09:57 +0000934// <type> ::= <array-type>
935// <array-type> ::= P <cvr-qualifiers> [Y <dimension-count> <dimension>+]
936// <element-type> # as global
937// ::= Q <cvr-qualifiers> [Y <dimension-count> <dimension>+]
938// <element-type> # as param
939// It's supposed to be the other way around, but for some strange reason, it
940// isn't. Today this behavior is retained for the sole purpose of backwards
941// compatibility.
942void MicrosoftCXXNameMangler::mangleType(const ArrayType *T, bool IsGlobal) {
943 // This isn't a recursive mangling, so now we have to do it all in this
944 // one call.
945 if (IsGlobal)
946 Out << 'P';
947 else
948 Out << 'Q';
949 mangleExtraDimensions(T->getElementType());
950}
951void MicrosoftCXXNameMangler::mangleType(const ConstantArrayType *T) {
952 mangleType(static_cast<const ArrayType *>(T), false);
953}
954void MicrosoftCXXNameMangler::mangleType(const VariableArrayType *T) {
955 mangleType(static_cast<const ArrayType *>(T), false);
956}
957void MicrosoftCXXNameMangler::mangleType(const DependentSizedArrayType *T) {
958 mangleType(static_cast<const ArrayType *>(T), false);
959}
960void MicrosoftCXXNameMangler::mangleType(const IncompleteArrayType *T) {
961 mangleType(static_cast<const ArrayType *>(T), false);
962}
963void MicrosoftCXXNameMangler::mangleExtraDimensions(QualType ElementTy) {
964 llvm::SmallVector<llvm::APInt, 3> Dimensions;
965 for (;;) {
966 if (ElementTy->isConstantArrayType()) {
967 const ConstantArrayType *CAT =
968 static_cast<const ConstantArrayType *>(ElementTy.getTypePtr());
969 Dimensions.push_back(CAT->getSize()-1);
970 ElementTy = CAT->getElementType();
971 } else if (ElementTy->isVariableArrayType()) {
972 assert(false && "Don't know how to mangle VLAs!");
973 } else if (ElementTy->isDependentSizedArrayType()) {
974 // The dependent expression has to be folded into a constant (TODO).
975 assert(false && "Don't know how to mangle dependent-sized arrays!");
976 } else if (ElementTy->isIncompleteArrayType()) continue;
977 else break;
978 }
979 mangleQualifiers(ElementTy.getQualifiers(), false);
980 // If there are any additional dimensions, mangle them now.
981 if (Dimensions.size() > 0) {
982 Out << 'Y';
983 // <dimension-count> ::= <number> # number of extra dimensions minus 1
984 mangleNumber(Dimensions.size()-1);
985 for (unsigned Dim = 0; Dim < Dimensions.size(); ++Dim) {
986 mangleNumber(Dimensions[Dim].getLimitedValue());
987 }
988 }
989 mangleType(ElementTy.getLocalUnqualifiedType());
990}
991
992void MicrosoftCXXNameMangler::mangleType(const MemberPointerType *T) {
993 assert(false && "Don't know how to mangle MemberPointerTypes yet!");
994}
995
996void MicrosoftCXXNameMangler::mangleType(const TemplateTypeParmType *T) {
997 assert(false && "Don't know how to mangle TemplateTypeParmTypes yet!");
998}
999
Charles Davisf4db33c2010-06-26 03:50:05 +00001000// <type> ::= <pointer-type>
1001// <pointer-type> ::= <pointer-cvr-qualifiers> <cvr-qualifiers> <type>
1002void MicrosoftCXXNameMangler::mangleType(const PointerType *T) {
1003 QualType PointeeTy = T->getPointeeType();
Charles Davis2a4773072010-06-30 08:09:57 +00001004 if (PointeeTy->isArrayType()) {
1005 // Pointers to arrays are mangled like arrays.
1006 mangleExtraDimensions(T->getPointeeType());
1007 } else {
1008 if (!PointeeTy.hasQualifiers())
1009 // Lack of qualifiers is mangled as 'A'.
1010 Out << 'A';
1011 mangleType(PointeeTy);
1012 }
1013}
1014void MicrosoftCXXNameMangler::mangleType(const ObjCObjectPointerType *T) {
1015 assert(false && "Don't know how to mangle ObjCObjectPointerTypes yet!");
Charles Davisf4db33c2010-06-26 03:50:05 +00001016}
1017
1018// <type> ::= <reference-type>
1019// <reference-type> ::= A <cvr-qualifiers> <type>
1020void MicrosoftCXXNameMangler::mangleType(const LValueReferenceType *T) {
1021 Out << 'A';
1022 QualType PointeeTy = T->getPointeeType();
Charles Davis2a4773072010-06-30 08:09:57 +00001023 if (!PointeeTy.hasQualifiers())
Charles Davisf4db33c2010-06-26 03:50:05 +00001024 // Lack of qualifiers is mangled as 'A'.
1025 Out << 'A';
1026 mangleType(PointeeTy);
1027}
1028
Charles Davis2a4773072010-06-30 08:09:57 +00001029void MicrosoftCXXNameMangler::mangleType(const RValueReferenceType *T) {
1030 assert(false && "Don't know how to mangle RValueReferenceTypes yet!");
1031}
1032
1033void MicrosoftCXXNameMangler::mangleType(const ComplexType *T) {
1034 assert(false && "Don't know how to mangle ComplexTypes yet!");
1035}
1036
1037void MicrosoftCXXNameMangler::mangleType(const VectorType *T) {
1038 assert(false && "Don't know how to mangle VectorTypes yet!");
1039}
1040void MicrosoftCXXNameMangler::mangleType(const ExtVectorType *T) {
1041 assert(false && "Don't know how to mangle ExtVectorTypes yet!");
1042}
1043void MicrosoftCXXNameMangler::mangleType(const DependentSizedExtVectorType *T) {
1044 assert(false && "Don't know how to mangle DependentSizedExtVectorTypes yet!");
1045}
1046
1047void MicrosoftCXXNameMangler::mangleType(const ObjCInterfaceType *T) {
1048 assert(false && "Don't know how to mangle ObjCInterfaceTypes yet!");
1049}
1050
1051void MicrosoftCXXNameMangler::mangleType(const ObjCObjectType *T) {
1052 assert(false && "Don't know how to mangle ObjCObjectTypes yet!");
1053}
1054
1055void MicrosoftCXXNameMangler::mangleType(const BlockPointerType *T) {
1056 assert(false && "Don't know how to mangle BlockPointerTypes yet!");
1057}
1058
1059void MicrosoftCXXNameMangler::mangleType(const InjectedClassNameType *T) {
1060 assert(false && "Don't know how to mangle InjectedClassNameTypes yet!");
1061}
1062
1063void MicrosoftCXXNameMangler::mangleType(const TemplateSpecializationType *T) {
1064 assert(false && "Don't know how to mangle TemplateSpecializationTypes yet!");
1065}
1066
1067void MicrosoftCXXNameMangler::mangleType(const DependentNameType *T) {
1068 assert(false && "Don't know how to mangle DependentNameTypes yet!");
1069}
1070
1071void MicrosoftCXXNameMangler::mangleType(
1072 const DependentTemplateSpecializationType *T) {
1073 assert(false &&
1074 "Don't know how to mangle DependentTemplateSpecializationTypes yet!");
1075}
1076
1077void MicrosoftCXXNameMangler::mangleType(const TypeOfType *T) {
1078 assert(false && "Don't know how to mangle TypeOfTypes yet!");
1079}
1080
1081void MicrosoftCXXNameMangler::mangleType(const TypeOfExprType *T) {
1082 assert(false && "Don't know how to mangle TypeOfExprTypes yet!");
1083}
1084
1085void MicrosoftCXXNameMangler::mangleType(const DecltypeType *T) {
1086 assert(false && "Don't know how to mangle DecltypeTypes yet!");
1087}
1088
Charles Davis74ce8592010-06-09 23:25:41 +00001089void MicrosoftMangleContext::mangleName(const NamedDecl *D,
1090 llvm::SmallVectorImpl<char> &Name) {
Charles Davis9af2d4a2010-06-11 03:07:32 +00001091 assert((isa<FunctionDecl>(D) || isa<VarDecl>(D)) &&
1092 "Invalid mangleName() call, argument is not a variable or function!");
1093 assert(!isa<CXXConstructorDecl>(D) && !isa<CXXDestructorDecl>(D) &&
1094 "Invalid mangleName() call on 'structor decl!");
1095
1096 PrettyStackTraceDecl CrashInfo(D, SourceLocation(),
1097 getASTContext().getSourceManager(),
1098 "Mangling declaration");
1099
1100 MicrosoftCXXNameMangler Mangler(*this, Name);
1101 return Mangler.mangle(D);
Charles Davis74ce8592010-06-09 23:25:41 +00001102}
1103void MicrosoftMangleContext::mangleThunk(const CXXMethodDecl *MD,
1104 const ThunkInfo &Thunk,
1105 llvm::SmallVectorImpl<char> &) {
1106 assert(false && "Can't yet mangle thunks!");
1107}
1108void MicrosoftMangleContext::mangleCXXDtorThunk(const CXXDestructorDecl *DD,
1109 CXXDtorType Type,
1110 const ThisAdjustment &,
1111 llvm::SmallVectorImpl<char> &) {
1112 assert(false && "Can't yet mangle destructor thunks!");
1113}
1114void MicrosoftMangleContext::mangleGuardVariable(const VarDecl *D,
1115 llvm::SmallVectorImpl<char> &) {
1116 assert(false && "Can't yet mangle guard variables!");
1117}
1118void MicrosoftMangleContext::mangleCXXVTable(const CXXRecordDecl *RD,
1119 llvm::SmallVectorImpl<char> &) {
1120 assert(false && "Can't yet mangle virtual tables!");
1121}
1122void MicrosoftMangleContext::mangleCXXVTT(const CXXRecordDecl *RD,
1123 llvm::SmallVectorImpl<char> &) {
1124 llvm_unreachable("The MS C++ ABI does not have virtual table tables!");
1125}
1126void MicrosoftMangleContext::mangleCXXCtorVTable(const CXXRecordDecl *RD,
1127 int64_t Offset,
1128 const CXXRecordDecl *Type,
1129 llvm::SmallVectorImpl<char> &) {
1130 llvm_unreachable("The MS C++ ABI does not have constructor vtables!");
1131}
1132void MicrosoftMangleContext::mangleCXXRTTI(QualType T,
1133 llvm::SmallVectorImpl<char> &) {
1134 assert(false && "Can't yet mangle RTTI!");
1135}
1136void MicrosoftMangleContext::mangleCXXRTTIName(QualType T,
1137 llvm::SmallVectorImpl<char> &) {
1138 assert(false && "Can't yet mangle RTTI names!");
1139}
1140void MicrosoftMangleContext::mangleCXXCtor(const CXXConstructorDecl *D,
1141 CXXCtorType Type,
1142 llvm::SmallVectorImpl<char> &) {
1143 assert(false && "Can't yet mangle constructors!");
1144}
1145void MicrosoftMangleContext::mangleCXXDtor(const CXXDestructorDecl *D,
1146 CXXDtorType Type,
1147 llvm::SmallVectorImpl<char> &) {
1148 assert(false && "Can't yet mangle destructors!");
1149}
1150
Charles Davis95a546e2010-06-11 01:06:47 +00001151CXXABI *clang::CodeGen::CreateMicrosoftCXXABI(CodeGenModule &CGM) {
Charles Davis74ce8592010-06-09 23:25:41 +00001152 return new MicrosoftCXXABI(CGM);
1153}
1154