Fix a crash mangling decayed val argument-typed function.
// rdar: //8620510 and PR7666
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118019 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp
index e47d9cb..37ecf28 100644
--- a/lib/CodeGen/Mangle.cpp
+++ b/lib/CodeGen/Mangle.cpp
@@ -1324,7 +1324,9 @@
}
void CXXNameMangler::mangleType(const VariableArrayType *T) {
Out << 'A';
- mangleExpression(T->getSizeExpr());
+ // decayed vla types (size 0) will just be skipped.
+ if (T->getSizeExpr())
+ mangleExpression(T->getSizeExpr());
Out << '_';
mangleType(T->getElementType());
}
diff --git a/test/CodeGenCXX/mangle.cpp b/test/CodeGenCXX/mangle.cpp
index 55357c7..e78ad39 100644
--- a/test/CodeGenCXX/mangle.cpp
+++ b/test/CodeGenCXX/mangle.cpp
@@ -624,3 +624,9 @@
template <class T> void test1(decltype(f<>(T()))) {}
template void test1<int>(decltype(f<>(int())));
}
+
+// rdar:// 8620510
+namespace test21 {
+ // CHECK: define void @_ZN6test2112vla_arg_funcEiPA_i(
+ void vla_arg_func(int X, int a[X][X]) {}
+}