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

Mariya Podchishchaeva via All-commits all-commits at lists.llvm.org
Wed Apr 5 02:26:47 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a5e1a93ea10ffc06a32df6d9f410e9b297ed136d
      https://github.com/llvm/llvm-project/commit/a5e1a93ea10ffc06a32df6d9f410e9b297ed136d
  Author: Mariya Podchishchaeva <mariya.podchishchaeva at intel.com>
  Date:   2023-04-05 (Wed, 05 Apr 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
diagnostics.

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

Reviewed By: aaron.ballman, shafik

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




More information about the All-commits mailing list