From 59aecdb55e33108f7b588d9f0b0a1025d67f9738 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 31 Jul 2014 23:46:44 +0000 Subject: [modules] Maintain an AST invariant across module load/save: if any declaration of a function has a resolved exception specification, then all declarations of the function do. We should probably improve the AST representation to make this implicit (perhaps only store the exception specification on the canonical declaration), but this fixes things for now. The testcase for this (which used to assert) also exposes the actual bug I was trying to reduce here: we sometimes fail to emit the body of an imported special member function definition. Fix for that to follow. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214458 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExceptionSpec.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'lib/Sema/SemaExceptionSpec.cpp') diff --git a/lib/Sema/SemaExceptionSpec.cpp b/lib/Sema/SemaExceptionSpec.cpp index 192b273c7c..e4963b13d6 100644 --- a/lib/Sema/SemaExceptionSpec.cpp +++ b/lib/Sema/SemaExceptionSpec.cpp @@ -135,13 +135,16 @@ Sema::ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT) { void Sema::UpdateExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI) { - const FunctionProtoType *Proto = - FD->getType()->castAs(); - - // Overwrite the exception spec and rebuild the function type. - FD->setType(Context.getFunctionType( - Proto->getReturnType(), Proto->getParamTypes(), - Proto->getExtProtoInfo().withExceptionSpec(ESI))); + for (auto *Redecl : FD->redecls()) { + auto *RedeclFD = dyn_cast(Redecl); + const FunctionProtoType *Proto = + RedeclFD->getType()->castAs(); + + // Overwrite the exception spec and rebuild the function type. + RedeclFD->setType(Context.getFunctionType( + Proto->getReturnType(), Proto->getParamTypes(), + Proto->getExtProtoInfo().withExceptionSpec(ESI))); + } // If we've fully resolved the exception specification, notify listeners. if (!isUnresolvedExceptionSpec(ESI.Type)) -- cgit v1.2.1