Make sure that Type::getAs<ArrayType>() (or Type::getAs<subclass of
ArrayType>()) does not instantiate. Update all callers that used this
unsafe feature to use the appropriate ASTContext::getAs*ArrayType method.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86596 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index cfea66b..8bd934a 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -3596,7 +3596,7 @@
         // template <typename... Args> void f(Args... args) {
         //   int vals[] = { args };
         // }
-        const IncompleteArrayType *IAT = T->getAs<IncompleteArrayType>();
+        const IncompleteArrayType *IAT = Context.getAsIncompleteArrayType(T);
         Expr *Init = IDecl->getInit();
         if (IAT && Init &&
             (Init->isTypeDependent() || Init->isValueDependent())) {
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 69dac7d..69e5a52 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -2982,7 +2982,7 @@
 
   QualType PointeeTy = PointerTy->getPointeeType();
   unsigned BaseCVR = PointeeTy.getCVRQualifiers();
-  if (const ConstantArrayType *Array = PointeeTy->getAs<ConstantArrayType>())
+  if (const ConstantArrayType *Array =Context.getAsConstantArrayType(PointeeTy))
     BaseCVR = Array->getElementType().getCVRQualifiers();
   bool hasVolatile = VisibleQuals.hasVolatile();
   bool hasRestrict = VisibleQuals.hasRestrict();
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 93ef1ea..00dc809 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -1704,7 +1704,7 @@
   // class template specialization, or an array with known size of such,
   // try to instantiate it.
   QualType MaybeTemplate = T;
-  if (const ConstantArrayType *Array = T->getAs<ConstantArrayType>())
+  if (const ConstantArrayType *Array = Context.getAsConstantArrayType(T))
     MaybeTemplate = Array->getElementType();
   if (const RecordType *Record = MaybeTemplate->getAs<RecordType>()) {
     if (ClassTemplateSpecializationDecl *ClassTemplateSpec