[clang] [clang][dataflow] Check for backedges directly (instead of loop statements). (PR #68923)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 15 23:48:39 PDT 2023
================
@@ -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());
----------------
martinboehme wrote:
This assertion is unnecessary -- findValueDecl() already asserts internally that its return value is non-null. (But see also suggested edit below.)
https://github.com/llvm/llvm-project/pull/68923
More information about the cfe-commits
mailing list