================ @@ -2313,6 +2313,28 @@ TEST(TransferTest, AssignmentOperatorWithInitAndInheritance) { ASTContext &ASTCtx) {}); } +TEST(TransferTest, InitListExprAsXValue) { + // This is a crash repro. + std::string Code = R"( + void target() { + bool&& Foo{false}; + // [[p]] + } + )"; + runDataflow( + Code, + [](const llvm::StringMap<DataflowAnalysisState<NoopLattice>> &Results, + ASTContext &ASTCtx) { + const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); + ASSERT_THAT(FooDecl, NotNull()); + const Environment &Env = getEnvironmentAtAnnotation(Results, "p"); + const auto *FooVal = + dyn_cast_or_null<BoolValue>(Env.getValue(*FooDecl)); + ASSERT_THAT(FooVal, NotNull()); + ASSERT_EQ(FooVal, &Env.getBoolLiteralValue(false)); ---------------- martinboehme wrote:
```suggestion const Environment &Env = getEnvironmentAtAnnotation(Results, "p"); const auto &FooVal = getValueForDecl<BoolValue>(ASTCtx, Env, "Foo"); ASSERT_TRUE(FooVal.formula().isLiteral(false)); ``` (There's unfortunately still a lot of tests that don't use the `getValueForDecl()` helper and are thus needlessly complicated.) https://github.com/llvm/llvm-project/pull/80970 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits