Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit e709c56

Browse files
committed
[OPENMP] Fix for PR31643: Clang crashes when compiling code on Windows
with SEH and openmp In some cituations (during codegen for Windows SEH constructs) CodeGenFunction instance may have CurFn equal to nullptr. OpenMP related code does not expect such situation during cleanup. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@292590 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent d57ab75 commit e709c56

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

lib/CodeGen/CodeGenFunction.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,8 @@ CodeGenFunction::~CodeGenFunction() {
112112
if (FirstBlockInfo)
113113
destroyBlockInfos(FirstBlockInfo);
114114

115-
if (getLangOpts().OpenMP) {
115+
if (getLangOpts().OpenMP && CurFn)
116116
CGM.getOpenMPRuntime().functionFinished(*this);
117-
}
118117
}
119118

120119
CharUnits CodeGenFunction::getNaturalPointeeTypeAlignment(QualType T,

test/OpenMP/openmp_seh.c

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %clang_cc1 -verify -triple x86_64-pc-windows-msvc19.0.0 -fopenmp -fms-compatibility -x c++ -emit-llvm %s -o - | FileCheck %s
2+
// expected-no-diagnostics
3+
// REQUIRES: x86-registered-target
4+
extern "C" {
5+
void __cpuid(int[4], int);
6+
}
7+
8+
// CHECK-LABEL: @main
9+
int main(void) {
10+
__try {
11+
int info[4];
12+
__cpuid(info, 1);
13+
} __except (1) {
14+
}
15+
16+
return 0;
17+
}
18+

0 commit comments

Comments
 (0)