Quellcode durchsuchen

[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

Alexey Bataev vor 8 Jahren
Ursprung
Commit
e709c56462
2 geänderte Dateien mit 19 neuen und 2 gelöschten Zeilen
  1. 1 2
      lib/CodeGen/CodeGenFunction.cpp
  2. 18 0
      test/OpenMP/openmp_seh.c

+ 1 - 2
lib/CodeGen/CodeGenFunction.cpp

@@ -112,9 +112,8 @@ CodeGenFunction::~CodeGenFunction() {
   if (FirstBlockInfo)
     destroyBlockInfos(FirstBlockInfo);
 
-  if (getLangOpts().OpenMP) {
+  if (getLangOpts().OpenMP && CurFn)
     CGM.getOpenMPRuntime().functionFinished(*this);
-  }
 }
 
 CharUnits CodeGenFunction::getNaturalPointeeTypeAlignment(QualType T,

+ 18 - 0
test/OpenMP/openmp_seh.c

@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -verify -triple x86_64-pc-windows-msvc19.0.0 -fopenmp -fms-compatibility -x c++ -emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics
+// REQUIRES: x86-registered-target
+extern "C" {
+void __cpuid(int[4], int);
+}
+
+// CHECK-LABEL: @main
+int main(void) {
+  __try {
+    int info[4];
+    __cpuid(info, 1);
+  } __except (1) {
+  }
+
+  return 0;
+}
+