================
@@ -1710,4 +1710,25 @@ TEST_F(TopTest, ForRangeStmtConverges) {
                 // analysis converged.
               });
 }
+
+TEST_F(TopTest, ForRangeStmtHasFlowCondition) {
+  std::string Code = R"(
+    #include <array>
+    void target(bool Foo) {
+      std::array<int, 5> t;
+      for (auto& i : t) {
+        (void)0;
+        /*[[p1]]*/
+      }
+    }
+  )";
+  runDataflow(Code,
+              [](const llvm::StringMap<DataflowAnalysisState<NoopLattice>> 
&Results,
+                 const AnalysisOutputs &AO) {
+                  ASSERT_THAT(Results.keys(), UnorderedElementsAre("p1"));
+                  const Environment &Env1 = 
getEnvironmentAtAnnotation(Results, "p1");
----------------
martinboehme wrote:

```suggestion
                  const Environment &Env = getEnvironmentAtAnnotation(Results, 
"p");
```

*  A lot of tests still do the `ASSERT_THAT(Results.keys(), 
UnorderedElementsAre(...));`, but it's unnecessary -- 
`getEnvironmentAtAnnotation()` itself asserts that the annotation exists.

*  When there is only one environment you want to query, the usual names are 
`Env` and `p` (will need to be changed in the code snippet too, obviously).

https://github.com/llvm/llvm-project/pull/80989
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to