From: David Majnemer Date: Thu, 23 Apr 2015 07:42:08 +0000 (+0000) Subject: [MS ABI] Add support for mangling VLA types X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=357f5e5741726a8341c627598ccedabc51cf55fb;p=clang [MS ABI] Add support for mangling VLA types Treat a VLA type like an incomplete array type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235575 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/MicrosoftMangle.cpp b/lib/AST/MicrosoftMangle.cpp index 6c953421db..613f2c51c2 100644 --- a/lib/AST/MicrosoftMangle.cpp +++ b/lib/AST/MicrosoftMangle.cpp @@ -1877,19 +1877,21 @@ void MicrosoftCXXNameMangler::mangleArrayType(const ArrayType *T) { QualType ElementTy(T, 0); SmallVector 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'; // ::= # number of extra dimensions diff --git a/test/CodeGenCXX/mangle-ms-arg-qualifiers.cpp b/test/CodeGenCXX/mangle-ms-arg-qualifiers.cpp index 41aa89b61a..ad0299ea5c 100644 --- a/test/CodeGenCXX/mangle-ms-arg-qualifiers.cpp +++ b/test/CodeGenCXX/mangle-ms-arg-qualifiers.cpp @@ -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"