Richard Smith pointed out that there already is a proposal for init list mangling.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151462 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Sebastian Redl 2012-02-25 22:59:28 +00:00
Родитель 8ed20910d8
Коммит faf4ef62b6
2 изменённых файлов: 21 добавлений и 12 удалений

Просмотреть файл

@ -2361,7 +2361,6 @@ recurse:
llvm_unreachable("unexpected statement kind");
// FIXME: invent manglings for all these.
case Expr::InitListExprClass:
case Expr::BlockExprClass:
case Expr::CXXPseudoDestructorExprClass:
case Expr::ChooseExprClass:
@ -2418,6 +2417,16 @@ recurse:
case Expr::OpaqueValueExprClass:
llvm_unreachable("cannot mangle opaque value; mangling wrong thing?");
case Expr::InitListExprClass: {
// Proposal by Jason Merrill, 2012-01-03
Out << "il";
const InitListExpr *InitList = cast<InitListExpr>(E);
for (unsigned i = 0, e = InitList->getNumInits(); i != e; ++i)
mangleExpression(InitList->getInit(i));
Out << "E";
break;
}
case Expr::CXXDefaultArgExprClass:
mangleExpression(cast<CXXDefaultArgExpr>(E)->getExpr(), Arity);
break;
@ -2463,12 +2472,9 @@ recurse:
Out << '_';
mangleType(New->getAllocatedType());
if (New->hasInitializer()) {
// <initializer> is 'pi <expression>* E' in the current ABI for
// parenthesized initializers, but braced initializers are unspecified.
// We use 'bl <expression>* E' for "braced list". "bi" is too easy to
// confuse.
// Proposal by Jason Merrill, 2012-01-03
if (New->getInitializationStyle() == CXXNewExpr::ListInit)
Out << "bl";
Out << "il";
else
Out << "pi";
const Expr *Init = New->getInitializer();
@ -2483,7 +2489,7 @@ recurse:
mangleExpression(PLE->getExpr(i));
} else if (New->getInitializationStyle() == CXXNewExpr::ListInit &&
isa<InitListExpr>(Init)) {
// Only take ParenListExprs apart for list-initialization.
// Only take InitListExprs apart for list-initialization.
const InitListExpr *InitList = cast<InitListExpr>(Init);
for (unsigned i = 0, e = InitList->getNumInits(); i != e; ++i)
mangleExpression(InitList->getInit(i));
@ -2552,7 +2558,11 @@ recurse:
const CXXConstructExpr *CE = cast<CXXConstructExpr>(E);
unsigned N = CE->getNumArgs();
Out << "cv";
// Proposal by Jason Merrill, 2012-01-03
if (CE->isListInitialization())
Out << "tl";
else
Out << "cv";
mangleType(CE->getType());
if (N != 1) Out << '_';
for (unsigned I = 0; I != N; ++I) mangleExpression(CE->getArg(I));

Просмотреть файл

@ -168,7 +168,6 @@ namespace test3 {
namespace test4 {
struct X {
X(int);
X(std::initializer_list<int>);
};
template <typename T>
@ -186,9 +185,9 @@ namespace test4 {
// CHECK: void @_ZN5test43tf1INS_1XEEEvDTnw_T_piLi1EEE
template void tf1<X>(X*);
// FIXME: Need mangling for braced initializers
//template void tf2<X>(X*);
// CHECK: void @_ZN5test43tf2INS_1XEEEvDTnw_T_piilLi1EEEE
template void tf2<X>(X*);
// CHECK: void @_ZN5test43tf3INS_1XEEEvDTnw_T_blLi1EEE
// CHECK: void @_ZN5test43tf3INS_1XEEEvDTnw_T_ilLi1EEE
template void tf3<X>(X*);
}