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