Merge pull request #6745 from yebblies/cppmanglert

Let Target determine how to mangle extern(C++) symbols
merged-on-behalf-of: Iain Buclaw <ibuclaw@gdcproject.org>
This commit is contained in:
The Dlang Bot 2017-05-06 19:45:18 +02:00 committed by GitHub
commit 2cc58d9b0e
4 changed files with 1697 additions and 1682 deletions

File diff suppressed because it is too large Load diff

View file

@ -28,6 +28,7 @@ import ddmd.id;
import ddmd.mtype;
import ddmd.root.ctfloat;
import ddmd.root.outbuffer;
import ddmd.target;
import ddmd.utf;
import ddmd.visitor;
@ -451,7 +452,7 @@ public:
buf.writestring(d.ident.toChars());
return;
case LINKcpp:
buf.writestring(toCppMangle(d));
buf.writestring(Target.toCppMangle(d));
return;
case LINKdefault:
d.error("forward declaration");

View file

@ -10,7 +10,10 @@
module ddmd.target;
import ddmd.cppmangle;
import ddmd.dclass;
import ddmd.dmodule;
import ddmd.dsymbol;
import ddmd.expression;
import ddmd.globals;
import ddmd.identifier;
@ -429,6 +432,25 @@ struct Target
break;
}
}
extern (C++) static const(char)* toCppMangle(Dsymbol s)
{
static if (TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS)
return toCppMangleItanium(s);
else static if (TARGET_WINDOS)
return toCppMangleMSVC(s);
else
static assert(0, "fix this");
}
extern (C++) static const(char)* cppTypeInfoMangle(ClassDeclaration cd)
{
static if (TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS)
return cppTypeInfoMangleItanium(cd);
else static if (TARGET_WINDOS)
return cppTypeInfoMangleMSVC(cd);
else
static assert(0, "fix this");
}
}
/******************************

View file

@ -777,7 +777,7 @@ Symbol* toSymbolCpp(ClassDeclaration cd)
*/
Symbol *toSymbolCppTypeInfo(ClassDeclaration cd)
{
const id = cppTypeInfoMangle(cd);
const id = Target.cppTypeInfoMangle(cd);
auto s = symbol_calloc(id, cast(uint)strlen(id));
s.Sclass = SCextern;
s.Sfl = FLextern; // C++ code will provide the definition