diff options
author | David Majnemer <david.majnemer@gmail.com> | 2015-04-23 07:42:08 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2015-04-23 07:42:08 +0000 |
commit | 9595b7da1a8da65b7feaa6cde9e57a4846e543e0 (patch) | |
tree | d434105f5bcc80a69e767a8fd72523303aeeca44 /clang | |
parent | e8659b5df619b0915ed6d71fe544d8514a11334a (diff) | |
download | bcm5719-llvm-9595b7da1a8da65b7feaa6cde9e57a4846e543e0.tar.gz bcm5719-llvm-9595b7da1a8da65b7feaa6cde9e57a4846e543e0.zip |
[MS ABI] Add support for mangling VLA types
Treat a VLA type like an incomplete array type.
llvm-svn: 235575
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/AST/MicrosoftMangle.cpp | 25 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/mangle-ms-arg-qualifiers.cpp | 4 |
2 files changed, 16 insertions, 13 deletions
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index 6c953421dbe..613f2c51c2b 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -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 diff --git a/clang/test/CodeGenCXX/mangle-ms-arg-qualifiers.cpp b/clang/test/CodeGenCXX/mangle-ms-arg-qualifiers.cpp index 41aa89b61aa..ad0299ea5c1 100644 --- a/clang/test/CodeGenCXX/mangle-ms-arg-qualifiers.cpp +++ b/clang/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" |