Hi Richard,
I am attaching the patch we discussed at the dev meeting. Still
haven't found small reproducer...
The issue appears to stem from the fact that module A contains only a
forward declaration of a function and it exception spec cannot be
computed. In module B is the definition with computed exception spec,
which gets deserialized after the one in module A. This patch teaches
the ASTDeclReader to update all the exception specs of the previous
decls to the current one.
Could you review, please?
Many thanks,
Vassil
Index: lib/Serialization/ASTReaderDecl.cpp
===================================================================
--- lib/Serialization/ASTReaderDecl.cpp (revision 220824)
+++ lib/Serialization/ASTReaderDecl.cpp (working copy)
@@ -2778,13 +2778,27 @@
// specification now.
auto *FPT = FD->getType()->getAs<FunctionProtoType>();
auto *PrevFPT = PrevFD->getType()->getAs<FunctionProtoType>();
- if (FPT && PrevFPT &&
- isUnresolvedExceptionSpec(FPT->getExceptionSpecType()) &&
- !isUnresolvedExceptionSpec(PrevFPT->getExceptionSpecType())) {
- FunctionProtoType::ExtProtoInfo EPI = PrevFPT->getExtProtoInfo();
- FD->setType(Reader.Context.getFunctionType(
+ if (FPT && PrevFPT) {
+ if (isUnresolvedExceptionSpec(FPT->getExceptionSpecType()) &&
+ !isUnresolvedExceptionSpec(PrevFPT->getExceptionSpecType())) {
+ FunctionProtoType::ExtProtoInfo EPI = PrevFPT->getExtProtoInfo();
+ FD->setType(Reader.Context.getFunctionType(
FPT->getReturnType(), FPT->getParamTypes(),
FPT->getExtProtoInfo().withExceptionSpec(EPI.ExceptionSpec)));
+ }
+ else { // FPT->getExceptionSpecType() is resolved and the other is not
+ // Happens in cases where module A contains only fwd decl and module B
+ // contains the definition.
+ FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
+ FunctionProtoType::ExtProtoInfo ExceptionSpec
+ = PrevFPT->getExtProtoInfo().withExceptionSpec(EPI.ExceptionSpec);
+ while (PrevFD) {
+ PrevFD->setType(Reader.Context.getFunctionType(PrevFPT->getReturnType(),
+ PrevFPT->getParamTypes(),
+ ExceptionSpec));
+ PrevFD = PrevFD->getPreviousDecl();
+ }
+ }
}
}
}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits