[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.

llvm-svn: 214458
This commit is contained in:
Richard Smith
2014-07-31 23:46:44 +00:00
parent b7e2f6015a
commit 6de7a24782
6 changed files with 188 additions and 49 deletions

View File

@@ -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<FunctionProtoType>();
for (auto *Redecl : FD->redecls()) {
auto *RedeclFD = dyn_cast<FunctionDecl>(Redecl);
const FunctionProtoType *Proto =
RedeclFD->getType()->castAs<FunctionProtoType>();
// Overwrite the exception spec and rebuild the function type.
FD->setType(Context.getFunctionType(
Proto->getReturnType(), Proto->getParamTypes(),
Proto->getExtProtoInfo().withExceptionSpec(ESI)));
// 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))