[all-commits] [llvm/llvm-project] 358f47: [Clang] Fix clang crash for fopenmp statement(for)...

Shivam Gupta via All-commits all-commits at lists.llvm.org
Tue Mar 3 07:25:40 PST 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 358f4777202395e19c17f0c4c57a55234ffc37df
      https://github.com/llvm/llvm-project/commit/358f4777202395e19c17f0c4c57a55234ffc37df
  Author: Shivam Gupta <shivam98.tkg at gmail.com>
  Date:   2026-03-03 (Tue, 03 Mar 2026)

  Changed paths:
    M clang/lib/CodeGen/CGStmtOpenMP.cpp
    A clang/test/OpenMP/for_range_loop_codegen.cpp
    M clang/test/OpenMP/parallel_for_codegen.cpp

  Log Message:
  -----------
  [Clang] Fix clang crash for fopenmp statement(for) inside lambda function (#146772)

C++ range-for statements introduce implicit variables such as `__range`,
`__begin`, and `__end`. When such a loop appears inside an OpenMP
loop-based directive (e.g. `#pragma omp for`) within a lambda, these
implicit variables were not emitted before OpenMP privatization logic
ran.

OMPLoopScope assumes that loop-related variables are already present in
LocalDeclMap and temporarily overrides their addresses. Since the
range-for implicit variables had not yet been emitted, they were treated
as newly introduced entries and later erased during restore(), leading
to missing mappings and a crash during codegen.

Fix this by emitting the range-for implicit variables before OpenMP
privatization (setVarAddr/apply), ensuring that existing mappings are
correctly overridden and restored.

This fixes #146335



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list