[PATCH] D142233: [Clang][OpenMP] Bail out early if `Scope` is nullptr in case of any crash

Shilei Tian via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 20 09:41:48 PST 2023


tianshilei1992 updated this revision to Diff 490896.
tianshilei1992 added a comment.

fix comment


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142233/new/

https://reviews.llvm.org/D142233

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/bug59944.c


Index: clang/test/OpenMP/bug59944.c
===================================================================
--- /dev/null
+++ clang/test/OpenMP/bug59944.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -x c -triple x86_64-apple-darwin10 %s -o - 2>&1 | FileCheck %s --check-prefix=CHECK
+
+extern int omp_get_initial_device();
+extern void *omp_get_mapped_ptr(void *, int);
+
+void t() {
+  omp_get_mapped_ptr(&x, omp_get_initial_device());
+}
+
+// CHECK: error: use of undeclared identifier 'x'
+// CHECK-NOT: crash
Index: clang/lib/Sema/SemaOpenMP.cpp
===================================================================
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -7242,7 +7242,7 @@
   if (LangOpts.OpenMP >= 51 && CalleeFnDecl->getIdentifier() &&
       CalleeFnDecl->getName().startswith_insensitive("omp_")) {
     // checking for any calls inside an Order region
-    if (Scope->isOpenMPOrderClauseScope())
+    if (Scope && Scope->isOpenMPOrderClauseScope())
       Diag(LParenLoc, diag::err_omp_unexpected_call_to_omp_runtime_api);
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142233.490896.patch
Type: text/x-patch
Size: 1089 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230120/bd6c9ae2/attachment.bin>


More information about the cfe-commits mailing list