================
@@ -403,4 +405,35 @@ TEST_F(EnvironmentTest,
               Contains(Member));
 }
 
+TEST_F(EnvironmentTest, Stmt) {
+  using namespace ast_matchers;
+
+  std::string Code = R"cc(
+      struct S {int i;};
+      void foo() {
+        S AnS = S{1};
+      }
----------------
martinboehme wrote:

> A variable declaration outside a function doesn't actually exist within a 
> Stmt, nor is it a Stmt.

But isn't this the use case for which you're making the change in this PR?

I don't see why you need the variable declaration to be a `Stmt` though. In any 
case, you're only analyzing the initializer, not the `DeclStmt` itself. Instead 
of searching for the `DeclStmt`, you could search for the `VarDecl` and then 
initialize the `Environment` with the `getInit()` of that `VarDecl`. This 
wouldn't make the test any more complicated and would be equivalent to what 
you're testing here?

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

Reply via email to