diff options
Diffstat (limited to 'clang/lib/AST')
| -rw-r--r-- | clang/lib/AST/Type.cpp | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index e9d474a174c..19a3add700d 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -1625,9 +1625,9 @@ FunctionProtoType::FunctionProtoType(QualType result, ArrayRef<QualType> params, QualType *exnSlot = argSlot + NumParams; unsigned I = 0; for (QualType ExceptionType : epi.ExceptionSpec.Exceptions) { - if (ExceptionType->isDependentType()) - setDependent(); - else if (ExceptionType->isInstantiationDependentType()) + // Note that a dependent exception specification does *not* make + // a type dependent; it's not even part of the C++ type system. + if (ExceptionType->isInstantiationDependentType()) setInstantiationDependent(); if (ExceptionType->containsUnexpandedParameterPack()) @@ -1641,11 +1641,12 @@ FunctionProtoType::FunctionProtoType(QualType result, ArrayRef<QualType> params, *noexSlot = epi.ExceptionSpec.NoexceptExpr; if (epi.ExceptionSpec.NoexceptExpr) { - if (epi.ExceptionSpec.NoexceptExpr->isValueDependent() - || epi.ExceptionSpec.NoexceptExpr->isTypeDependent()) - setDependent(); - else if (epi.ExceptionSpec.NoexceptExpr->isInstantiationDependent()) + if (epi.ExceptionSpec.NoexceptExpr->isValueDependent() || + epi.ExceptionSpec.NoexceptExpr->isInstantiationDependent()) setInstantiationDependent(); + + if (epi.ExceptionSpec.NoexceptExpr->containsUnexpandedParameterPack()) + setContainsUnexpandedParameterPack(); } } else if (getExceptionSpecType() == EST_Uninstantiated) { // Store the function decl from which we will resolve our @@ -1671,6 +1672,18 @@ FunctionProtoType::FunctionProtoType(QualType result, ArrayRef<QualType> params, } } +bool FunctionProtoType::hasDependentExceptionSpec() const { + if (Expr *NE = getNoexceptExpr()) + return NE->isValueDependent(); + 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 (ET->isDependentType() || ET->getAs<PackExpansionType>()) + return true; + return false; +} + FunctionProtoType::NoexceptResult FunctionProtoType::getNoexceptSpec(const ASTContext &ctx) const { ExceptionSpecificationType est = getExceptionSpecType(); |

