diff options
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 48 |
1 files changed, 14 insertions, 34 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index d51071440e7..bf79e07f200 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -3420,6 +3420,11 @@ static bool isCanonicalExceptionSpecification( if (ESI.Type == EST_BasicNoexcept) return true; + // A noexcept(expr) specification is (possibly) canonical if expr is + // value-dependent. + if (ESI.Type == EST_DependentNoexcept) + return true; + // A dynamic exception specification is canonical if it only contains pack // expansions (so we can't tell whether it's non-throwing) and all its // contained types are canonical. @@ -3434,11 +3439,6 @@ static bool isCanonicalExceptionSpecification( return AnyPackExpansions; } - // A noexcept(expr) specification is (possibly) canonical if expr is - // value-dependent. - if (ESI.Type == EST_ComputedNoexcept) - return ESI.NoexceptExpr && ESI.NoexceptExpr->isValueDependent(); - return false; } @@ -3466,7 +3466,7 @@ QualType ASTContext::getFunctionTypeInternal( // noexcept expression, or we're just looking for a canonical type. // Otherwise, we're going to need to create a type // sugar node to hold the concrete expression. - if (OnlyWantCanonical || EPI.ExceptionSpec.Type != EST_ComputedNoexcept || + if (OnlyWantCanonical || !isComputedNoexcept(EPI.ExceptionSpec.Type) || EPI.ExceptionSpec.NoexceptExpr == FPT->getNoexceptExpr()) return Existing; @@ -3513,7 +3513,7 @@ QualType ASTContext::getFunctionTypeInternal( // We don't know yet. It shouldn't matter what we pick here; no-one // should ever look at this. LLVM_FALLTHROUGH; - case EST_None: case EST_MSAny: + case EST_None: case EST_MSAny: case EST_NoexceptFalse: CanonicalEPI.ExceptionSpec.Type = EST_None; break; @@ -3535,24 +3535,12 @@ QualType ASTContext::getFunctionTypeInternal( break; } - case EST_DynamicNone: case EST_BasicNoexcept: + case EST_DynamicNone: case EST_BasicNoexcept: case EST_NoexceptTrue: CanonicalEPI.ExceptionSpec.Type = EST_BasicNoexcept; break; - case EST_ComputedNoexcept: - llvm::APSInt Value(1); - auto *E = CanonicalEPI.ExceptionSpec.NoexceptExpr; - if (!E || !E->isIntegerConstantExpr(Value, *this, nullptr, - /*IsEvaluated*/false)) { - // This noexcept specification is invalid. - // FIXME: Should this be able to happen? - CanonicalEPI.ExceptionSpec.Type = EST_None; - break; - } - - CanonicalEPI.ExceptionSpec.Type = - Value.getBoolValue() ? EST_BasicNoexcept : EST_None; - break; + case EST_DependentNoexcept: + llvm_unreachable("dependent noexcept is already canonical"); } } else { CanonicalEPI.ExceptionSpec = FunctionProtoType::ExceptionSpecInfo(); @@ -3577,18 +3565,10 @@ QualType ASTContext::getFunctionTypeInternal( // Instead of the exception types, there could be a noexcept // expression, or information used to resolve the exception // specification. - size_t Size = sizeof(FunctionProtoType) + - NumArgs * sizeof(QualType); - - if (EPI.ExceptionSpec.Type == EST_Dynamic) { - Size += EPI.ExceptionSpec.Exceptions.size() * sizeof(QualType); - } else if (EPI.ExceptionSpec.Type == EST_ComputedNoexcept) { - Size += sizeof(Expr*); - } else if (EPI.ExceptionSpec.Type == EST_Uninstantiated) { - Size += 2 * sizeof(FunctionDecl*); - } else if (EPI.ExceptionSpec.Type == EST_Unevaluated) { - Size += sizeof(FunctionDecl*); - } + size_t Size = + sizeof(FunctionProtoType) + NumArgs * sizeof(QualType) + + FunctionProtoType::getExceptionSpecSize( + EPI.ExceptionSpec.Type, EPI.ExceptionSpec.Exceptions.size()); // Put the ExtParameterInfos last. If all were equal, it would make // more sense to put these before the exception specification, because |