[all-commits] [llvm/llvm-project] cf85b3: [clang] Fix crash when handling nested immediate i...

Mariya Podchishchaeva via All-commits all-commits at lists.llvm.org
Wed May 31 20:08:27 PDT 2023

  Branch: refs/heads/release/16.x
  Home:   https://github.com/llvm/llvm-project
  Commit: cf85b3e5662d9ac436b4e1a0361513dfbe547782
  Author: Mariya Podchishchaeva <mariya.podchishchaeva at intel.com>
  Date:   2023-05-31 (Wed, 31 May 2023)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Sema/Sema.h
    M clang/lib/Sema/SemaExpr.cpp
    M clang/test/SemaCXX/cxx2a-consteval.cpp

  Log Message:
  [clang] Fix crash when handling nested immediate invocations

Before this patch it was expected that if there was several immediate
invocations they all belong to the same expression evaluation context.
During parsing of non local variable initializer a new evaluation context is
pushed, so code like this
namespace scope {
struct channel {
    consteval channel(const char* name) noexcept { }
consteval const char* make_channel_name(const char* name) { return name;}

channel rsx_log(make_channel_name("rsx_log"));
produced a nested immediate invocation whose subexpressions are attached
to different expression evaluation contexts. The constructor call
belongs to TU context and `make_channel_name` call to context of
variable initializer.

This patch removes this assumption and adds tracking of previously
failed immediate invocations, so it is possible when handling an
immediate invocation th check that its subexpressions from possibly another
evaluation context contains errors and not produce duplicate

Fixes https://github.com/llvm/llvm-project/issues/58207

Reviewed By: aaron.ballman, shafik

Differential Revision: https://reviews.llvm.org/D146234

(cherry picked from commit a5e1a93ea10ffc06a32df6d9f410e9b297ed136d)

More information about the All-commits mailing list