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
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
@@ -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
@@ -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};
+ }
@@ -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};
+ }
@@ -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
@@ -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.
@@ -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
@@ -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
@@ -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
@@ -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};
+ }
@@ -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
@@ -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
@@ -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
@@ -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
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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};
+ }
@@ -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
@@ -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.
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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
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
@@ -476,7 +476,7 @@ runTypeErasedDataflowAnalysis(
PrettyStackTraceAnalysis CrashInfo(ACFG, "runTypeErasedDataflowAnalysis");
std::optional MaybeStartingEnv;
- if (InitEnv.callStackSize() == 1) {
+ if (InitEnv.callStackSize() == 0) {
ymand wrote:
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
@@ -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
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
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
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
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
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
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
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
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
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
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
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
52 matches
Mail list logo