From: Alexander Kornienko Date: Thu, 18 Sep 2014 15:19:53 +0000 (+0000) Subject: Use exceptions() instead of getNumExceptions()/getExceptionType() to avoid X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b71291c2967670c1cc882eec6552f0e0f014657e;p=clang Use exceptions() instead of getNumExceptions()/getExceptionType() to avoid accesses to incorrect exception types when getExceptionSpecType() != EST_Dynamic This fixes a crash in test/CXX/except/except.spec/template.cpp that happens in certain build configurations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218053 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 07be285ee0..7834bfda6d 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -1673,12 +1673,11 @@ FunctionProtoType::FunctionProtoType(QualType result, ArrayRef params, bool FunctionProtoType::hasDependentExceptionSpec() const { if (Expr *NE = getNoexceptExpr()) return NE->isValueDependent(); - for (unsigned I = 0, N = getNumExceptions(); I != N; ++I) + for (QualType ET : exceptions()) // A pack expansion with a non-dependent pattern is still dependent, // because we don't know whether the pattern is in the exception spec // or not (that depends on whether the pack has 0 expansions). - if (getExceptionType(I)->isDependentType() || - getExceptionType(I)->getAs()) + if (ET->isDependentType() || ET->getAs()) return true; return false; }