[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)
via cfe-commits
cfe-commits at lists.llvm.org
Wed May 15 01:07:33 PDT 2024
================
@@ -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};
+ }
+ )cc";
+ auto Unit =
+ tooling::buildASTFromCodeWithArgs(Code, {"-fsyntax-only", "-std=c++11"});
+ auto &Context = Unit->getASTContext();
+
+ ASSERT_EQ(Context.getDiagnostics().getClient()->getNumErrors(), 0U);
+
+ auto *DeclStatement = const_cast<DeclStmt *>(
+ selectFirst<DeclStmt>("d", match(declStmt().bind("d"), Context)));
----------------
martinboehme wrote:
Can we make this matcher a bit stronger, i.e. match against the name `AnS`?
https://github.com/llvm/llvm-project/pull/91616
More information about the cfe-commits
mailing list