summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-07-30 23:48:14 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-07-30 23:48:14 +0000
commit7f78227ce95722f70de3c3b8b33dc0d83375db46 (patch)
tree013be5a78923ef0b482170489b1b59c7df7c994e /clang/lib/Sema/SemaDeclCXX.cpp
parent535a23c38b63adf1bb4a3c5be05db2832a73ba55 (diff)
downloadbcm5719-llvm-7f78227ce95722f70de3c3b8b33dc0d83375db46.tar.gz
bcm5719-llvm-7f78227ce95722f70de3c3b8b33dc0d83375db46.zip
PR13479: If we see the definition of an out-of-line destructor in C++11, be
sure to update the exception specification on the declaration as well as the definition. If we're building in -fno-exceptions mode, nothing else will trigger it to be updated. llvm-svn: 161008
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp34
1 files changed, 26 insertions, 8 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 9c4272de0c5..fae0b165ceb 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -4007,19 +4007,37 @@ computeImplicitExceptionSpec(Sema &S, SourceLocation Loc, CXXMethodDecl *MD) {
llvm_unreachable("only special members have implicit exception specs");
}
+static void
+updateExceptionSpec(Sema &S, FunctionDecl *FD, const FunctionProtoType *FPT,
+ const Sema::ImplicitExceptionSpecification &ExceptSpec) {
+ FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
+ ExceptSpec.getEPI(EPI);
+ const FunctionProtoType *NewFPT = cast<FunctionProtoType>(
+ S.Context.getFunctionType(FPT->getResultType(), FPT->arg_type_begin(),
+ FPT->getNumArgs(), EPI));
+ FD->setType(QualType(NewFPT, 0));
+}
+
void Sema::EvaluateImplicitExceptionSpec(SourceLocation Loc, CXXMethodDecl *MD) {
const FunctionProtoType *FPT = MD->getType()->castAs<FunctionProtoType>();
if (FPT->getExceptionSpecType() != EST_Unevaluated)
return;
- // Evaluate the exception specification and update the type of the special
- // member to use it.
- FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
- computeImplicitExceptionSpec(*this, Loc, MD).getEPI(EPI);
- const FunctionProtoType *NewFPT = cast<FunctionProtoType>(
- Context.getFunctionType(FPT->getResultType(), FPT->arg_type_begin(),
- FPT->getNumArgs(), EPI));
- MD->setType(QualType(NewFPT, 0));
+ // Evaluate the exception specification.
+ ImplicitExceptionSpecification ExceptSpec =
+ computeImplicitExceptionSpec(*this, Loc, MD);
+
+ // Update the type of the special member to use it.
+ updateExceptionSpec(*this, MD, FPT, ExceptSpec);
+
+ // A user-provided destructor can be defined outside the class. When that
+ // happens, be sure to update the exception specification on both
+ // declarations.
+ const FunctionProtoType *CanonicalFPT =
+ MD->getCanonicalDecl()->getType()->castAs<FunctionProtoType>();
+ if (CanonicalFPT->getExceptionSpecType() == EST_Unevaluated)
+ updateExceptionSpec(*this, MD->getCanonicalDecl(),
+ CanonicalFPT, ExceptSpec);
}
static bool isImplicitCopyCtorArgConst(Sema &S, CXXRecordDecl *ClassDecl);
OpenPOWER on IntegriCloud