Author: Olivier Goffart Date: 2021-05-07T13:27:59-07:00 New Revision: c4adc49a1c988e6ea8a340b6245525ef5599812c
URL: https://github.com/llvm/llvm-project/commit/c4adc49a1c988e6ea8a340b6245525ef5599812c DIFF: https://github.com/llvm/llvm-project/commit/c4adc49a1c988e6ea8a340b6245525ef5599812c.diff LOG: [SEH] Fix regression with SEH in noexpect functions Commit 5baea0560160a693b19022c5d0ba637b6b46b2d8 set the CurCodeDecl because it was needed to pass the assert in CodeGenFunction::EmitLValueForLambdaField, But this was not right to do as CodeGenFunction::FinishFunction passes it to EmitEndEHSpec and cause corruption of the EHStack. Revert the part of the commit that changes the CurCodeDecl, and instead adjust the assert to check for a null CurCodeDecl. Differential Revision: https://reviews.llvm.org/D102027 Added: Modified: clang/lib/CodeGen/CGException.cpp clang/lib/CodeGen/CGExpr.cpp clang/test/CodeGenCXX/exceptions-seh.cpp Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp index 078c60c6c4cf4..aa6fe303ff659 100644 --- a/clang/lib/CodeGen/CGException.cpp +++ b/clang/lib/CodeGen/CGException.cpp @@ -1966,7 +1966,6 @@ void CodeGenFunction::startOutlinedSEHHelper(CodeGenFunction &ParentCGF, StartFunction(GlobalDecl(), RetTy, Fn, FnInfo, Args, OutlinedStmt->getBeginLoc(), OutlinedStmt->getBeginLoc()); CurSEHParent = ParentCGF.CurSEHParent; - CurCodeDecl = ParentCGF.CurCodeDecl; CGM.SetInternalFunctionAttributes(GlobalDecl(), CurFn, FnInfo); EmitCapturedLocals(ParentCGF, OutlinedStmt, IsFilter); diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 2a272bf29e04e..3e6e25dc3d2f5 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -4185,8 +4185,10 @@ LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) { /// Given that we are currently emitting a lambda, emit an l-value for /// one of its members. LValue CodeGenFunction::EmitLValueForLambdaField(const FieldDecl *Field) { - assert(cast<CXXMethodDecl>(CurCodeDecl)->getParent()->isLambda()); - assert(cast<CXXMethodDecl>(CurCodeDecl)->getParent() == Field->getParent()); + if (CurCodeDecl) { + assert(cast<CXXMethodDecl>(CurCodeDecl)->getParent()->isLambda()); + assert(cast<CXXMethodDecl>(CurCodeDecl)->getParent() == Field->getParent()); + } QualType LambdaTagType = getContext().getTagDeclType(Field->getParent()); LValue LambdaLV = MakeNaturalAlignAddrLValue(CXXABIThisValue, LambdaTagType); diff --git a/clang/test/CodeGenCXX/exceptions-seh.cpp b/clang/test/CodeGenCXX/exceptions-seh.cpp index a922daac1c0b6..42b76b1dcc5a9 100644 --- a/clang/test/CodeGenCXX/exceptions-seh.cpp +++ b/clang/test/CodeGenCXX/exceptions-seh.cpp @@ -164,3 +164,5 @@ void use_inline() { // CHECK: store i32 1234, i32* @my_unique_global // CHECK: attributes #[[NOINLINE]] = { {{.*noinline.*}} } + +void seh_in_noexcept() noexcept { __try {} __finally {} } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits