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 | |
Charles Davis | e60cea8 | 2010-06-11 03:07:32 +0000 | [diff] [blame] | 44 | void mangle(const NamedDecl *D, llvm::StringRef Prefix = "?"); |
| 45 | void mangleName(const NamedDecl *ND); |
Charles Davis | 65161d1 | 2010-06-16 05:33:16 +0000 | [diff] [blame] | 46 | void mangleFunctionEncoding(const FunctionDecl *FD); |
Charles Davis | b021f8b | 2010-06-14 05:29:01 +0000 | [diff] [blame] | 47 | void mangleVariableEncoding(const VarDecl *VD); |
Charles Davis | c62458f | 2010-06-18 07:51:00 +0000 | [diff] [blame] | 48 | void mangleNumber(int64_t Number); |
Charles Davis | 570d276 | 2010-06-12 08:11:16 +0000 | [diff] [blame] | 49 | void mangleType(QualType T); |
Charles Davis | e60cea8 | 2010-06-11 03:07:32 +0000 | [diff] [blame] | 50 | |
| 51 | private: |
| 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); |
Charles Davis | 21e2a7e | 2010-06-17 06:47:31 +0000 | [diff] [blame] | 58 | void mangleOperatorName(OverloadedOperatorKind OO); |
Charles Davis | b021f8b | 2010-06-14 05:29:01 +0000 | [diff] [blame] | 59 | void mangleQualifiers(Qualifiers Quals, bool IsMember); |
Charles Davis | e60cea8 | 2010-06-11 03:07:32 +0000 | [diff] [blame] | 60 | |
| 61 | void mangleObjCMethodName(const ObjCMethodDecl *MD); |
| 62 | |
Charles Davis | 570d276 | 2010-06-12 08:11:16 +0000 | [diff] [blame] | 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 | |
Charles Davis | c62458f | 2010-06-18 07:51:00 +0000 | [diff] [blame] | 69 | void mangleType(const TagType*); |
Charles Davis | 4f0a337 | 2010-07-03 02:41:45 +0000 | [diff] [blame] | 70 | void mangleType(const FunctionType *T, const FunctionDecl *D, |
| 71 | bool IsStructor, bool IsInstMethod); |
Charles Davis | 0b8fe8c | 2010-06-30 08:09:57 +0000 | [diff] [blame] | 72 | void mangleType(const ArrayType *T, bool IsGlobal); |
| 73 | void mangleExtraDimensions(QualType T); |
Charles Davis | 65161d1 | 2010-06-16 05:33:16 +0000 | [diff] [blame] | 74 | void mangleFunctionClass(const FunctionDecl *FD); |
| 75 | void mangleCallingConvention(const FunctionType *T); |
| 76 | void mangleThrowSpecification(const FunctionProtoType *T); |
| 77 | |
Charles Davis | e60cea8 | 2010-06-11 03:07:32 +0000 | [diff] [blame] | 78 | }; |
| 79 | |
Charles Davis | c392664 | 2010-06-09 23:25:41 +0000 | [diff] [blame] | 80 | /// MicrosoftMangleContext - Overrides the default MangleContext for the |
| 81 | /// Microsoft Visual C++ ABI. |
| 82 | class MicrosoftMangleContext : public MangleContext { |
| 83 | public: |
| 84 | MicrosoftMangleContext(ASTContext &Context, |
| 85 | Diagnostic &Diags) : MangleContext(Context, Diags) { } |
Charles Davis | 971154d | 2010-06-11 04:25:47 +0000 | [diff] [blame] | 86 | virtual bool shouldMangleDeclName(const NamedDecl *D); |
Charles Davis | c392664 | 2010-06-09 23:25:41 +0000 | [diff] [blame] | 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> &); |
Charles Davis | c392664 | 2010-06-09 23:25:41 +0000 | [diff] [blame] | 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 | |
Charles Davis | 071cc7d | 2010-08-16 03:33:14 +0000 | [diff] [blame] | 109 | class MicrosoftCXXABI : public CGCXXABI { |
Charles Davis | c392664 | 2010-06-09 23:25:41 +0000 | [diff] [blame] | 110 | MicrosoftMangleContext MangleCtx; |
| 111 | public: |
| 112 | MicrosoftCXXABI(CodeGenModule &CGM) |
John McCall | d608cdb | 2010-08-22 10:59:02 +0000 | [diff] [blame] | 113 | : CGCXXABI(CGM), MangleCtx(CGM.getContext(), CGM.getDiags()) {} |
Charles Davis | c392664 | 2010-06-09 23:25:41 +0000 | [diff] [blame] | 114 | |
| 115 | MicrosoftMangleContext &getMangleContext() { |
| 116 | return MangleCtx; |
| 117 | } |
John McCall | 4c40d98 | 2010-08-31 07:33:07 +0000 | [diff] [blame] | 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 | } |
Charles Davis | c392664 | 2010-06-09 23:25:41 +0000 | [diff] [blame] | 146 | }; |
| 147 | |
| 148 | } |
| 149 | |
Charles Davis | 971154d | 2010-06-11 04:25:47 +0000 | [diff] [blame] | 150 | static 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 | } |
Charles Davis | 570d276 | 2010-06-12 08:11:16 +0000 | [diff] [blame] | 157 | |
Charles Davis | 971154d | 2010-06-11 04:25:47 +0000 | [diff] [blame] | 158 | return false; |
| 159 | } |
| 160 | |
| 161 | bool 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 | |
Charles Davis | 570d276 | 2010-06-12 08:11:16 +0000 | [diff] [blame] | 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 | |
Charles Davis | 971154d | 2010-06-11 04:25:47 +0000 | [diff] [blame] | 190 | // C functions and "main" are not mangled. |
| 191 | if ((FD && FD->isMain()) || isInCLinkageSpecification(D)) |
| 192 | return false; |
| 193 | |
| 194 | return true; |
| 195 | } |
| 196 | |
Charles Davis | e60cea8 | 2010-06-11 03:07:32 +0000 | [diff] [blame] | 197 | void 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 | |
Charles Davis | 65161d1 | 2010-06-16 05:33:16 +0000 | [diff] [blame] | 213 | // <mangled-name> ::= ? <name> <type-encoding> |
Charles Davis | e60cea8 | 2010-06-11 03:07:32 +0000 | [diff] [blame] | 214 | Out << Prefix; |
| 215 | mangleName(D); |
Charles Davis | 65161d1 | 2010-06-16 05:33:16 +0000 | [diff] [blame] | 216 | if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) |
| 217 | mangleFunctionEncoding(FD); |
| 218 | else if (const VarDecl *VD = dyn_cast<VarDecl>(D)) |
Charles Davis | b021f8b | 2010-06-14 05:29:01 +0000 | [diff] [blame] | 219 | mangleVariableEncoding(VD); |
Charles Davis | 65161d1 | 2010-06-16 05:33:16 +0000 | [diff] [blame] | 220 | // TODO: Fields? Can MSVC even mangle them? |
| 221 | } |
| 222 | |
| 223 | void 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 :). |
Charles Davis | 3a0d41d | 2010-06-26 03:50:05 +0000 | [diff] [blame] | 232 | const FunctionProtoType *FT = cast<FunctionProtoType>(FD->getType()); |
Charles Davis | 65161d1 | 2010-06-16 05:33:16 +0000 | [diff] [blame] | 233 | |
Charles Davis | 3a0d41d | 2010-06-26 03:50:05 +0000 | [diff] [blame] | 234 | bool InStructor = false, InInstMethod = false; |
Charles Davis | 65161d1 | 2010-06-16 05:33:16 +0000 | [diff] [blame] | 235 | const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD); |
| 236 | if (MD) { |
Charles Davis | 3a0d41d | 2010-06-26 03:50:05 +0000 | [diff] [blame] | 237 | if (MD->isInstance()) |
| 238 | InInstMethod = true; |
Charles Davis | 65161d1 | 2010-06-16 05:33:16 +0000 | [diff] [blame] | 239 | if (isa<CXXConstructorDecl>(MD) || isa<CXXDestructorDecl>(MD)) |
| 240 | InStructor = true; |
| 241 | } |
| 242 | |
| 243 | // First, the function class. |
| 244 | mangleFunctionClass(FD); |
| 245 | |
Charles Davis | 4f0a337 | 2010-07-03 02:41:45 +0000 | [diff] [blame] | 246 | mangleType(FT, FD, InStructor, InInstMethod); |
Charles Davis | b021f8b | 2010-06-14 05:29:01 +0000 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | void MicrosoftCXXNameMangler::mangleVariableEncoding(const VarDecl *VD) { |
Charles Davis | 65161d1 | 2010-06-16 05:33:16 +0000 | [diff] [blame] | 250 | // <type-encoding> ::= <storage-class> <variable-type> |
Charles Davis | b021f8b | 2010-06-14 05:29:01 +0000 | [diff] [blame] | 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> |
Charles Davis | 0b8fe8c | 2010-06-30 08:09:57 +0000 | [diff] [blame] | 273 | // ::= <type> A # pointers, references, arrays |
Charles Davis | 3a0d41d | 2010-06-26 03:50:05 +0000 | [diff] [blame] | 274 | // Pointers and references are odd. The type of 'int * const foo;' gets |
| 275 | // mangled as 'QAHA' instead of 'PAHB', for example. |
Charles Davis | b021f8b | 2010-06-14 05:29:01 +0000 | [diff] [blame] | 276 | QualType Ty = VD->getType(); |
Charles Davis | 3a0d41d | 2010-06-26 03:50:05 +0000 | [diff] [blame] | 277 | if (Ty->isPointerType() || Ty->isReferenceType()) { |
| 278 | mangleType(Ty); |
| 279 | Out << 'A'; |
Charles Davis | 0b8fe8c | 2010-06-30 08:09:57 +0000 | [diff] [blame] | 280 | } else if (Ty->isArrayType()) { |
| 281 | // Global arrays are funny, too. |
| 282 | mangleType(static_cast<ArrayType *>(Ty.getTypePtr()), true); |
| 283 | Out << 'A'; |
Charles Davis | 3a0d41d | 2010-06-26 03:50:05 +0000 | [diff] [blame] | 284 | } else { |
| 285 | mangleType(Ty.getLocalUnqualifiedType()); |
| 286 | mangleQualifiers(Ty.getLocalQualifiers(), false); |
| 287 | } |
Charles Davis | e60cea8 | 2010-06-11 03:07:32 +0000 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | void 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 | |
Charles Davis | c62458f | 2010-06-18 07:51:00 +0000 | [diff] [blame] | 309 | void 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 | } |
Charles Davis | 0877826 | 2010-07-03 08:15:16 +0000 | [diff] [blame] | 316 | if (Number >= 1 && Number <= 10) { |
| 317 | Out << Number-1; |
Charles Davis | c62458f | 2010-06-18 07:51:00 +0000 | [diff] [blame] | 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 | |
Charles Davis | e60cea8 | 2010-06-11 03:07:32 +0000 | [diff] [blame] | 333 | void |
| 334 | MicrosoftCXXNameMangler::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 | |
Charles Davis | 4f0a337 | 2010-07-03 02:41:45 +0000 | [diff] [blame] | 367 | // When VC encounters an anonymous type with no tag and no typedef, |
| 368 | // it literally emits '<unnamed-tag>'. |
| 369 | Out << "<unnamed-tag>"; |
Charles Davis | e60cea8 | 2010-06-11 03:07:32 +0000 | [diff] [blame] | 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: |
Charles Davis | 21e2a7e | 2010-06-17 06:47:31 +0000 | [diff] [blame] | 394 | mangleOperatorName(Name.getCXXOverloadedOperator()); |
| 395 | break; |
Charles Davis | e60cea8 | 2010-06-11 03:07:32 +0000 | [diff] [blame] | 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 | |
| 408 | void 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; |
Fariborz Jahanian | 564360b | 2010-06-24 00:08:06 +0000 | [diff] [blame] | 425 | Context.mangleBlock(GlobalDecl(), BD, Name); |
Charles Davis | e60cea8 | 2010-06-11 03:07:32 +0000 | [diff] [blame] | 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 | |
Charles Davis | 21e2a7e | 2010-06-17 06:47:31 +0000 | [diff] [blame] | 440 | void 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 | |
Charles Davis | e60cea8 | 2010-06-11 03:07:32 +0000 | [diff] [blame] | 568 | void MicrosoftCXXNameMangler::mangleSourceName(const IdentifierInfo *II) { |
| 569 | // <source name> ::= <identifier> @ |
| 570 | Out << II->getName() << '@'; |
| 571 | } |
| 572 | |
| 573 | void MicrosoftCXXNameMangler::mangleObjCMethodName(const ObjCMethodDecl *MD) { |
| 574 | llvm::SmallString<64> Buffer; |
| 575 | MiscNameMangler(Context, Buffer).mangleObjCMethodName(MD); |
| 576 | Out << Buffer; |
| 577 | } |
| 578 | |
Charles Davis | b021f8b | 2010-06-14 05:29:01 +0000 | [diff] [blame] | 579 | void 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) |
Charles Davis | 4d25483 | 2010-07-03 16:56:59 +0000 | [diff] [blame] | 626 | // ::= _E # block (Clang) |
Charles Davis | b021f8b | 2010-06-14 05:29:01 +0000 | [diff] [blame] | 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 | |
Charles Davis | 570d276 | 2010-06-12 08:11:16 +0000 | [diff] [blame] | 662 | void MicrosoftCXXNameMangler::mangleType(QualType T) { |
| 663 | // Only operate on the canonical type! |
| 664 | T = getASTContext().getCanonicalType(T); |
| 665 | |
Charles Davis | 3a0d41d | 2010-06-26 03:50:05 +0000 | [diff] [blame] | 666 | Qualifiers Quals = T.getLocalQualifiers(); |
| 667 | if (Quals) { |
| 668 | // We have to mangle these now, while we still have enough information. |
Charles Davis | 4d25483 | 2010-07-03 16:56:59 +0000 | [diff] [blame] | 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()) |
Charles Davis | 3a0d41d | 2010-06-26 03:50:05 +0000 | [diff] [blame] | 676 | Out << 'Q'; |
Charles Davis | 4d25483 | 2010-07-03 16:56:59 +0000 | [diff] [blame] | 677 | else { |
Charles Davis | 3a0d41d | 2010-06-26 03:50:05 +0000 | [diff] [blame] | 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); |
Charles Davis | 4d25483 | 2010-07-03 16:56:59 +0000 | [diff] [blame] | 689 | } else if (T->isAnyPointerType() || T->isMemberPointerType() || |
| 690 | T->isBlockPointerType()) { |
Charles Davis | 3a0d41d | 2010-06-26 03:50:05 +0000 | [diff] [blame] | 691 | Out << 'P'; |
| 692 | } |
Charles Davis | 570d276 | 2010-06-12 08:11:16 +0000 | [diff] [blame] | 693 | switch (T->getTypeClass()) { |
| 694 | #define ABSTRACT_TYPE(CLASS, PARENT) |
| 695 | #define NON_CANONICAL_TYPE(CLASS, PARENT) \ |
| 696 | case Type::CLASS: \ |
| 697 | llvm_unreachable("can't mangle non-canonical type " #CLASS "Type"); \ |
| 698 | return; |
Charles Davis | 0b8fe8c | 2010-06-30 08:09:57 +0000 | [diff] [blame] | 699 | #define TYPE(CLASS, PARENT) \ |
| 700 | case Type::CLASS: \ |
| 701 | mangleType(static_cast<const CLASS##Type*>(T.getTypePtr())); \ |
| 702 | break; |
Charles Davis | 570d276 | 2010-06-12 08:11:16 +0000 | [diff] [blame] | 703 | #include "clang/AST/TypeNodes.def" |
Charles Davis | 570d276 | 2010-06-12 08:11:16 +0000 | [diff] [blame] | 704 | } |
| 705 | } |
| 706 | |
| 707 | void 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 | |
Charles Davis | 65161d1 | 2010-06-16 05:33:16 +0000 | [diff] [blame] | 781 | // <type> ::= <function-type> |
| 782 | void MicrosoftCXXNameMangler::mangleType(const FunctionProtoType *T) { |
| 783 | // Structors only appear in decls, so at this point we know it's not a |
| 784 | // structor type. |
Charles Davis | 0b8fe8c | 2010-06-30 08:09:57 +0000 | [diff] [blame] | 785 | // I'll probably have mangleType(MemberPointerType) call the mangleType() |
| 786 | // method directly. |
Charles Davis | 4f0a337 | 2010-07-03 02:41:45 +0000 | [diff] [blame] | 787 | mangleType(T, NULL, false, false); |
Charles Davis | 65161d1 | 2010-06-16 05:33:16 +0000 | [diff] [blame] | 788 | } |
| 789 | void MicrosoftCXXNameMangler::mangleType(const FunctionNoProtoType *T) { |
| 790 | llvm_unreachable("Can't mangle K&R function prototypes"); |
| 791 | } |
| 792 | |
| 793 | void MicrosoftCXXNameMangler::mangleType(const FunctionType *T, |
Charles Davis | 4f0a337 | 2010-07-03 02:41:45 +0000 | [diff] [blame] | 794 | const FunctionDecl *D, |
Charles Davis | 3a0d41d | 2010-06-26 03:50:05 +0000 | [diff] [blame] | 795 | bool IsStructor, |
| 796 | bool IsInstMethod) { |
| 797 | // <function-type> ::= <this-cvr-qualifiers> <calling-convention> |
| 798 | // <return-type> <argument-list> <throw-spec> |
Charles Davis | 65161d1 | 2010-06-16 05:33:16 +0000 | [diff] [blame] | 799 | const FunctionProtoType *Proto = cast<FunctionProtoType>(T); |
| 800 | |
Charles Davis | 3a0d41d | 2010-06-26 03:50:05 +0000 | [diff] [blame] | 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); |
| 807 | |
| 808 | // <return-type> ::= <type> |
| 809 | // ::= @ # structors (they have no declared return type) |
Charles Davis | 65161d1 | 2010-06-16 05:33:16 +0000 | [diff] [blame] | 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 { |
Charles Davis | 4f0a337 | 2010-07-03 02:41:45 +0000 | [diff] [blame] | 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 | } |
Charles Davis | 65161d1 | 2010-06-16 05:33:16 +0000 | [diff] [blame] | 834 | // <builtin-type> ::= Z # ellipsis |
| 835 | if (Proto->isVariadic()) |
| 836 | Out << 'Z'; |
| 837 | else |
| 838 | Out << '@'; |
| 839 | } |
| 840 | |
| 841 | mangleThrowSpecification(Proto); |
| 842 | } |
| 843 | |
| 844 | void 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 | } |
| 901 | void MicrosoftCXXNameMangler::mangleCallingConvention(const FunctionType *T) { |
| 902 | // <calling-convention> ::= A # __cdecl |
| 903 | // ::= B # __export __cdecl |
| 904 | // ::= C # __pascal |
| 905 | // ::= D # __export __pascal |
| 906 | // ::= E # __thiscall |
| 907 | // ::= F # __export __thiscall |
| 908 | // ::= G # __stdcall |
| 909 | // ::= H # __export __stdcall |
| 910 | // ::= I # __fastcall |
| 911 | // ::= J # __export __fastcall |
| 912 | // The 'export' calling conventions are from a bygone era |
| 913 | // (*cough*Win16*cough*) when functions were declared for export with |
| 914 | // that keyword. (It didn't actually export them, it just made them so |
| 915 | // that they could be in a DLL and somebody from another module could call |
| 916 | // them.) |
| 917 | switch (T->getCallConv()) { |
| 918 | case CC_Default: |
| 919 | case CC_C: Out << 'A'; break; |
Dawn Perchik | 52fc314 | 2010-09-03 01:29:35 +0000 | [diff] [blame] | 920 | case CC_X86Pascal: Out << 'C'; break; |
Charles Davis | 65161d1 | 2010-06-16 05:33:16 +0000 | [diff] [blame] | 921 | case CC_X86ThisCall: Out << 'E'; break; |
| 922 | case CC_X86StdCall: Out << 'G'; break; |
| 923 | case CC_X86FastCall: Out << 'I'; break; |
| 924 | } |
| 925 | } |
| 926 | void MicrosoftCXXNameMangler::mangleThrowSpecification( |
| 927 | const FunctionProtoType *FT) { |
| 928 | // <throw-spec> ::= Z # throw(...) (default) |
| 929 | // ::= @ # throw() or __declspec/__attribute__((nothrow)) |
| 930 | // ::= <type>+ |
Charles Davis | 3a0d41d | 2010-06-26 03:50:05 +0000 | [diff] [blame] | 931 | // NOTE: Since the Microsoft compiler ignores throw specifications, they are |
| 932 | // all actually mangled as 'Z'. (They're ignored because their associated |
| 933 | // functionality isn't implemented, and probably never will be.) |
| 934 | Out << 'Z'; |
Charles Davis | 65161d1 | 2010-06-16 05:33:16 +0000 | [diff] [blame] | 935 | } |
| 936 | |
Charles Davis | 0b8fe8c | 2010-06-30 08:09:57 +0000 | [diff] [blame] | 937 | void MicrosoftCXXNameMangler::mangleType(const UnresolvedUsingType *T) { |
| 938 | assert(false && "Don't know how to mangle UnresolvedUsingTypes yet!"); |
| 939 | } |
| 940 | |
Charles Davis | c62458f | 2010-06-18 07:51:00 +0000 | [diff] [blame] | 941 | // <type> ::= <union-type> | <struct-type> | <class-type> | <enum-type> |
| 942 | // <union-type> ::= T <name> |
| 943 | // <struct-type> ::= U <name> |
| 944 | // <class-type> ::= V <name> |
| 945 | // <enum-type> ::= W <size> <name> |
| 946 | void MicrosoftCXXNameMangler::mangleType(const EnumType *T) { |
| 947 | mangleType(static_cast<const TagType*>(T)); |
| 948 | } |
| 949 | void MicrosoftCXXNameMangler::mangleType(const RecordType *T) { |
| 950 | mangleType(static_cast<const TagType*>(T)); |
| 951 | } |
| 952 | void MicrosoftCXXNameMangler::mangleType(const TagType *T) { |
| 953 | switch (T->getDecl()->getTagKind()) { |
| 954 | case TTK_Union: |
| 955 | Out << 'T'; |
| 956 | break; |
| 957 | case TTK_Struct: |
| 958 | Out << 'U'; |
| 959 | break; |
| 960 | case TTK_Class: |
| 961 | Out << 'V'; |
| 962 | break; |
| 963 | case TTK_Enum: |
| 964 | Out << 'W'; |
Charles Davis | 0877826 | 2010-07-03 08:15:16 +0000 | [diff] [blame] | 965 | Out << getASTContext().getTypeSizeInChars( |
| 966 | cast<EnumDecl>(T->getDecl())->getIntegerType()).getQuantity(); |
Charles Davis | c62458f | 2010-06-18 07:51:00 +0000 | [diff] [blame] | 967 | break; |
| 968 | } |
| 969 | mangleName(T->getDecl()); |
| 970 | } |
| 971 | |
Charles Davis | 0b8fe8c | 2010-06-30 08:09:57 +0000 | [diff] [blame] | 972 | // <type> ::= <array-type> |
| 973 | // <array-type> ::= P <cvr-qualifiers> [Y <dimension-count> <dimension>+] |
| 974 | // <element-type> # as global |
| 975 | // ::= Q <cvr-qualifiers> [Y <dimension-count> <dimension>+] |
| 976 | // <element-type> # as param |
| 977 | // It's supposed to be the other way around, but for some strange reason, it |
| 978 | // isn't. Today this behavior is retained for the sole purpose of backwards |
| 979 | // compatibility. |
| 980 | void MicrosoftCXXNameMangler::mangleType(const ArrayType *T, bool IsGlobal) { |
| 981 | // This isn't a recursive mangling, so now we have to do it all in this |
| 982 | // one call. |
| 983 | if (IsGlobal) |
| 984 | Out << 'P'; |
| 985 | else |
| 986 | Out << 'Q'; |
| 987 | mangleExtraDimensions(T->getElementType()); |
| 988 | } |
| 989 | void MicrosoftCXXNameMangler::mangleType(const ConstantArrayType *T) { |
| 990 | mangleType(static_cast<const ArrayType *>(T), false); |
| 991 | } |
| 992 | void MicrosoftCXXNameMangler::mangleType(const VariableArrayType *T) { |
| 993 | mangleType(static_cast<const ArrayType *>(T), false); |
| 994 | } |
| 995 | void MicrosoftCXXNameMangler::mangleType(const DependentSizedArrayType *T) { |
| 996 | mangleType(static_cast<const ArrayType *>(T), false); |
| 997 | } |
| 998 | void MicrosoftCXXNameMangler::mangleType(const IncompleteArrayType *T) { |
| 999 | mangleType(static_cast<const ArrayType *>(T), false); |
| 1000 | } |
| 1001 | void MicrosoftCXXNameMangler::mangleExtraDimensions(QualType ElementTy) { |
| 1002 | llvm::SmallVector<llvm::APInt, 3> Dimensions; |
| 1003 | for (;;) { |
| 1004 | if (ElementTy->isConstantArrayType()) { |
| 1005 | const ConstantArrayType *CAT = |
| 1006 | static_cast<const ConstantArrayType *>(ElementTy.getTypePtr()); |
Charles Davis | 0877826 | 2010-07-03 08:15:16 +0000 | [diff] [blame] | 1007 | Dimensions.push_back(CAT->getSize()); |
Charles Davis | 0b8fe8c | 2010-06-30 08:09:57 +0000 | [diff] [blame] | 1008 | ElementTy = CAT->getElementType(); |
| 1009 | } else if (ElementTy->isVariableArrayType()) { |
| 1010 | assert(false && "Don't know how to mangle VLAs!"); |
| 1011 | } else if (ElementTy->isDependentSizedArrayType()) { |
| 1012 | // The dependent expression has to be folded into a constant (TODO). |
| 1013 | assert(false && "Don't know how to mangle dependent-sized arrays!"); |
| 1014 | } else if (ElementTy->isIncompleteArrayType()) continue; |
| 1015 | else break; |
| 1016 | } |
| 1017 | mangleQualifiers(ElementTy.getQualifiers(), false); |
| 1018 | // If there are any additional dimensions, mangle them now. |
| 1019 | if (Dimensions.size() > 0) { |
| 1020 | Out << 'Y'; |
Charles Davis | 0877826 | 2010-07-03 08:15:16 +0000 | [diff] [blame] | 1021 | // <dimension-count> ::= <number> # number of extra dimensions |
| 1022 | mangleNumber(Dimensions.size()); |
Charles Davis | 0b8fe8c | 2010-06-30 08:09:57 +0000 | [diff] [blame] | 1023 | for (unsigned Dim = 0; Dim < Dimensions.size(); ++Dim) { |
| 1024 | mangleNumber(Dimensions[Dim].getLimitedValue()); |
| 1025 | } |
| 1026 | } |
| 1027 | mangleType(ElementTy.getLocalUnqualifiedType()); |
| 1028 | } |
| 1029 | |
Charles Davis | cd712cb | 2010-07-03 08:01:32 +0000 | [diff] [blame] | 1030 | // <type> ::= <pointer-to-member-type> |
| 1031 | // <pointer-to-member-type> ::= <pointer-cvr-qualifiers> <cvr-qualifiers> |
| 1032 | // <class name> <type> |
Charles Davis | 0b8fe8c | 2010-06-30 08:09:57 +0000 | [diff] [blame] | 1033 | void MicrosoftCXXNameMangler::mangleType(const MemberPointerType *T) { |
Charles Davis | cd712cb | 2010-07-03 08:01:32 +0000 | [diff] [blame] | 1034 | QualType PointeeType = T->getPointeeType(); |
| 1035 | if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(PointeeType)) { |
| 1036 | Out << '8'; |
| 1037 | mangleName(cast<RecordType>(T->getClass())->getDecl()); |
| 1038 | mangleType(FPT, NULL, false, true); |
| 1039 | } else { |
| 1040 | mangleQualifiers(PointeeType.getQualifiers(), true); |
| 1041 | mangleName(cast<RecordType>(T->getClass())->getDecl()); |
| 1042 | mangleType(PointeeType.getLocalUnqualifiedType()); |
| 1043 | } |
Charles Davis | 0b8fe8c | 2010-06-30 08:09:57 +0000 | [diff] [blame] | 1044 | } |
| 1045 | |
| 1046 | void MicrosoftCXXNameMangler::mangleType(const TemplateTypeParmType *T) { |
| 1047 | assert(false && "Don't know how to mangle TemplateTypeParmTypes yet!"); |
| 1048 | } |
| 1049 | |
Charles Davis | 3a0d41d | 2010-06-26 03:50:05 +0000 | [diff] [blame] | 1050 | // <type> ::= <pointer-type> |
| 1051 | // <pointer-type> ::= <pointer-cvr-qualifiers> <cvr-qualifiers> <type> |
| 1052 | void MicrosoftCXXNameMangler::mangleType(const PointerType *T) { |
| 1053 | QualType PointeeTy = T->getPointeeType(); |
Charles Davis | 0b8fe8c | 2010-06-30 08:09:57 +0000 | [diff] [blame] | 1054 | if (PointeeTy->isArrayType()) { |
| 1055 | // Pointers to arrays are mangled like arrays. |
| 1056 | mangleExtraDimensions(T->getPointeeType()); |
Charles Davis | 1139da1 | 2010-07-03 05:53:41 +0000 | [diff] [blame] | 1057 | } else if (PointeeTy->isFunctionType()) { |
| 1058 | // Function pointers are special. |
| 1059 | Out << '6'; |
| 1060 | mangleType(static_cast<const FunctionType *>(PointeeTy.getTypePtr()), |
| 1061 | NULL, false, false); |
Charles Davis | 0b8fe8c | 2010-06-30 08:09:57 +0000 | [diff] [blame] | 1062 | } else { |
| 1063 | if (!PointeeTy.hasQualifiers()) |
| 1064 | // Lack of qualifiers is mangled as 'A'. |
| 1065 | Out << 'A'; |
| 1066 | mangleType(PointeeTy); |
| 1067 | } |
| 1068 | } |
| 1069 | void MicrosoftCXXNameMangler::mangleType(const ObjCObjectPointerType *T) { |
Charles Davis | 4d25483 | 2010-07-03 16:56:59 +0000 | [diff] [blame] | 1070 | // Object pointers never have qualifiers. |
| 1071 | Out << 'A'; |
| 1072 | mangleType(T->getPointeeType()); |
Charles Davis | 3a0d41d | 2010-06-26 03:50:05 +0000 | [diff] [blame] | 1073 | } |
| 1074 | |
| 1075 | // <type> ::= <reference-type> |
| 1076 | // <reference-type> ::= A <cvr-qualifiers> <type> |
| 1077 | void MicrosoftCXXNameMangler::mangleType(const LValueReferenceType *T) { |
| 1078 | Out << 'A'; |
| 1079 | QualType PointeeTy = T->getPointeeType(); |
Charles Davis | 0b8fe8c | 2010-06-30 08:09:57 +0000 | [diff] [blame] | 1080 | if (!PointeeTy.hasQualifiers()) |
Charles Davis | 3a0d41d | 2010-06-26 03:50:05 +0000 | [diff] [blame] | 1081 | // Lack of qualifiers is mangled as 'A'. |
| 1082 | Out << 'A'; |
| 1083 | mangleType(PointeeTy); |
| 1084 | } |
| 1085 | |
Charles Davis | 0b8fe8c | 2010-06-30 08:09:57 +0000 | [diff] [blame] | 1086 | void MicrosoftCXXNameMangler::mangleType(const RValueReferenceType *T) { |
| 1087 | assert(false && "Don't know how to mangle RValueReferenceTypes yet!"); |
| 1088 | } |
| 1089 | |
| 1090 | void MicrosoftCXXNameMangler::mangleType(const ComplexType *T) { |
| 1091 | assert(false && "Don't know how to mangle ComplexTypes yet!"); |
| 1092 | } |
| 1093 | |
| 1094 | void MicrosoftCXXNameMangler::mangleType(const VectorType *T) { |
| 1095 | assert(false && "Don't know how to mangle VectorTypes yet!"); |
| 1096 | } |
| 1097 | void MicrosoftCXXNameMangler::mangleType(const ExtVectorType *T) { |
| 1098 | assert(false && "Don't know how to mangle ExtVectorTypes yet!"); |
| 1099 | } |
| 1100 | void MicrosoftCXXNameMangler::mangleType(const DependentSizedExtVectorType *T) { |
| 1101 | assert(false && "Don't know how to mangle DependentSizedExtVectorTypes yet!"); |
| 1102 | } |
| 1103 | |
| 1104 | void MicrosoftCXXNameMangler::mangleType(const ObjCInterfaceType *T) { |
Charles Davis | 4d25483 | 2010-07-03 16:56:59 +0000 | [diff] [blame] | 1105 | // ObjC interfaces have structs underlying them. |
| 1106 | Out << 'U'; |
| 1107 | mangleName(T->getDecl()); |
Charles Davis | 0b8fe8c | 2010-06-30 08:09:57 +0000 | [diff] [blame] | 1108 | } |
| 1109 | |
| 1110 | void MicrosoftCXXNameMangler::mangleType(const ObjCObjectType *T) { |
Charles Davis | 4d25483 | 2010-07-03 16:56:59 +0000 | [diff] [blame] | 1111 | // We don't allow overloading by different protocol qualification, |
| 1112 | // so mangling them isn't necessary. |
| 1113 | mangleType(T->getBaseType()); |
Charles Davis | 0b8fe8c | 2010-06-30 08:09:57 +0000 | [diff] [blame] | 1114 | } |
| 1115 | |
| 1116 | void MicrosoftCXXNameMangler::mangleType(const BlockPointerType *T) { |
Charles Davis | 4d25483 | 2010-07-03 16:56:59 +0000 | [diff] [blame] | 1117 | Out << "_E"; |
| 1118 | mangleType(T->getPointeeType()); |
Charles Davis | 0b8fe8c | 2010-06-30 08:09:57 +0000 | [diff] [blame] | 1119 | } |
| 1120 | |
| 1121 | void MicrosoftCXXNameMangler::mangleType(const InjectedClassNameType *T) { |
| 1122 | assert(false && "Don't know how to mangle InjectedClassNameTypes yet!"); |
| 1123 | } |
| 1124 | |
| 1125 | void MicrosoftCXXNameMangler::mangleType(const TemplateSpecializationType *T) { |
| 1126 | assert(false && "Don't know how to mangle TemplateSpecializationTypes yet!"); |
| 1127 | } |
| 1128 | |
| 1129 | void MicrosoftCXXNameMangler::mangleType(const DependentNameType *T) { |
| 1130 | assert(false && "Don't know how to mangle DependentNameTypes yet!"); |
| 1131 | } |
| 1132 | |
| 1133 | void MicrosoftCXXNameMangler::mangleType( |
| 1134 | const DependentTemplateSpecializationType *T) { |
| 1135 | assert(false && |
| 1136 | "Don't know how to mangle DependentTemplateSpecializationTypes yet!"); |
| 1137 | } |
| 1138 | |
| 1139 | void MicrosoftCXXNameMangler::mangleType(const TypeOfType *T) { |
| 1140 | assert(false && "Don't know how to mangle TypeOfTypes yet!"); |
| 1141 | } |
| 1142 | |
| 1143 | void MicrosoftCXXNameMangler::mangleType(const TypeOfExprType *T) { |
| 1144 | assert(false && "Don't know how to mangle TypeOfExprTypes yet!"); |
| 1145 | } |
| 1146 | |
| 1147 | void MicrosoftCXXNameMangler::mangleType(const DecltypeType *T) { |
| 1148 | assert(false && "Don't know how to mangle DecltypeTypes yet!"); |
| 1149 | } |
| 1150 | |
Charles Davis | c392664 | 2010-06-09 23:25:41 +0000 | [diff] [blame] | 1151 | void MicrosoftMangleContext::mangleName(const NamedDecl *D, |
| 1152 | llvm::SmallVectorImpl<char> &Name) { |
Charles Davis | e60cea8 | 2010-06-11 03:07:32 +0000 | [diff] [blame] | 1153 | assert((isa<FunctionDecl>(D) || isa<VarDecl>(D)) && |
| 1154 | "Invalid mangleName() call, argument is not a variable or function!"); |
| 1155 | assert(!isa<CXXConstructorDecl>(D) && !isa<CXXDestructorDecl>(D) && |
| 1156 | "Invalid mangleName() call on 'structor decl!"); |
| 1157 | |
| 1158 | PrettyStackTraceDecl CrashInfo(D, SourceLocation(), |
| 1159 | getASTContext().getSourceManager(), |
| 1160 | "Mangling declaration"); |
| 1161 | |
| 1162 | MicrosoftCXXNameMangler Mangler(*this, Name); |
| 1163 | return Mangler.mangle(D); |
Charles Davis | c392664 | 2010-06-09 23:25:41 +0000 | [diff] [blame] | 1164 | } |
| 1165 | void MicrosoftMangleContext::mangleThunk(const CXXMethodDecl *MD, |
| 1166 | const ThunkInfo &Thunk, |
| 1167 | llvm::SmallVectorImpl<char> &) { |
| 1168 | assert(false && "Can't yet mangle thunks!"); |
| 1169 | } |
| 1170 | void MicrosoftMangleContext::mangleCXXDtorThunk(const CXXDestructorDecl *DD, |
| 1171 | CXXDtorType Type, |
| 1172 | const ThisAdjustment &, |
| 1173 | llvm::SmallVectorImpl<char> &) { |
| 1174 | assert(false && "Can't yet mangle destructor thunks!"); |
| 1175 | } |
Charles Davis | c392664 | 2010-06-09 23:25:41 +0000 | [diff] [blame] | 1176 | void MicrosoftMangleContext::mangleCXXVTable(const CXXRecordDecl *RD, |
| 1177 | llvm::SmallVectorImpl<char> &) { |
| 1178 | assert(false && "Can't yet mangle virtual tables!"); |
| 1179 | } |
| 1180 | void MicrosoftMangleContext::mangleCXXVTT(const CXXRecordDecl *RD, |
| 1181 | llvm::SmallVectorImpl<char> &) { |
| 1182 | llvm_unreachable("The MS C++ ABI does not have virtual table tables!"); |
| 1183 | } |
| 1184 | void MicrosoftMangleContext::mangleCXXCtorVTable(const CXXRecordDecl *RD, |
| 1185 | int64_t Offset, |
| 1186 | const CXXRecordDecl *Type, |
| 1187 | llvm::SmallVectorImpl<char> &) { |
| 1188 | llvm_unreachable("The MS C++ ABI does not have constructor vtables!"); |
| 1189 | } |
| 1190 | void MicrosoftMangleContext::mangleCXXRTTI(QualType T, |
| 1191 | llvm::SmallVectorImpl<char> &) { |
| 1192 | assert(false && "Can't yet mangle RTTI!"); |
| 1193 | } |
| 1194 | void MicrosoftMangleContext::mangleCXXRTTIName(QualType T, |
| 1195 | llvm::SmallVectorImpl<char> &) { |
| 1196 | assert(false && "Can't yet mangle RTTI names!"); |
| 1197 | } |
| 1198 | void MicrosoftMangleContext::mangleCXXCtor(const CXXConstructorDecl *D, |
| 1199 | CXXCtorType Type, |
| 1200 | llvm::SmallVectorImpl<char> &) { |
| 1201 | assert(false && "Can't yet mangle constructors!"); |
| 1202 | } |
| 1203 | void MicrosoftMangleContext::mangleCXXDtor(const CXXDestructorDecl *D, |
| 1204 | CXXDtorType Type, |
| 1205 | llvm::SmallVectorImpl<char> &) { |
| 1206 | assert(false && "Can't yet mangle destructors!"); |
| 1207 | } |
| 1208 | |
Charles Davis | 071cc7d | 2010-08-16 03:33:14 +0000 | [diff] [blame] | 1209 | CGCXXABI *clang::CodeGen::CreateMicrosoftCXXABI(CodeGenModule &CGM) { |
Charles Davis | c392664 | 2010-06-09 23:25:41 +0000 | [diff] [blame] | 1210 | return new MicrosoftCXXABI(CGM); |
| 1211 | } |
| 1212 | |