================ @@ -913,6 +913,34 @@ TEST_F(FlowConditionTest, WhileStmt) { }); } +TEST_F(FlowConditionTest, WhileStmtWithAssignmentInCondition) { + std::string Code = R"( + void target(bool Foo) { + // This test checks whether the analysis preserves the connection between + // the value of `Foo` and the assignment expression, despite widening. + // The equality operator generates a fresh boolean variable on each + // interpretation, which forces use of widening. + while ((Foo = (3 == 4))) { + (void)0; + /*[[p]]*/ + } + } + )"; + runDataflow( + Code, + [](const llvm::StringMap<DataflowAnalysisState<NoopLattice>> &Results, + ASTContext &ASTCtx) { + const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); + ASSERT_THAT(FooDecl, NotNull()); + + ASSERT_THAT(Results.keys(), UnorderedElementsAre("p")); + const Environment &Env = getEnvironmentAtAnnotation(Results, "p"); + + auto &FooVal = cast<BoolValue>(Env.getValue(*FooDecl))->formula(); ---------------- martinboehme wrote:
```suggestion const Environment &Env = getEnvironmentAtAnnotation(Results, "p"); auto &FooVal = getValueForDecl<BoolValue>(ASTCtx, Env, "Foo"); ``` You may need to include "TestingSupport.h". https://github.com/llvm/llvm-project/pull/68923 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits