diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp --- a/clang/lib/AST/ItaniumMangle.cpp +++ b/clang/lib/AST/ItaniumMangle.cpp @@ -3204,7 +3204,11 @@ } void CXXNameMangler::mangleType(const DependentSizedArrayType *T) { Out << 'A'; - mangleExpression(T->getSizeExpr()); + // A DependentSizedArrayType might not have size expression as below + // + // template int arr[] = {N...}; + if (T->getSizeExpr()) + mangleExpression(T->getSizeExpr()); Out << '_'; mangleType(T->getElementType()); } diff --git a/clang/test/AST/ast-dump-array-json.cpp b/clang/test/AST/ast-dump-array-json.cpp new file mode 100644 --- /dev/null +++ b/clang/test/AST/ast-dump-array-json.cpp @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump=json -ast-dump-filter Test %s | FileCheck %s + +template struct A { static const int Test[]; }; +template const int A::Test[] = { N... }; + +// CHECK: "mangledName": "_ZN1A4TestE", +// CHECK: "mangledName": "_ZN1A4TestE",