Douglas Gregor | 6ec3668 | 2009-02-18 23:53:56 +0000 | [diff] [blame] | 1 | //===--- Mangle.cpp - Mangle C++ Names --------------------------*- C++ -*-===// |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 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 | // Implements C++ name mangling according to the Itanium C++ ABI, |
| 11 | // which is used in GCC 3.2 and newer (and many compilers that are |
| 12 | // ABI-compatible with GCC): |
| 13 | // |
| 14 | // http://www.codesourcery.com/public/cxx-abi/abi.html |
| 15 | // |
| 16 | //===----------------------------------------------------------------------===// |
| 17 | #include "Mangle.h" |
| 18 | #include "clang/AST/ASTContext.h" |
| 19 | #include "clang/AST/Decl.h" |
| 20 | #include "clang/AST/DeclCXX.h" |
Anders Carlsson | a40c5e4 | 2009-03-07 22:03:21 +0000 | [diff] [blame] | 21 | #include "clang/AST/DeclObjC.h" |
Douglas Gregor | 6ec3668 | 2009-02-18 23:53:56 +0000 | [diff] [blame] | 22 | #include "clang/Basic/SourceManager.h" |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 23 | #include "llvm/Support/Compiler.h" |
| 24 | #include "llvm/Support/raw_ostream.h" |
| 25 | using namespace clang; |
| 26 | |
| 27 | namespace { |
| 28 | class VISIBILITY_HIDDEN CXXNameMangler { |
| 29 | ASTContext &Context; |
| 30 | llvm::raw_ostream &Out; |
| 31 | |
Anders Carlsson | 27ae536 | 2009-04-17 01:58:57 +0000 | [diff] [blame^] | 32 | const CXXMethodDecl *Structor; |
| 33 | unsigned StructorType; |
Anders Carlsson | 3ac86b5 | 2009-04-15 05:36:58 +0000 | [diff] [blame] | 34 | CXXCtorType CtorType; |
| 35 | |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 36 | public: |
| 37 | CXXNameMangler(ASTContext &C, llvm::raw_ostream &os) |
Anders Carlsson | 27ae536 | 2009-04-17 01:58:57 +0000 | [diff] [blame^] | 38 | : Context(C), Out(os), Structor(0), StructorType(0) { } |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 39 | |
| 40 | bool mangle(const NamedDecl *D); |
Anders Carlsson | 41aa8c1 | 2009-04-13 18:02:10 +0000 | [diff] [blame] | 41 | void mangleGuardVariable(const VarDecl *D); |
Anders Carlsson | 27ae536 | 2009-04-17 01:58:57 +0000 | [diff] [blame^] | 42 | |
Anders Carlsson | 3ac86b5 | 2009-04-15 05:36:58 +0000 | [diff] [blame] | 43 | void mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type); |
Anders Carlsson | 27ae536 | 2009-04-17 01:58:57 +0000 | [diff] [blame^] | 44 | void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type); |
Anders Carlsson | 3ac86b5 | 2009-04-15 05:36:58 +0000 | [diff] [blame] | 45 | |
Anders Carlsson | 43f1740 | 2009-04-02 15:51:53 +0000 | [diff] [blame] | 46 | private: |
| 47 | bool mangleFunctionDecl(const FunctionDecl *FD); |
| 48 | |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 49 | void mangleFunctionEncoding(const FunctionDecl *FD); |
| 50 | void mangleName(const NamedDecl *ND); |
| 51 | void mangleUnqualifiedName(const NamedDecl *ND); |
| 52 | void mangleSourceName(const IdentifierInfo *II); |
Anders Carlsson | 1b42c79 | 2009-04-02 16:24:45 +0000 | [diff] [blame] | 53 | void mangleLocalName(const NamedDecl *ND); |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 54 | void mangleNestedName(const NamedDecl *ND); |
| 55 | void manglePrefix(const DeclContext *DC); |
| 56 | void mangleOperatorName(OverloadedOperatorKind OO, unsigned Arity); |
| 57 | void mangleCVQualifiers(unsigned Quals); |
| 58 | void mangleType(QualType T); |
| 59 | void mangleType(const BuiltinType *T); |
| 60 | void mangleType(const FunctionType *T); |
| 61 | void mangleBareFunctionType(const FunctionType *T, bool MangleReturnType); |
| 62 | void mangleType(const TagType *T); |
| 63 | void mangleType(const ArrayType *T); |
| 64 | void mangleType(const MemberPointerType *T); |
| 65 | void mangleType(const TemplateTypeParmType *T); |
Anders Carlsson | a40c5e4 | 2009-03-07 22:03:21 +0000 | [diff] [blame] | 66 | void mangleType(const ObjCInterfaceType *T); |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 67 | void mangleExpression(Expr *E); |
Anders Carlsson | 3ac86b5 | 2009-04-15 05:36:58 +0000 | [diff] [blame] | 68 | void mangleCXXCtorType(CXXCtorType T); |
Anders Carlsson | 27ae536 | 2009-04-17 01:58:57 +0000 | [diff] [blame^] | 69 | void mangleCXXDtorType(CXXDtorType T); |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 70 | }; |
| 71 | } |
| 72 | |
Anders Carlsson | 43f1740 | 2009-04-02 15:51:53 +0000 | [diff] [blame] | 73 | static bool isInCLinkageSpecification(const Decl *D) { |
| 74 | for (const DeclContext *DC = D->getDeclContext(); |
| 75 | !DC->isTranslationUnit(); DC = DC->getParent()) { |
| 76 | if (const LinkageSpecDecl *Linkage = dyn_cast<LinkageSpecDecl>(DC)) |
| 77 | return Linkage->getLanguage() == LinkageSpecDecl::lang_c; |
| 78 | } |
| 79 | |
| 80 | return false; |
| 81 | } |
| 82 | |
| 83 | bool CXXNameMangler::mangleFunctionDecl(const FunctionDecl *FD) { |
| 84 | // Clang's "overloadable" attribute extension to C/C++ implies |
| 85 | // name mangling (always). |
Daniel Dunbar | b11fa0d | 2009-04-13 21:08:27 +0000 | [diff] [blame] | 86 | if (FD->hasAttr<OverloadableAttr>()) { |
Anders Carlsson | 43f1740 | 2009-04-02 15:51:53 +0000 | [diff] [blame] | 87 | ; // fall into mangling code unconditionally. |
| 88 | } else if (// C functions are not mangled |
| 89 | !Context.getLangOptions().CPlusPlus || |
| 90 | // "main" is not mangled in C++ |
| 91 | FD->isMain() || |
| 92 | // No mangling in an "implicit extern C" header. |
| 93 | Context.getSourceManager().getFileCharacteristic(FD->getLocation()) |
| 94 | == SrcMgr::C_ExternCSystem || |
| 95 | // No name mangling in a C linkage specification. |
| 96 | isInCLinkageSpecification(FD)) |
| 97 | return false; |
| 98 | |
| 99 | // If we get here, mangle the decl name! |
| 100 | Out << "_Z"; |
| 101 | mangleFunctionEncoding(FD); |
| 102 | return true; |
| 103 | } |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 104 | |
| 105 | bool CXXNameMangler::mangle(const NamedDecl *D) { |
Chris Lattner | ca3f25c | 2009-03-21 08:24:40 +0000 | [diff] [blame] | 106 | // Any decl can be declared with __asm("foo") on it, and this takes |
| 107 | // precedence over all other naming in the .o file. |
| 108 | if (const AsmLabelAttr *ALA = D->getAttr<AsmLabelAttr>()) { |
| 109 | // If we have an asm name, then we use it as the mangling. |
| 110 | Out << '\01'; // LLVM IR Marker for __asm("foo") |
| 111 | Out << ALA->getLabel(); |
| 112 | return true; |
| 113 | } |
| 114 | |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 115 | // <mangled-name> ::= _Z <encoding> |
| 116 | // ::= <data name> |
| 117 | // ::= <special-name> |
| 118 | |
| 119 | // FIXME: Actually use a visitor to decode these? |
Anders Carlsson | 43f1740 | 2009-04-02 15:51:53 +0000 | [diff] [blame] | 120 | if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) |
| 121 | return mangleFunctionDecl(FD); |
Chris Lattner | bc7a029 | 2009-03-21 06:19:20 +0000 | [diff] [blame] | 122 | |
Anders Carlsson | 329749c | 2009-04-02 16:05:20 +0000 | [diff] [blame] | 123 | if (const VarDecl *VD = dyn_cast<VarDecl>(D)) { |
| 124 | if (!Context.getLangOptions().CPlusPlus || |
Anders Carlsson | 9ccb065 | 2009-04-11 01:19:45 +0000 | [diff] [blame] | 125 | isInCLinkageSpecification(D) || |
| 126 | D->getDeclContext()->isTranslationUnit()) |
Anders Carlsson | 329749c | 2009-04-02 16:05:20 +0000 | [diff] [blame] | 127 | return false; |
| 128 | |
| 129 | Out << "_Z"; |
| 130 | mangleName(VD); |
| 131 | return true; |
| 132 | } |
| 133 | |
Anders Carlsson | 43f1740 | 2009-04-02 15:51:53 +0000 | [diff] [blame] | 134 | return false; |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 135 | } |
| 136 | |
Anders Carlsson | 3ac86b5 | 2009-04-15 05:36:58 +0000 | [diff] [blame] | 137 | void CXXNameMangler::mangleCXXCtor(const CXXConstructorDecl *D, |
| 138 | CXXCtorType Type) { |
Anders Carlsson | 27ae536 | 2009-04-17 01:58:57 +0000 | [diff] [blame^] | 139 | assert(!Structor && "Structor already set!"); |
| 140 | Structor = D; |
| 141 | StructorType = Type; |
| 142 | |
| 143 | mangle(D); |
| 144 | } |
| 145 | |
| 146 | void CXXNameMangler::mangleCXXDtor(const CXXDestructorDecl *D, |
| 147 | CXXDtorType Type) { |
| 148 | assert(!Structor && "Structor already set!"); |
| 149 | Structor = D; |
| 150 | StructorType = Type; |
Anders Carlsson | 3ac86b5 | 2009-04-15 05:36:58 +0000 | [diff] [blame] | 151 | |
| 152 | mangle(D); |
| 153 | } |
| 154 | |
Anders Carlsson | 41aa8c1 | 2009-04-13 18:02:10 +0000 | [diff] [blame] | 155 | void CXXNameMangler::mangleGuardVariable(const VarDecl *D) |
| 156 | { |
| 157 | // <special-name> ::= GV <object name> # Guard variable for one-time |
| 158 | // # initialization |
| 159 | |
| 160 | Out << "_ZGV"; |
| 161 | mangleName(D); |
| 162 | } |
| 163 | |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 164 | void CXXNameMangler::mangleFunctionEncoding(const FunctionDecl *FD) { |
| 165 | // <encoding> ::= <function name> <bare-function-type> |
| 166 | mangleName(FD); |
| 167 | mangleBareFunctionType(FD->getType()->getAsFunctionType(), false); |
| 168 | } |
| 169 | |
| 170 | static bool isStdNamespace(const DeclContext *DC) { |
| 171 | if (!DC->isNamespace() || !DC->getParent()->isTranslationUnit()) |
| 172 | return false; |
| 173 | |
| 174 | const NamespaceDecl *NS = cast<NamespaceDecl>(DC); |
Douglas Gregor | 6ec3668 | 2009-02-18 23:53:56 +0000 | [diff] [blame] | 175 | return NS->getOriginalNamespace()->getIdentifier()->isStr("std"); |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | void CXXNameMangler::mangleName(const NamedDecl *ND) { |
| 179 | // <name> ::= <nested-name> |
| 180 | // ::= <unscoped-name> |
| 181 | // ::= <unscoped-template-name> <template-args> |
| 182 | // ::= <local-name> # See Scope Encoding below |
| 183 | // |
| 184 | // <unscoped-name> ::= <unqualified-name> |
| 185 | // ::= St <unqualified-name> # ::std:: |
| 186 | if (ND->getDeclContext()->isTranslationUnit()) |
| 187 | mangleUnqualifiedName(ND); |
| 188 | else if (isStdNamespace(ND->getDeclContext())) { |
| 189 | Out << "St"; |
| 190 | mangleUnqualifiedName(ND); |
Anders Carlsson | 1b42c79 | 2009-04-02 16:24:45 +0000 | [diff] [blame] | 191 | } else if (isa<FunctionDecl>(ND->getDeclContext())) |
| 192 | mangleLocalName(ND); |
| 193 | else |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 194 | mangleNestedName(ND); |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND) { |
| 198 | // <unqualified-name> ::= <operator-name> |
| 199 | // ::= <ctor-dtor-name> |
| 200 | // ::= <source-name> |
| 201 | DeclarationName Name = ND->getDeclName(); |
| 202 | switch (Name.getNameKind()) { |
| 203 | case DeclarationName::Identifier: |
| 204 | mangleSourceName(Name.getAsIdentifierInfo()); |
| 205 | break; |
| 206 | |
| 207 | case DeclarationName::ObjCZeroArgSelector: |
| 208 | case DeclarationName::ObjCOneArgSelector: |
| 209 | case DeclarationName::ObjCMultiArgSelector: |
| 210 | assert(false && "Can't mangle Objective-C selector names here!"); |
| 211 | break; |
| 212 | |
| 213 | case DeclarationName::CXXConstructorName: |
Anders Carlsson | 27ae536 | 2009-04-17 01:58:57 +0000 | [diff] [blame^] | 214 | if (ND == Structor) |
Anders Carlsson | 3ac86b5 | 2009-04-15 05:36:58 +0000 | [diff] [blame] | 215 | // If the named decl is the C++ constructor we're mangling, use the |
| 216 | // type we were given. |
Anders Carlsson | 27ae536 | 2009-04-17 01:58:57 +0000 | [diff] [blame^] | 217 | mangleCXXCtorType(static_cast<CXXCtorType>(StructorType)); |
Anders Carlsson | 3ac86b5 | 2009-04-15 05:36:58 +0000 | [diff] [blame] | 218 | else |
| 219 | // Otherwise, use the complete constructor name. This is relevant if a |
| 220 | // class with a constructor is declared within a constructor. |
| 221 | mangleCXXCtorType(Ctor_Complete); |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 222 | break; |
| 223 | |
| 224 | case DeclarationName::CXXDestructorName: |
Anders Carlsson | 27ae536 | 2009-04-17 01:58:57 +0000 | [diff] [blame^] | 225 | if (ND == Structor) |
| 226 | // If the named decl is the C++ destructor we're mangling, use the |
| 227 | // type we were given. |
| 228 | mangleCXXDtorType(static_cast<CXXDtorType>(StructorType)); |
| 229 | else |
| 230 | // Otherwise, use the complete destructor name. This is relevant if a |
| 231 | // class with a destructor is declared within a destructor. |
| 232 | mangleCXXDtorType(Dtor_Complete); |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 233 | break; |
| 234 | |
| 235 | case DeclarationName::CXXConversionFunctionName: |
Douglas Gregor | 219cc61 | 2009-02-13 01:28:03 +0000 | [diff] [blame] | 236 | // <operator-name> ::= cv <type> # (cast) |
| 237 | Out << "cv"; |
| 238 | mangleType(Context.getCanonicalType(Name.getCXXNameType())); |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 239 | break; |
| 240 | |
| 241 | case DeclarationName::CXXOperatorName: |
| 242 | mangleOperatorName(Name.getCXXOverloadedOperator(), |
| 243 | cast<FunctionDecl>(ND)->getNumParams()); |
| 244 | break; |
| 245 | |
| 246 | case DeclarationName::CXXUsingDirective: |
| 247 | assert(false && "Can't mangle a using directive name!"); |
Douglas Gregor | 219cc61 | 2009-02-13 01:28:03 +0000 | [diff] [blame] | 248 | break; |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 249 | } |
| 250 | } |
| 251 | |
| 252 | void CXXNameMangler::mangleSourceName(const IdentifierInfo *II) { |
| 253 | // <source-name> ::= <positive length number> <identifier> |
| 254 | // <number> ::= [n] <non-negative decimal integer> |
| 255 | // <identifier> ::= <unqualified source code identifier> |
| 256 | Out << II->getLength() << II->getName(); |
| 257 | } |
| 258 | |
| 259 | void CXXNameMangler::mangleNestedName(const NamedDecl *ND) { |
| 260 | // <nested-name> ::= N [<CV-qualifiers>] <prefix> <unqualified-name> E |
| 261 | // ::= N [<CV-qualifiers>] <template-prefix> <template-args> E |
| 262 | // FIXME: no template support |
| 263 | Out << 'N'; |
| 264 | if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(ND)) |
| 265 | mangleCVQualifiers(Method->getTypeQualifiers()); |
| 266 | manglePrefix(ND->getDeclContext()); |
| 267 | mangleUnqualifiedName(ND); |
| 268 | Out << 'E'; |
| 269 | } |
| 270 | |
Anders Carlsson | 1b42c79 | 2009-04-02 16:24:45 +0000 | [diff] [blame] | 271 | void CXXNameMangler::mangleLocalName(const NamedDecl *ND) { |
| 272 | // <local-name> := Z <function encoding> E <entity name> [<discriminator>] |
| 273 | // := Z <function encoding> E s [<discriminator>] |
| 274 | // <discriminator> := _ <non-negative number> |
| 275 | Out << 'Z'; |
| 276 | mangleFunctionEncoding(cast<FunctionDecl>(ND->getDeclContext())); |
| 277 | Out << 'E'; |
| 278 | mangleSourceName(ND->getIdentifier()); |
| 279 | } |
| 280 | |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 281 | void CXXNameMangler::manglePrefix(const DeclContext *DC) { |
| 282 | // <prefix> ::= <prefix> <unqualified-name> |
| 283 | // ::= <template-prefix> <template-args> |
| 284 | // ::= <template-param> |
| 285 | // ::= # empty |
| 286 | // ::= <substitution> |
| 287 | // FIXME: We only handle mangling of namespaces and classes at the moment. |
Anders Carlsson | c8dee9c | 2009-04-01 00:42:16 +0000 | [diff] [blame] | 288 | if (!DC->getParent()->isTranslationUnit()) |
| 289 | manglePrefix(DC->getParent()); |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 290 | |
| 291 | if (const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(DC)) |
| 292 | mangleSourceName(Namespace->getIdentifier()); |
| 293 | else if (const RecordDecl *Record = dyn_cast<RecordDecl>(DC)) |
| 294 | mangleSourceName(Record->getIdentifier()); |
| 295 | } |
| 296 | |
| 297 | void |
| 298 | CXXNameMangler::mangleOperatorName(OverloadedOperatorKind OO, unsigned Arity) { |
| 299 | switch (OO) { |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 300 | // <operator-name> ::= nw # new |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 301 | case OO_New: Out << "nw"; break; |
| 302 | // ::= na # new[] |
| 303 | case OO_Array_New: Out << "na"; break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 304 | // ::= dl # delete |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 305 | case OO_Delete: Out << "dl"; break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 306 | // ::= da # delete[] |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 307 | case OO_Array_Delete: Out << "da"; break; |
| 308 | // ::= ps # + (unary) |
| 309 | // ::= pl # + |
| 310 | case OO_Plus: Out << (Arity == 1? "ps" : "pl"); break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 311 | // ::= ng # - (unary) |
| 312 | // ::= mi # - |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 313 | case OO_Minus: Out << (Arity == 1? "ng" : "mi"); break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 314 | // ::= ad # & (unary) |
| 315 | // ::= an # & |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 316 | case OO_Amp: Out << (Arity == 1? "ad" : "an"); break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 317 | // ::= de # * (unary) |
| 318 | // ::= ml # * |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 319 | case OO_Star: Out << (Arity == 1? "de" : "ml"); break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 320 | // ::= co # ~ |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 321 | case OO_Tilde: Out << "co"; break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 322 | // ::= dv # / |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 323 | case OO_Slash: Out << "dv"; break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 324 | // ::= rm # % |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 325 | case OO_Percent: Out << "rm"; break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 326 | // ::= or # | |
| 327 | case OO_Pipe: Out << "or"; break; |
| 328 | // ::= eo # ^ |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 329 | case OO_Caret: Out << "eo"; break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 330 | // ::= aS # = |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 331 | case OO_Equal: Out << "aS"; break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 332 | // ::= pL # += |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 333 | case OO_PlusEqual: Out << "pL"; break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 334 | // ::= mI # -= |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 335 | case OO_MinusEqual: Out << "mI"; break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 336 | // ::= mL # *= |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 337 | case OO_StarEqual: Out << "mL"; break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 338 | // ::= dV # /= |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 339 | case OO_SlashEqual: Out << "dV"; break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 340 | // ::= rM # %= |
| 341 | case OO_PercentEqual: Out << "rM"; break; |
| 342 | // ::= aN # &= |
| 343 | case OO_AmpEqual: Out << "aN"; break; |
| 344 | // ::= oR # |= |
| 345 | case OO_PipeEqual: Out << "oR"; break; |
| 346 | // ::= eO # ^= |
| 347 | case OO_CaretEqual: Out << "eO"; break; |
| 348 | // ::= ls # << |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 349 | case OO_LessLess: Out << "ls"; break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 350 | // ::= rs # >> |
| 351 | case OO_GreaterGreater: Out << "rs"; break; |
| 352 | // ::= lS # <<= |
| 353 | case OO_LessLessEqual: Out << "lS"; break; |
| 354 | // ::= rS # >>= |
| 355 | case OO_GreaterGreaterEqual: Out << "rS"; break; |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 356 | // ::= eq # == |
| 357 | case OO_EqualEqual: Out << "eq"; break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 358 | // ::= ne # != |
| 359 | case OO_ExclaimEqual: Out << "ne"; break; |
| 360 | // ::= lt # < |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 361 | case OO_Less: Out << "lt"; break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 362 | // ::= gt # > |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 363 | case OO_Greater: Out << "gt"; break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 364 | // ::= le # <= |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 365 | case OO_LessEqual: Out << "le"; break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 366 | // ::= ge # >= |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 367 | case OO_GreaterEqual: Out << "ge"; break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 368 | // ::= nt # ! |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 369 | case OO_Exclaim: Out << "nt"; break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 370 | // ::= aa # && |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 371 | case OO_AmpAmp: Out << "aa"; break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 372 | // ::= oo # || |
| 373 | case OO_PipePipe: Out << "oo"; break; |
| 374 | // ::= pp # ++ |
| 375 | case OO_PlusPlus: Out << "pp"; break; |
| 376 | // ::= mm # -- |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 377 | case OO_MinusMinus: Out << "mm"; break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 378 | // ::= cm # , |
| 379 | case OO_Comma: Out << "cm"; break; |
| 380 | // ::= pm # ->* |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 381 | case OO_ArrowStar: Out << "pm"; break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 382 | // ::= pt # -> |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 383 | case OO_Arrow: Out << "pt"; break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 384 | // ::= cl # () |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 385 | case OO_Call: Out << "cl"; break; |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 386 | // ::= ix # [] |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 387 | case OO_Subscript: Out << "ix"; break; |
| 388 | // UNSUPPORTED: ::= qu # ? |
| 389 | |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 390 | case OO_None: |
| 391 | case OO_Conditional: |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 392 | case NUM_OVERLOADED_OPERATORS: |
Douglas Gregor | 6ec3668 | 2009-02-18 23:53:56 +0000 | [diff] [blame] | 393 | assert(false && "Not an overloaded operator"); |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 394 | break; |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | void CXXNameMangler::mangleCVQualifiers(unsigned Quals) { |
| 399 | // <CV-qualifiers> ::= [r] [V] [K] # restrict (C99), volatile, const |
| 400 | if (Quals & QualType::Restrict) |
| 401 | Out << 'r'; |
| 402 | if (Quals & QualType::Volatile) |
| 403 | Out << 'V'; |
| 404 | if (Quals & QualType::Const) |
| 405 | Out << 'K'; |
| 406 | } |
| 407 | |
| 408 | void CXXNameMangler::mangleType(QualType T) { |
Anders Carlsson | 4843e58 | 2009-03-10 17:07:44 +0000 | [diff] [blame] | 409 | // Only operate on the canonical type! |
| 410 | T = Context.getCanonicalType(T); |
| 411 | |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 412 | // FIXME: Should we have a TypeNodes.def to make this easier? (YES!) |
| 413 | |
| 414 | // <type> ::= <CV-qualifiers> <type> |
| 415 | mangleCVQualifiers(T.getCVRQualifiers()); |
| 416 | |
| 417 | // ::= <builtin-type> |
Anders Carlsson | 4843e58 | 2009-03-10 17:07:44 +0000 | [diff] [blame] | 418 | if (const BuiltinType *BT = dyn_cast<BuiltinType>(T.getTypePtr())) |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 419 | mangleType(BT); |
| 420 | // ::= <function-type> |
| 421 | else if (const FunctionType *FT = dyn_cast<FunctionType>(T.getTypePtr())) |
| 422 | mangleType(FT); |
| 423 | // ::= <class-enum-type> |
| 424 | else if (const TagType *TT = dyn_cast<TagType>(T.getTypePtr())) |
| 425 | mangleType(TT); |
| 426 | // ::= <array-type> |
| 427 | else if (const ArrayType *AT = dyn_cast<ArrayType>(T.getTypePtr())) |
| 428 | mangleType(AT); |
| 429 | // ::= <pointer-to-member-type> |
| 430 | else if (const MemberPointerType *MPT |
| 431 | = dyn_cast<MemberPointerType>(T.getTypePtr())) |
| 432 | mangleType(MPT); |
| 433 | // ::= <template-param> |
| 434 | else if (const TemplateTypeParmType *TypeParm |
| 435 | = dyn_cast<TemplateTypeParmType>(T.getTypePtr())) |
| 436 | mangleType(TypeParm); |
| 437 | // FIXME: ::= <template-template-param> <template-args> |
| 438 | // FIXME: ::= <substitution> # See Compression below |
| 439 | // ::= P <type> # pointer-to |
| 440 | else if (const PointerType *PT = dyn_cast<PointerType>(T.getTypePtr())) { |
| 441 | Out << 'P'; |
| 442 | mangleType(PT->getPointeeType()); |
| 443 | } |
| 444 | // ::= R <type> # reference-to |
Sebastian Redl | 7c80bd6 | 2009-03-16 23:22:08 +0000 | [diff] [blame] | 445 | else if (const LValueReferenceType *RT = |
| 446 | dyn_cast<LValueReferenceType>(T.getTypePtr())) { |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 447 | Out << 'R'; |
| 448 | mangleType(RT->getPointeeType()); |
| 449 | } |
Sebastian Redl | 7c80bd6 | 2009-03-16 23:22:08 +0000 | [diff] [blame] | 450 | // ::= O <type> # rvalue reference-to (C++0x) |
| 451 | else if (const RValueReferenceType *RT = |
| 452 | dyn_cast<RValueReferenceType>(T.getTypePtr())) { |
| 453 | Out << 'O'; |
| 454 | mangleType(RT->getPointeeType()); |
| 455 | } |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 456 | // ::= C <type> # complex pair (C 2000) |
| 457 | else if (const ComplexType *CT = dyn_cast<ComplexType>(T.getTypePtr())) { |
| 458 | Out << 'C'; |
| 459 | mangleType(CT->getElementType()); |
| 460 | } else if (const VectorType *VT = dyn_cast<VectorType>(T.getTypePtr())) { |
| 461 | // GNU extension: vector types |
| 462 | Out << "U8__vector"; |
| 463 | mangleType(VT->getElementType()); |
Anders Carlsson | a40c5e4 | 2009-03-07 22:03:21 +0000 | [diff] [blame] | 464 | } else if (const ObjCInterfaceType *IT = |
| 465 | dyn_cast<ObjCInterfaceType>(T.getTypePtr())) { |
| 466 | mangleType(IT); |
Anders Carlsson | 4843e58 | 2009-03-10 17:07:44 +0000 | [diff] [blame] | 467 | } |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 468 | // FIXME: ::= G <type> # imaginary (C 2000) |
| 469 | // FIXME: ::= U <source-name> <type> # vendor extended type qualifier |
| 470 | else |
| 471 | assert(false && "Cannot mangle unknown type"); |
| 472 | } |
| 473 | |
| 474 | void CXXNameMangler::mangleType(const BuiltinType *T) { |
| 475 | // <builtin-type> ::= v # void |
| 476 | // ::= w # wchar_t |
| 477 | // ::= b # bool |
| 478 | // ::= c # char |
| 479 | // ::= a # signed char |
| 480 | // ::= h # unsigned char |
| 481 | // ::= s # short |
| 482 | // ::= t # unsigned short |
| 483 | // ::= i # int |
| 484 | // ::= j # unsigned int |
| 485 | // ::= l # long |
| 486 | // ::= m # unsigned long |
| 487 | // ::= x # long long, __int64 |
| 488 | // ::= y # unsigned long long, __int64 |
| 489 | // ::= n # __int128 |
| 490 | // UNSUPPORTED: ::= o # unsigned __int128 |
| 491 | // ::= f # float |
| 492 | // ::= d # double |
| 493 | // ::= e # long double, __float80 |
| 494 | // UNSUPPORTED: ::= g # __float128 |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 495 | // UNSUPPORTED: ::= Dd # IEEE 754r decimal floating point (64 bits) |
| 496 | // UNSUPPORTED: ::= De # IEEE 754r decimal floating point (128 bits) |
| 497 | // UNSUPPORTED: ::= Df # IEEE 754r decimal floating point (32 bits) |
| 498 | // UNSUPPORTED: ::= Dh # IEEE 754r half-precision floating point (16 bits) |
| 499 | // UNSUPPORTED: ::= Di # char32_t |
| 500 | // UNSUPPORTED: ::= Ds # char16_t |
| 501 | // ::= u <source-name> # vendor extended type |
| 502 | switch (T->getKind()) { |
| 503 | case BuiltinType::Void: Out << 'v'; break; |
| 504 | case BuiltinType::Bool: Out << 'b'; break; |
| 505 | case BuiltinType::Char_U: case BuiltinType::Char_S: Out << 'c'; break; |
| 506 | case BuiltinType::UChar: Out << 'h'; break; |
| 507 | case BuiltinType::UShort: Out << 't'; break; |
| 508 | case BuiltinType::UInt: Out << 'j'; break; |
| 509 | case BuiltinType::ULong: Out << 'm'; break; |
| 510 | case BuiltinType::ULongLong: Out << 'y'; break; |
| 511 | case BuiltinType::SChar: Out << 'a'; break; |
| 512 | case BuiltinType::WChar: Out << 'w'; break; |
| 513 | case BuiltinType::Short: Out << 's'; break; |
| 514 | case BuiltinType::Int: Out << 'i'; break; |
| 515 | case BuiltinType::Long: Out << 'l'; break; |
| 516 | case BuiltinType::LongLong: Out << 'x'; break; |
| 517 | case BuiltinType::Float: Out << 'f'; break; |
| 518 | case BuiltinType::Double: Out << 'd'; break; |
| 519 | case BuiltinType::LongDouble: Out << 'e'; break; |
| 520 | |
| 521 | case BuiltinType::Overload: |
| 522 | case BuiltinType::Dependent: |
| 523 | assert(false && |
| 524 | "Overloaded and dependent types shouldn't get to name mangling"); |
| 525 | break; |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | void CXXNameMangler::mangleType(const FunctionType *T) { |
| 530 | // <function-type> ::= F [Y] <bare-function-type> E |
| 531 | Out << 'F'; |
| 532 | // FIXME: We don't have enough information in the AST to produce the |
| 533 | // 'Y' encoding for extern "C" function types. |
| 534 | mangleBareFunctionType(T, /*MangleReturnType=*/true); |
| 535 | Out << 'E'; |
| 536 | } |
| 537 | |
| 538 | void CXXNameMangler::mangleBareFunctionType(const FunctionType *T, |
| 539 | bool MangleReturnType) { |
| 540 | // <bare-function-type> ::= <signature type>+ |
| 541 | if (MangleReturnType) |
| 542 | mangleType(T->getResultType()); |
| 543 | |
Douglas Gregor | 72564e7 | 2009-02-26 23:50:07 +0000 | [diff] [blame] | 544 | const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(T); |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 545 | assert(Proto && "Can't mangle K&R function prototypes"); |
| 546 | |
Anders Carlsson | c6c91bc | 2009-04-01 00:15:23 +0000 | [diff] [blame] | 547 | if (Proto->getNumArgs() == 0) { |
| 548 | Out << 'v'; |
| 549 | return; |
| 550 | } |
| 551 | |
Douglas Gregor | 72564e7 | 2009-02-26 23:50:07 +0000 | [diff] [blame] | 552 | for (FunctionProtoType::arg_type_iterator Arg = Proto->arg_type_begin(), |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 553 | ArgEnd = Proto->arg_type_end(); |
| 554 | Arg != ArgEnd; ++Arg) |
| 555 | mangleType(*Arg); |
Douglas Gregor | 219cc61 | 2009-02-13 01:28:03 +0000 | [diff] [blame] | 556 | |
| 557 | // <builtin-type> ::= z # ellipsis |
| 558 | if (Proto->isVariadic()) |
| 559 | Out << 'z'; |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 560 | } |
| 561 | |
| 562 | void CXXNameMangler::mangleType(const TagType *T) { |
| 563 | // <class-enum-type> ::= <name> |
Anders Carlsson | 4843e58 | 2009-03-10 17:07:44 +0000 | [diff] [blame] | 564 | |
| 565 | if (!T->getDecl()->getIdentifier()) |
| 566 | mangleName(T->getDecl()->getTypedefForAnonDecl()); |
| 567 | else |
| 568 | mangleName(T->getDecl()); |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 569 | } |
| 570 | |
| 571 | void CXXNameMangler::mangleType(const ArrayType *T) { |
| 572 | // <array-type> ::= A <positive dimension number> _ <element type> |
| 573 | // ::= A [<dimension expression>] _ <element type> |
| 574 | Out << 'A'; |
| 575 | if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(T)) |
| 576 | Out << CAT->getSize(); |
| 577 | else if (const VariableArrayType *VAT = dyn_cast<VariableArrayType>(T)) |
| 578 | mangleExpression(VAT->getSizeExpr()); |
| 579 | else if (const DependentSizedArrayType *DSAT |
| 580 | = dyn_cast<DependentSizedArrayType>(T)) |
| 581 | mangleExpression(DSAT->getSizeExpr()); |
| 582 | |
| 583 | Out << '_'; |
| 584 | mangleType(T->getElementType()); |
| 585 | } |
| 586 | |
| 587 | void CXXNameMangler::mangleType(const MemberPointerType *T) { |
| 588 | // <pointer-to-member-type> ::= M <class type> <member type> |
| 589 | Out << 'M'; |
| 590 | mangleType(QualType(T->getClass(), 0)); |
| 591 | mangleType(T->getPointeeType()); |
| 592 | } |
| 593 | |
| 594 | void CXXNameMangler::mangleType(const TemplateTypeParmType *T) { |
| 595 | // <template-param> ::= T_ # first template parameter |
| 596 | // ::= T <parameter-2 non-negative number> _ |
| 597 | if (T->getIndex() == 0) |
| 598 | Out << "T_"; |
| 599 | else |
| 600 | Out << 'T' << (T->getIndex() - 1) << '_'; |
| 601 | } |
| 602 | |
Anders Carlsson | a40c5e4 | 2009-03-07 22:03:21 +0000 | [diff] [blame] | 603 | void CXXNameMangler::mangleType(const ObjCInterfaceType *T) { |
| 604 | mangleSourceName(T->getDecl()->getIdentifier()); |
| 605 | } |
| 606 | |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 607 | void CXXNameMangler::mangleExpression(Expr *E) { |
| 608 | assert(false && "Cannot mangle expressions yet"); |
| 609 | } |
| 610 | |
Anders Carlsson | 3ac86b5 | 2009-04-15 05:36:58 +0000 | [diff] [blame] | 611 | void CXXNameMangler::mangleCXXCtorType(CXXCtorType T) { |
| 612 | // <ctor-dtor-name> ::= C1 # complete object constructor |
| 613 | // ::= C2 # base object constructor |
| 614 | // ::= C3 # complete object allocating constructor |
| 615 | // |
| 616 | switch (T) { |
| 617 | case Ctor_Complete: |
| 618 | Out << "C1"; |
| 619 | break; |
| 620 | case Ctor_Base: |
| 621 | Out << "C2"; |
| 622 | break; |
| 623 | case Ctor_CompleteAllocating: |
| 624 | Out << "C3"; |
| 625 | break; |
| 626 | } |
| 627 | } |
| 628 | |
Anders Carlsson | 27ae536 | 2009-04-17 01:58:57 +0000 | [diff] [blame^] | 629 | void CXXNameMangler::mangleCXXDtorType(CXXDtorType T) { |
| 630 | // <ctor-dtor-name> ::= D0 # deleting destructor |
| 631 | // ::= D1 # complete object destructor |
| 632 | // ::= D2 # base object destructor |
| 633 | // |
| 634 | switch (T) { |
| 635 | case Dtor_Deleting: |
| 636 | Out << "D0"; |
| 637 | break; |
| 638 | case Dtor_Complete: |
| 639 | Out << "D1"; |
| 640 | break; |
| 641 | case Dtor_Base: |
| 642 | Out << "D2"; |
| 643 | break; |
| 644 | } |
| 645 | } |
| 646 | |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 647 | namespace clang { |
| 648 | /// \brief Mangles the name of the declaration D and emits that name |
| 649 | /// to the given output stream. |
| 650 | /// |
| 651 | /// If the declaration D requires a mangled name, this routine will |
| 652 | /// emit that mangled name to \p os and return true. Otherwise, \p |
| 653 | /// os will be unchanged and this routine will return false. In this |
| 654 | /// case, the caller should just emit the identifier of the declaration |
| 655 | /// (\c D->getIdentifier()) as its name. |
| 656 | bool mangleName(const NamedDecl *D, ASTContext &Context, |
| 657 | llvm::raw_ostream &os) { |
| 658 | CXXNameMangler Mangler(Context, os); |
Douglas Gregor | 6ec3668 | 2009-02-18 23:53:56 +0000 | [diff] [blame] | 659 | if (!Mangler.mangle(D)) |
| 660 | return false; |
| 661 | |
| 662 | os.flush(); |
| 663 | return true; |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 664 | } |
Anders Carlsson | 41aa8c1 | 2009-04-13 18:02:10 +0000 | [diff] [blame] | 665 | |
Anders Carlsson | 3ac86b5 | 2009-04-15 05:36:58 +0000 | [diff] [blame] | 666 | /// mangleGuardVariable - Returns the mangled name for a guard variable |
| 667 | /// for the passed in VarDecl. |
Anders Carlsson | 41aa8c1 | 2009-04-13 18:02:10 +0000 | [diff] [blame] | 668 | void mangleGuardVariable(const VarDecl *D, ASTContext &Context, |
| 669 | llvm::raw_ostream &os) { |
| 670 | CXXNameMangler Mangler(Context, os); |
| 671 | Mangler.mangleGuardVariable(D); |
| 672 | |
| 673 | os.flush(); |
| 674 | } |
Anders Carlsson | 3ac86b5 | 2009-04-15 05:36:58 +0000 | [diff] [blame] | 675 | |
| 676 | void mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type, |
| 677 | ASTContext &Context, llvm::raw_ostream &os) { |
| 678 | CXXNameMangler Mangler(Context, os); |
| 679 | Mangler.mangleCXXCtor(D, Type); |
| 680 | |
| 681 | os.flush(); |
| 682 | } |
Anders Carlsson | 27ae536 | 2009-04-17 01:58:57 +0000 | [diff] [blame^] | 683 | |
| 684 | void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type, |
| 685 | ASTContext &Context, llvm::raw_ostream &os) { |
| 686 | CXXNameMangler Mangler(Context, os); |
| 687 | Mangler.mangleCXXDtor(D, Type); |
| 688 | |
| 689 | os.flush(); |
| 690 | } |
| 691 | |
| 692 | |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 693 | } |
| 694 | |