[cfe-commits] r80747 - in /cfe/trunk/lib/CodeGen: Mangle.cpp Mangle.h
Mike Stump
mrs at apple.com
Tue Sep 1 17:56:18 PDT 2009
Author: mrs
Date: Tue Sep 1 19:56:18 2009
New Revision: 80747
URL: http://llvm.org/viewvc/llvm-project?rev=80747&view=rev
Log:
Add mangling for covariant thunks.
Modified:
cfe/trunk/lib/CodeGen/Mangle.cpp
cfe/trunk/lib/CodeGen/Mangle.h
Modified: cfe/trunk/lib/CodeGen/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.cpp?rev=80747&r1=80746&r2=80747&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Tue Sep 1 19:56:18 2009
@@ -39,7 +39,11 @@
: Context(C), Out(os), Structor(0), StructorType(0) { }
bool mangle(const NamedDecl *D);
+ void mangleCalloffset(bool Virtual, int64_t nv, int64_t v);
void mangleThunk(const NamedDecl *ND, bool Virtual, int64_t nv, int64_t v);
+ void mangleCovariantThunk(const NamedDecl *ND, bool VirtualThis,
+ int64_t nv_t, int64_t v_t, bool VirtualResult,
+ int64_t nv_r, int64_t v_r);
void mangleGuardVariable(const VarDecl *D);
void mangleCXXVtable(QualType Type);
@@ -237,24 +241,22 @@
mangleNestedName(ND);
}
-void CXXNameMangler::mangleThunk(const NamedDecl *D, bool Virtual, int64_t nv,
- int64_t v) {
- // <special-name> ::= T <call-offset> <base encoding>
- // # base is the nominal target function of thunk
+void CXXNameMangler::mangleCalloffset(bool Virtual, int64_t nv,
+ int64_t v) {
// <call-offset> ::= h <nv-offset> _
// ::= v <v-offset> _
// <nv-offset> ::= <offset number> # non-virtual base override
// <v-offset> ::= <offset nubmer> _ <virtual offset number>
// # virtual base override, with vcall offset
if (!Virtual) {
- Out << "_Th";
+ Out << "h";
if (nv < 0) {
Out << "n";
nv = -nv;
}
Out << nv;
} else {
- Out << "_Tv";
+ Out << "v";
if (nv < 0) {
Out << "n";
nv = -nv;
@@ -268,6 +270,28 @@
Out << v;
}
Out << "_";
+}
+
+void CXXNameMangler::mangleThunk(const NamedDecl *D, bool Virtual, int64_t nv,
+ int64_t v) {
+ // <special-name> ::= T <call-offset> <base encoding>
+ // # base is the nominal target function of thunk
+ Out << "_T";
+ mangleCalloffset(Virtual, nv, v);
+ mangleName(D);
+}
+
+ void CXXNameMangler::mangleCovariantThunk(const NamedDecl *D,
+ bool VirtualThis, int64_t nv_t,
+ int64_t v_t, bool VirtualResult,
+ int64_t nv_r, int64_t v_r) {
+ // <special-name> ::= Tc <call-offset> <call-offset> <base encoding>
+ // # base is the nominal target function of thunk
+ // # first call-offset is 'this' adjustment
+ // # second call-offset is result adjustment
+ Out << "_Tc";
+ mangleCalloffset(VirtualThis, nv_t, v_t);
+ mangleCalloffset(VirtualResult, nv_r, v_r);
mangleName(D);
}
@@ -845,6 +869,24 @@
os.flush();
}
+ /// \brief Mangles the a covariant thunk for the declaration D and emits that
+ /// name to the given output stream.
+ void mangleCovariantThunk(const NamedDecl *D, bool VirtualThis, int64_t nv_t,
+ int64_t v_t, bool VirtualResult, int64_t nv_r,
+ int64_t v_r, ASTContext &Context,
+ llvm::raw_ostream &os) {
+ // FIXME: Hum, we might have to thunk these, fix.
+ assert(!isa<CXXConstructorDecl>(D) &&
+ "Use mangleCXXCtor for constructor decls!");
+ assert(!isa<CXXDestructorDecl>(D) &&
+ "Use mangleCXXDtor for destructor decls!");
+
+ CXXNameMangler Mangler(Context, os);
+ Mangler.mangleCovariantThunk(D, VirtualThis, nv_t, v_t, VirtualResult,
+ nv_r, v_r);
+ os.flush();
+ }
+
/// mangleGuardVariable - Returns the mangled name for a guard variable
/// for the passed in VarDecl.
void mangleGuardVariable(const VarDecl *D, ASTContext &Context,
Modified: cfe/trunk/lib/CodeGen/Mangle.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.h?rev=80747&r1=80746&r2=80747&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.h (original)
+++ cfe/trunk/lib/CodeGen/Mangle.h Tue Sep 1 19:56:18 2009
@@ -36,6 +36,10 @@
llvm::raw_ostream &os);
void mangleThunk(const NamedDecl *D, bool Virtual, int64_t n, int64_t vn,
ASTContext &Context, llvm::raw_ostream &os);
+ void mangleCovariantThunk(const NamedDecl *D, bool VirtualThis, int64_t nv_t,
+ int64_t v_t, bool VirtualResult, int64_t nv_r,
+ int64_t v_r, ASTContext &Context,
+ llvm::raw_ostream &os);
void mangleGuardVariable(const VarDecl *D, ASTContext &Context,
llvm::raw_ostream &os);
void mangleCXXVtable(QualType T, ASTContext &Context, llvm::raw_ostream &os);
More information about the cfe-commits
mailing list