https://github.com/yuxuanchen1997 updated https://github.com/llvm/llvm-project/pull/98102
>From 097881dcd14d44e97e526de86dc348e7a4e5a2e6 Mon Sep 17 00:00:00 2001 From: Yuxuan Chen <yuxuanchen1...@outlook.com> Date: Mon, 8 Jul 2024 18:16:17 -0700 Subject: [PATCH 1/2] [clang] fix sema init crash for not checking a ExprResult --- clang/lib/Sema/SemaInit.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 41753a1661ace..a27ed02fc73b8 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -5576,6 +5576,10 @@ static void TryOrBuildParenListInitialization( ExprResult ER; ER = IS.Perform(S, SubEntity, SubKind, Arg ? MultiExprArg(Arg) : std::nullopt); + + if (ER.isInvalid()) + return false; + if (InitExpr) *InitExpr = ER.get(); else >From 4c2b881257094a503ece9528bff045a312086988 Mon Sep 17 00:00:00 2001 From: Yuxuan Chen <y...@meta.com> Date: Tue, 9 Jul 2024 19:52:34 -0700 Subject: [PATCH 2/2] Add a crash-on-valid unit test --- clang/docs/ReleaseNotes.rst | 2 ++ clang/test/SemaCXX/pr98102.cpp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 clang/test/SemaCXX/pr98102.cpp diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index d0930ccfc603b..cfec1cd14a6fc 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -813,6 +813,8 @@ Bug Fixes in This Version - Fixed `static_cast` to array of unknown bound. Fixes (#GH62863). +- Fixed Clang crashing when failing to perform some C++ Initialization Sequences. (#GH98102) + Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/test/SemaCXX/pr98102.cpp b/clang/test/SemaCXX/pr98102.cpp new file mode 100644 index 0000000000000..9281279c1848c --- /dev/null +++ b/clang/test/SemaCXX/pr98102.cpp @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s +// expected-no-diagnostics + +template <bool v> +struct BC { + static constexpr bool value = v; +}; + +template <typename T, typename Arg> +struct Constructible : BC<__is_constructible(T, Arg)> {}; + +template <typename T> +using Requires = T::value; + +template <typename T> +struct optional { + template <typename U, Requires<Constructible<T, U>> = true> + optional(U) {} +}; + +struct MO {}; +struct S : MO {}; +struct TB { + TB(optional<S>) {} +}; + +class TD : TB, MO { + using TB::TB; +}; + +void foo() { + static_assert(Constructible<TD, TD>::value); +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits