forked from OSchip/llvm-project
Sema: Don't crash when __try/__except/__finally appears in a template function
We wouldn't transform the compound statement in any of these forms, causing crashes when it got time to act on them. Additionally, we wouldn't check to see if the handler was invalid before deciding whether or not we should continue acting on the __try. This fixes PR17584. llvm-svn: 192682
This commit is contained in:
parent
6af6ff1e15
commit
7e75550fa1
|
@ -6233,10 +6233,13 @@ TreeTransform<Derived>::TransformMSPropertyRefExpr(MSPropertyRefExpr *E) {
|
|||
template<typename Derived>
|
||||
StmtResult
|
||||
TreeTransform<Derived>::TransformSEHTryStmt(SEHTryStmt *S) {
|
||||
StmtResult TryBlock; // = getDerived().TransformCompoundStmt(S->getTryBlock());
|
||||
StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
|
||||
if(TryBlock.isInvalid()) return StmtError();
|
||||
|
||||
StmtResult Handler = getDerived().TransformSEHHandler(S->getHandler());
|
||||
if (Handler.isInvalid())
|
||||
return StmtError();
|
||||
|
||||
if(!getDerived().AlwaysRebuild() &&
|
||||
TryBlock.get() == S->getTryBlock() &&
|
||||
Handler.get() == S->getHandler())
|
||||
|
@ -6251,7 +6254,7 @@ TreeTransform<Derived>::TransformSEHTryStmt(SEHTryStmt *S) {
|
|||
template<typename Derived>
|
||||
StmtResult
|
||||
TreeTransform<Derived>::TransformSEHFinallyStmt(SEHFinallyStmt *S) {
|
||||
StmtResult Block; // = getDerived().TransformCompoundStatement(S->getBlock());
|
||||
StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
|
||||
if(Block.isInvalid()) return StmtError();
|
||||
|
||||
return getDerived().RebuildSEHFinallyStmt(S->getFinallyLoc(),
|
||||
|
@ -6264,7 +6267,7 @@ TreeTransform<Derived>::TransformSEHExceptStmt(SEHExceptStmt *S) {
|
|||
ExprResult FilterExpr = getDerived().TransformExpr(S->getFilterExpr());
|
||||
if(FilterExpr.isInvalid()) return StmtError();
|
||||
|
||||
StmtResult Block; // = getDerived().TransformCompoundStatement(S->getBlock());
|
||||
StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
|
||||
if(Block.isInvalid()) return StmtError();
|
||||
|
||||
return getDerived().RebuildSEHExceptStmt(S->getExceptLoc(),
|
||||
|
|
|
@ -57,3 +57,23 @@ int main()
|
|||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
namespace PR17584 {
|
||||
template <typename>
|
||||
void Except() {
|
||||
__try {
|
||||
} __except(true) {
|
||||
}
|
||||
}
|
||||
|
||||
template <typename>
|
||||
void Finally() {
|
||||
__try {
|
||||
} __finally {
|
||||
}
|
||||
}
|
||||
|
||||
template void Except<void>();
|
||||
template void Finally<void>();
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue