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