[all-commits] [llvm/llvm-project] a891a5: [Clang] [Sema] Use getCurFunctionDecl() to get the...

Sirraide via All-commits all-commits at lists.llvm.org
Fri Jul 24 16:13:17 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a891a5c40c7d2ed62d97fc6563cf256e7bab3ffb
      https://github.com/llvm/llvm-project/commit/a891a5c40c7d2ed62d97fc6563cf256e7bab3ffb
  Author: Sirraide <aeternalmail at gmail.com>
  Date:   2026-07-24 (Fri, 24 Jul 2026)

  Changed paths:
    M clang/lib/Sema/SemaStmt.cpp
    M clang/test/SemaCXX/cxx2c-expansion-stmts.cpp

  Log Message:
  -----------
  [Clang] [Sema] Use getCurFunctionDecl() to get the current function (#211938)

In `BuildReturnStmt()`, use `getCurFunctionDecl()` to get the current
function rather than attempting to cast `CurContext` to a
`FunctionDecl`, which breaks inside an expansion statement because the
current `DeclContext` will be that of the expansion statement, not the
function. `getCurFunctionDecl()` knows how to handle this case and we
already call it earlier in that function, so just reuse the result of
that call.

Fixes #211917.



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