[MS ABI] Add support for mangling VLA types

Treat a VLA type like an incomplete array type.

llvm-svn: 235575
This commit is contained in:
David Majnemer 2015-04-23 07:42:08 +00:00
parent e8659b5df6
commit 9595b7da1a
2 changed files with 16 additions and 13 deletions

View File

@ -1877,19 +1877,21 @@ void MicrosoftCXXNameMangler::mangleArrayType(const ArrayType *T) {
QualType ElementTy(T, 0);
SmallVector<llvm::APInt, 3> Dimensions;
for (;;) {
if (const ConstantArrayType *CAT =
getASTContext().getAsConstantArrayType(ElementTy)) {
if (ElementTy->isConstantArrayType()) {
const ConstantArrayType *CAT =
getASTContext().getAsConstantArrayType(ElementTy);
Dimensions.push_back(CAT->getSize());
ElementTy = CAT->getElementType();
} else if (ElementTy->isIncompleteArrayType()) {
const IncompleteArrayType *IAT =
getASTContext().getAsIncompleteArrayType(ElementTy);
Dimensions.push_back(llvm::APInt(32, 0));
ElementTy = IAT->getElementType();
} else if (ElementTy->isVariableArrayType()) {
const VariableArrayType *VAT =
getASTContext().getAsVariableArrayType(ElementTy);
DiagnosticsEngine &Diags = Context.getDiags();
unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
"cannot mangle this variable-length array yet");
Diags.Report(VAT->getSizeExpr()->getExprLoc(), DiagID)
<< VAT->getBracketsRange();
return;
Dimensions.push_back(llvm::APInt(32, 0));
ElementTy = VAT->getElementType();
} else if (ElementTy->isDependentSizedArrayType()) {
// The dependent expression has to be folded into a constant (TODO).
const DependentSizedArrayType *DSAT =
@ -1900,12 +1902,9 @@ void MicrosoftCXXNameMangler::mangleArrayType(const ArrayType *T) {
Diags.Report(DSAT->getSizeExpr()->getExprLoc(), DiagID)
<< DSAT->getBracketsRange();
return;
} else if (const IncompleteArrayType *IAT =
getASTContext().getAsIncompleteArrayType(ElementTy)) {
Dimensions.push_back(llvm::APInt(32, 0));
ElementTy = IAT->getElementType();
} else {
break;
}
else break;
}
Out << 'Y';
// <dimension-count> ::= <number> # number of extra dimensions

View File

@ -263,3 +263,7 @@ struct S {};
void pr23325(const S[1], const S[]) {}
// CHECK: "\01?pr23325@@YAXQBUS@@0@Z"
// X64: "\01?pr23325@@YAXQEBUS@@0@Z"
void vla_arg(int i, int a[][i]) {}
// CHECK: "\01?vla_arg@@YAXHQAY0A@H@Z"
// X64: "\01?vla_arg@@YAXHQEAY0A@H@Z"