https://github.com/jvoung created https://github.com/llvm/llvm-project/pull/128065
An issue with looking up the "this" when a default init of field2 refers to field1. >From a7002fb5a61c2f6f3c4df2347b6d5f861bf45f8e Mon Sep 17 00:00:00 2001 From: Jan Voung <jvo...@gmail.com> Date: Thu, 20 Feb 2025 19:40:16 +0000 Subject: [PATCH] [clang][dataflow] Add test repro for a crash An issue with looking up the "this" when a default init of field2 refers to field1. --- .../UncheckedOptionalAccessModelTest.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp b/clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp index 19c3ff49eab27..6ece51d84cbff 100644 --- a/clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp @@ -3863,6 +3863,25 @@ TEST_P(UncheckedOptionalAccessTest, ConstBoolAccessorWithModInBetween) { )cc"); } +TEST_P(UncheckedOptionalAccessTest, ConstructorOtherStructField) { + // Repro for a crash. + ExpectDiagnosticsFor(R"cc( + #include "unchecked_optional_access_test.h" + struct NonTrivDtor { + NonTrivDtor(int x); + ~NonTrivDtor() {} + }; + struct Other { + $ns::$optional<int> x = $ns::nullopt; + NonTrivDtor y = x.has_value() ? NonTrivDtor(*x) : NonTrivDtor(-1); + }; + struct target { + target() { Other{}; } + }; + )cc"); +} + + // FIXME: Add support for: // - constructors (copy, move) // - assignment operators (default, copy, move) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits