[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread Yitzhak Mandelbaum via cfe-commits
https://github.com/ymand closed 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

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread via cfe-commits
https://github.com/martinboehme approved this pull request. 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

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread via cfe-commits
@@ -146,6 +146,30 @@ TEST_F(DataflowAnalysisTest, DiagnoseFunctionDiagnoserCalledOnEachElement) { " (Lifetime ends)\n"))); } +TEST_F(DataflowAnalysisTest, CanAnalyzeStmt) { + std::string Code = R"cc( + struct S {int i;}; + S

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread via cfe-commits
@@ -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}; + }

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread via cfe-commits
@@ -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}; + }

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread via cfe-commits
@@ -290,13 +295,13 @@ widenKeyToValueMap(const llvm::MapVector , namespace { // Visitor that builds a map from record prvalues to result objects. -// This traverses the body of the function to be analyzed; for each result -// object that it encounters, it propagates the

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread Samira Bazuzi via cfe-commits
@@ -718,16 +730,24 @@ class Environment { void pushCallInternal(const FunctionDecl *FuncDecl, ArrayRef Args); + // FIXME: Add support for resetting globals after function calls to enable + // the implementation of sound analyses.

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread Samira Bazuzi via cfe-commits
@@ -164,23 +169,28 @@ class Environment { Environment =(Environment &) = default; /// Creates an environment that uses `DACtx` to store objects that encompass - /// the state of a program. - /// - /// If `DeclCtx` is a function, initializes the environment with

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread Samira Bazuzi via cfe-commits
@@ -290,13 +295,13 @@ widenKeyToValueMap(const llvm::MapVector , namespace { // Visitor that builds a map from record prvalues to result objects. -// This traverses the body of the function to be analyzed; for each result -// object that it encounters, it propagates the

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread Samira Bazuzi via cfe-commits
@@ -290,13 +295,13 @@ widenKeyToValueMap(const llvm::MapVector , namespace { // Visitor that builds a map from record prvalues to result objects. -// This traverses the body of the function to be analyzed; for each result -// object that it encounters, it propagates the

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread Samira Bazuzi via cfe-commits
@@ -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}; + }

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread Samira Bazuzi via cfe-commits
@@ -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

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread Samira Bazuzi via cfe-commits
@@ -146,6 +146,30 @@ TEST_F(DataflowAnalysisTest, DiagnoseFunctionDiagnoserCalledOnEachElement) { " (Lifetime ends)\n"))); } +TEST_F(DataflowAnalysisTest, CanAnalyzeStmt) { + std::string Code = R"cc( + struct S {int i;}; + S

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread Samira Bazuzi via cfe-commits
@@ -146,6 +146,30 @@ TEST_F(DataflowAnalysisTest, DiagnoseFunctionDiagnoserCalledOnEachElement) { " (Lifetime ends)\n"))); } +TEST_F(DataflowAnalysisTest, CanAnalyzeStmt) { + std::string Code = R"cc( + struct S {int i;}; + S

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread Samira Bazuzi via cfe-commits
@@ -146,6 +146,30 @@ TEST_F(DataflowAnalysisTest, DiagnoseFunctionDiagnoserCalledOnEachElement) { " (Lifetime ends)\n"))); } +TEST_F(DataflowAnalysisTest, CanAnalyzeStmt) { + std::string Code = R"cc( + struct S {int i;}; + S

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread Samira Bazuzi via cfe-commits
https://github.com/bazuzi updated https://github.com/llvm/llvm-project/pull/91616 >From b62a95001e32a0c1d63204950481eb500c9d0275 Mon Sep 17 00:00:00 2001 From: Samira Bazuzi Date: Thu, 9 May 2024 12:00:06 -0400 Subject: [PATCH 1/7] [clang][dataflow] Fully support Environment construction for

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread via cfe-commits
@@ -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

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread via cfe-commits
@@ -641,23 +656,20 @@ class Environment { /// (or the flow condition is overly constraining) or if the solver times out. bool allows(const Formula &) const; - /// Returns the `DeclContext` of the block being analysed, if any. Otherwise, - /// returns null. - const

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread via cfe-commits
@@ -146,6 +146,30 @@ TEST_F(DataflowAnalysisTest, DiagnoseFunctionDiagnoserCalledOnEachElement) { " (Lifetime ends)\n"))); } +TEST_F(DataflowAnalysisTest, CanAnalyzeStmt) { + std::string Code = R"cc( + struct S {int i;}; + S

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread via cfe-commits
@@ -164,23 +169,28 @@ class Environment { Environment =(Environment &) = default; /// Creates an environment that uses `DACtx` to store objects that encompass - /// the state of a program. - /// - /// If `DeclCtx` is a function, initializes the environment with

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread via cfe-commits
@@ -146,6 +146,30 @@ TEST_F(DataflowAnalysisTest, DiagnoseFunctionDiagnoserCalledOnEachElement) { " (Lifetime ends)\n"))); } +TEST_F(DataflowAnalysisTest, CanAnalyzeStmt) { + std::string Code = R"cc( + struct S {int i;}; + S

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread via cfe-commits
@@ -146,6 +146,30 @@ TEST_F(DataflowAnalysisTest, DiagnoseFunctionDiagnoserCalledOnEachElement) { " (Lifetime ends)\n"))); } +TEST_F(DataflowAnalysisTest, CanAnalyzeStmt) { + std::string Code = R"cc( + struct S {int i;}; + S

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread via cfe-commits
@@ -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}; + }

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread via cfe-commits
@@ -164,23 +169,28 @@ class Environment { Environment =(Environment &) = default; /// Creates an environment that uses `DACtx` to store objects that encompass - /// the state of a program. - /// - /// If `DeclCtx` is a function, initializes the environment with

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread via cfe-commits
@@ -718,16 +730,24 @@ class Environment { void pushCallInternal(const FunctionDecl *FuncDecl, ArrayRef Args); + // FIXME: Add support for resetting globals after function calls to enable + // the implementation of sound analyses.

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread via cfe-commits
@@ -164,23 +169,28 @@ class Environment { Environment =(Environment &) = default; /// Creates an environment that uses `DACtx` to store objects that encompass - /// the state of a program. - /// - /// If `DeclCtx` is a function, initializes the environment with

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread via cfe-commits
@@ -290,13 +295,13 @@ widenKeyToValueMap(const llvm::MapVector , namespace { // Visitor that builds a map from record prvalues to result objects. -// This traverses the body of the function to be analyzed; for each result -// object that it encounters, it propagates the

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread via cfe-commits
@@ -762,7 +791,8 @@ class Environment { RecordStorageLocation *LocForRecordReturnVal = nullptr; // The storage location of the `this` pointee. Should only be null if the - // function being analyzed is only a function and not a method. + // analysis target is not a

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread via cfe-commits
@@ -164,23 +169,28 @@ class Environment { Environment =(Environment &) = default; /// Creates an environment that uses `DACtx` to store objects that encompass - /// the state of a program. - /// - /// If `DeclCtx` is a function, initializes the environment with

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread via cfe-commits
@@ -736,11 +756,20 @@ class Environment { // shared between environments in the same call. // https://github.com/llvm/llvm-project/issues/59005 - // `DeclContext` of the block being analysed if provided. - std::vector CallStack; + // The stack of functions called from

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread via cfe-commits
@@ -641,23 +656,20 @@ class Environment { /// (or the flow condition is overly constraining) or if the solver times out. bool allows(const Formula &) const; - /// Returns the `DeclContext` of the block being analysed, if any. Otherwise, - /// returns null. - const

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread via cfe-commits
@@ -164,23 +169,28 @@ class Environment { Environment =(Environment &) = default; /// Creates an environment that uses `DACtx` to store objects that encompass - /// the state of a program. - /// - /// If `DeclCtx` is a function, initializes the environment with

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread via cfe-commits
@@ -290,13 +295,13 @@ widenKeyToValueMap(const llvm::MapVector , namespace { // Visitor that builds a map from record prvalues to result objects. -// This traverses the body of the function to be analyzed; for each result -// object that it encounters, it propagates the

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread via cfe-commits
@@ -164,23 +169,28 @@ class Environment { Environment =(Environment &) = default; /// Creates an environment that uses `DACtx` to store objects that encompass - /// the state of a program. - /// - /// If `DeclCtx` is a function, initializes the environment with

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread via cfe-commits
@@ -736,11 +756,20 @@ class Environment { // shared between environments in the same call. // https://github.com/llvm/llvm-project/issues/59005 - // `DeclContext` of the block being analysed if provided. - std::vector CallStack; + // The stack of functions called from

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-15 Thread via cfe-commits
@@ -164,23 +169,28 @@ class Environment { Environment =(Environment &) = default; /// Creates an environment that uses `DACtx` to store objects that encompass - /// the state of a program. - /// - /// If `DeclCtx` is a function, initializes the environment with

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-13 Thread Yitzhak Mandelbaum via cfe-commits
https://github.com/ymand approved this pull request. 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

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-10 Thread Samira Bazuzi via cfe-commits
https://github.com/bazuzi updated https://github.com/llvm/llvm-project/pull/91616 >From b62a95001e32a0c1d63204950481eb500c9d0275 Mon Sep 17 00:00:00 2001 From: Samira Bazuzi Date: Thu, 9 May 2024 12:00:06 -0400 Subject: [PATCH 1/6] [clang][dataflow] Fully support Environment construction for

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-10 Thread Yitzhak Mandelbaum via cfe-commits
@@ -476,7 +476,7 @@ runTypeErasedDataflowAnalysis( PrettyStackTraceAnalysis CrashInfo(ACFG, "runTypeErasedDataflowAnalysis"); std::optional MaybeStartingEnv; - if (InitEnv.callStackSize() == 1) { + if (InitEnv.callStackSize() == 0) { ymand wrote:

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-10 Thread Yitzhak Mandelbaum via cfe-commits
https://github.com/ymand approved this pull request. Nice! 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

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-10 Thread Yitzhak Mandelbaum via cfe-commits
@@ -718,29 +730,46 @@ class Environment { void pushCallInternal(const FunctionDecl *FuncDecl, ArrayRef Args); + // FIXME: Add support for resetting globals after function calls to enable + // the implementation of sound analyses. + /// Assigns

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-10 Thread Yitzhak Mandelbaum via cfe-commits
https://github.com/ymand edited 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

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-10 Thread Samira Bazuzi via cfe-commits
https://github.com/bazuzi updated https://github.com/llvm/llvm-project/pull/91616 >From b62a95001e32a0c1d63204950481eb500c9d0275 Mon Sep 17 00:00:00 2001 From: Samira Bazuzi Date: Thu, 9 May 2024 12:00:06 -0400 Subject: [PATCH 1/5] [clang][dataflow] Fully support Environment construction for

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-10 Thread Samira Bazuzi via cfe-commits
https://github.com/bazuzi updated https://github.com/llvm/llvm-project/pull/91616 >From b62a95001e32a0c1d63204950481eb500c9d0275 Mon Sep 17 00:00:00 2001 From: Samira Bazuzi Date: Thu, 9 May 2024 12:00:06 -0400 Subject: [PATCH 1/4] [clang][dataflow] Fully support Environment construction for

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-10 Thread Yitzhak Mandelbaum via cfe-commits
ymand wrote: > I agree with the usefulness of storing the initial target separately, > reducing checks and branching based on whether the current target is a `Stmt` > or `Function`. Since I was touching everywhere `CallStack` was used anyway, I > went ahead with not pushing the starting

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-10 Thread Samira Bazuzi via cfe-commits
https://github.com/bazuzi updated https://github.com/llvm/llvm-project/pull/91616 >From b62a95001e32a0c1d63204950481eb500c9d0275 Mon Sep 17 00:00:00 2001 From: Samira Bazuzi Date: Thu, 9 May 2024 12:00:06 -0400 Subject: [PATCH 1/3] [clang][dataflow] Fully support Environment construction for

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-10 Thread Samira Bazuzi via cfe-commits
bazuzi wrote: I agree with the usefulness of storing the initial target separately, reducing checks and branching based on whether the current target is a `Stmt` or `Function`. Since I was touching everywhere `CallStack` was used anyway, I went ahead with not pushing the starting

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-10 Thread Yitzhak Mandelbaum via cfe-commits
https://github.com/ymand commented: I think we can do this without resorting to a pointer union and templating of the initialization functions, but it will take a little refactoring. First, notice that `stmt` doesn't make sense for the CallStack. The call stack serves two purposes -- to avoid

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-09 Thread Samira Bazuzi via cfe-commits
https://github.com/bazuzi updated https://github.com/llvm/llvm-project/pull/91616 >From b62a95001e32a0c1d63204950481eb500c9d0275 Mon Sep 17 00:00:00 2001 From: Samira Bazuzi Date: Thu, 9 May 2024 12:00:06 -0400 Subject: [PATCH 1/2] [clang][dataflow] Fully support Environment construction for

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-09 Thread Samira Bazuzi via cfe-commits
bazuzi wrote: @ymand Can you review and eventually merge for me? 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

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-09 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang-analysis @llvm/pr-subscribers-clang Author: Samira Bazuzi (bazuzi) Changes Assume in fewer places that the analysis is of a FunctionDecl, and initialize the Environment properly for Stmts. Moves constructors for Environment to header to make it

[clang] [clang][dataflow] Fully support Environment construction for Stmt analysis. (PR #91616)

2024-05-09 Thread Samira Bazuzi via cfe-commits
https://github.com/bazuzi created https://github.com/llvm/llvm-project/pull/91616 Assume in fewer places that the analysis is of a FunctionDecl, and initialize the Environment properly for Stmts. Moves constructors for Environment to header to make it more obvious that there are only minor