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