Introduce getConstantArrayElementCount API and use it in
construction/destruction of array members.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79637 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index cf7ad26..0cfb05b 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -2382,6 +2382,17 @@
   return ElemTy;
 }
 
+/// getConstantArrayElementCount - Returns number of constant array elements.
+uint64_t 
+ASTContext::getConstantArrayElementCount(const ConstantArrayType *CA)  const {
+  uint64_t ElementCount = 1;
+  do {
+    ElementCount *= CA->getSize().getZExtValue();
+    CA = dyn_cast<ConstantArrayType>(CA->getElementType());
+  } while (CA);
+  return ElementCount;
+}
+
 /// getFloatingRank - Return a relative rank for floating point types.
 /// This routine will assert if passed a built-in type that isn't a float.
 static FloatingRank getFloatingRank(QualType T) {