diff options
Diffstat (limited to 'lib/Sema/SemaExceptionSpec.cpp')
-rw-r--r-- | lib/Sema/SemaExceptionSpec.cpp | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/lib/Sema/SemaExceptionSpec.cpp b/lib/Sema/SemaExceptionSpec.cpp index 14b2434..63bfa9d 100644 --- a/lib/Sema/SemaExceptionSpec.cpp +++ b/lib/Sema/SemaExceptionSpec.cpp @@ -51,7 +51,8 @@ bool Sema::CheckSpecifiedExceptionType(QualType T, const SourceRange &Range) { // C++ 15.4p2: A type denoted in an exception-specification shall not denote // an incomplete type. if (RequireCompleteType(Range.getBegin(), T, - PDiag(diag::err_incomplete_in_exception_spec) << /*direct*/0 << Range)) + diag::err_incomplete_in_exception_spec, + /*direct*/0, Range)) return true; // C++ 15.4p2: A type denoted in an exception-specification shall not denote @@ -71,8 +72,9 @@ bool Sema::CheckSpecifiedExceptionType(QualType T, const SourceRange &Range) { if (T->isRecordType() && T->getAs<RecordType>()->isBeingDefined()) return false; - if (!T->isVoidType() && RequireCompleteType(Range.getBegin(), T, - PDiag(diag::err_incomplete_in_exception_spec) << kind << Range)) + if (!T->isVoidType() && + RequireCompleteType(Range.getBegin(), T, + diag::err_incomplete_in_exception_spec, kind, Range)) return true; return false; @@ -98,20 +100,22 @@ bool Sema::CheckDistantExceptionSpec(QualType T) { const FunctionProtoType * Sema::ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT) { - // FIXME: If FD is a special member, we should delay computing its exception - // specification until this point. - if (FPT->getExceptionSpecType() != EST_Uninstantiated) + if (!isUnresolvedExceptionSpec(FPT->getExceptionSpecType())) return FPT; FunctionDecl *SourceDecl = FPT->getExceptionSpecDecl(); const FunctionProtoType *SourceFPT = SourceDecl->getType()->castAs<FunctionProtoType>(); - if (SourceFPT->getExceptionSpecType() != EST_Uninstantiated) + // If the exception specification has already been resolved, just return it. + if (!isUnresolvedExceptionSpec(SourceFPT->getExceptionSpecType())) return SourceFPT; - // Instantiate the exception specification now. - InstantiateExceptionSpec(Loc, SourceDecl); + // Compute or instantiate the exception specification now. + if (FPT->getExceptionSpecType() == EST_Unevaluated) + EvaluateImplicitExceptionSpec(Loc, cast<CXXMethodDecl>(SourceDecl)); + else + InstantiateExceptionSpec(Loc, SourceDecl); return SourceDecl->getType()->castAs<FunctionProtoType>(); } @@ -344,8 +348,8 @@ bool Sema::CheckEquivalentExceptionSpec(const PartialDiagnostic &DiagID, ExceptionSpecificationType OldEST = Old->getExceptionSpecType(); ExceptionSpecificationType NewEST = New->getExceptionSpecType(); - assert(OldEST != EST_Delayed && NewEST != EST_Delayed && - OldEST != EST_Uninstantiated && NewEST != EST_Uninstantiated && + assert(!isUnresolvedExceptionSpec(OldEST) && + !isUnresolvedExceptionSpec(NewEST) && "Shouldn't see unknown exception specifications here"); // Shortcut the case where both have no spec. @@ -542,8 +546,8 @@ bool Sema::CheckExceptionSpecSubset( ExceptionSpecificationType SubEST = Subset->getExceptionSpecType(); - assert(SuperEST != EST_Delayed && SubEST != EST_Delayed && - SuperEST != EST_Uninstantiated && SubEST != EST_Uninstantiated && + assert(!isUnresolvedExceptionSpec(SuperEST) && + !isUnresolvedExceptionSpec(SubEST) && "Shouldn't see unknown exception specifications here"); // It does not. If the subset contains everything, we've failed. @@ -806,15 +810,6 @@ static CanThrowResult canCalleeThrow(Sema &S, const Expr *E, if (!FT) return CT_Can; - if (FT->getExceptionSpecType() == EST_Delayed) { - // FIXME: Try to resolve a delayed exception spec in ResolveExceptionSpec. - assert(isa<CXXConstructorDecl>(D) && - "only constructor exception specs can be unknown"); - S.Diag(E->getLocStart(), diag::err_exception_spec_unknown) - << E->getSourceRange(); - return CT_Can; - } - return FT->isNothrow(S.Context) ? CT_Cannot : CT_Can; } @@ -964,7 +959,7 @@ CanThrowResult Sema::canThrow(const Expr *E) { // possibility. case Expr::ObjCArrayLiteralClass: case Expr::ObjCDictionaryLiteralClass: - case Expr::ObjCNumericLiteralClass: + case Expr::ObjCBoxedExprClass: return CT_Can; // Many other things have subexpressions, so we have to test those. |