[PATCH] D128659: [clang][dataflow] Add `buildAndSubstituteFlowCondition` to `DataflowEnvironment`

2022-06-27 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGae90bc846758: [clang][dataflow] Add 
`buildAndSubstituteFlowCondition` to `DataflowEnvironment` (authored by wyt, 
committed by gribozavr).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128659/new/

https://reviews.llvm.org/D128659

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h


Index: clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
===
--- clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -308,6 +308,16 @@
   /// Returns the token that identifies the flow condition of the environment.
   AtomicBoolValue () const { return *FlowConditionToken; 
}
 
+  /// Builds and returns the logical formula defining the flow condition
+  /// identified by `Token`. If a value in the formula is present as a key in
+  /// `Substitutions`, it will be substituted with the value it maps to.
+  BoolValue (
+  AtomicBoolValue ,
+  llvm::DenseMap Substitutions) {
+return DACtx->buildAndSubstituteFlowCondition(Token,
+  std::move(Substitutions));
+  }
+
   /// Adds `Val` to the set of clauses that constitute the flow condition.
   void addToFlowCondition(BoolValue );
 


Index: clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
===
--- clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -308,6 +308,16 @@
   /// Returns the token that identifies the flow condition of the environment.
   AtomicBoolValue () const { return *FlowConditionToken; }
 
+  /// Builds and returns the logical formula defining the flow condition
+  /// identified by `Token`. If a value in the formula is present as a key in
+  /// `Substitutions`, it will be substituted with the value it maps to.
+  BoolValue (
+  AtomicBoolValue ,
+  llvm::DenseMap Substitutions) {
+return DACtx->buildAndSubstituteFlowCondition(Token,
+  std::move(Substitutions));
+  }
+
   /// Adds `Val` to the set of clauses that constitute the flow condition.
   void addToFlowCondition(BoolValue );
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128659: [clang][dataflow] Add `buildAndSubstituteFlowCondition` to `DataflowEnvironment`

2022-06-27 Thread weiyi via Phabricator via cfe-commits
wyt updated this revision to Diff 440336.
wyt added a comment.

Propagate change from parent patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128659/new/

https://reviews.llvm.org/D128659

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h


Index: clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
===
--- clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -304,6 +304,16 @@
   /// Returns the token that identifies the flow condition of the environment.
   AtomicBoolValue () const { return *FlowConditionToken; 
}
 
+  /// Builds and returns the logical formula defining the flow condition
+  /// identified by `Token`. If a value in the formula is present as a key in
+  /// `Substitutions`, it will be substituted with the value it maps to.
+  BoolValue (
+  AtomicBoolValue ,
+  llvm::DenseMap Substitutions) {
+return DACtx->buildAndSubstituteFlowCondition(Token,
+  std::move(Substitutions));
+  }
+
   /// Adds `Val` to the set of clauses that constitute the flow condition.
   void addToFlowCondition(BoolValue );
 


Index: clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
===
--- clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -304,6 +304,16 @@
   /// Returns the token that identifies the flow condition of the environment.
   AtomicBoolValue () const { return *FlowConditionToken; }
 
+  /// Builds and returns the logical formula defining the flow condition
+  /// identified by `Token`. If a value in the formula is present as a key in
+  /// `Substitutions`, it will be substituted with the value it maps to.
+  BoolValue (
+  AtomicBoolValue ,
+  llvm::DenseMap Substitutions) {
+return DACtx->buildAndSubstituteFlowCondition(Token,
+  std::move(Substitutions));
+  }
+
   /// Adds `Val` to the set of clauses that constitute the flow condition.
   void addToFlowCondition(BoolValue );
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128659: [clang][dataflow] Add `buildAndSubstituteFlowCondition` to `DataflowEnvironment`

2022-06-27 Thread weiyi via Phabricator via cfe-commits
wyt updated this revision to Diff 440305.
wyt added a comment.

Fix comment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128659/new/

https://reviews.llvm.org/D128659

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp


Index: clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp
@@ -16,7 +16,6 @@
 
 using namespace clang;
 using namespace dataflow;
-using testing::_;
 
 class DataflowAnalysisContextTest : public ::testing::Test {
 protected:
@@ -287,7 +286,7 @@
 
   // `True` should never be substituted
   EXPECT_DEATH(Context.buildAndSubstituteFlowCondition(FC, {{, }}),
-   _);
+   testing::_);
 }
 
 TEST_F(DataflowAnalysisContextTest, SubstituteFlowConditionsFalseUnchanged) {
@@ -300,7 +299,7 @@
 
   // `False` should never be substituted
   EXPECT_DEATH(Context.buildAndSubstituteFlowCondition(FC, {{, }}),
-   _);
+   testing::_);
 }
 
 TEST_F(DataflowAnalysisContextTest, SubstituteFlowConditionsAtomicFC) {
Index: clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -220,7 +220,7 @@
 BoolValue ::buildAndSubstituteFlowCondition(
 AtomicBoolValue ,
 llvm::DenseMap Substitutions) {
-  // Do not substitute true/false boolean literals.
+  // Do not try and substitute true/false boolean literals
   assert(
   Substitutions.find((true)) == Substitutions.end() &&
   Substitutions.find((false)) == Substitutions.end());
Index: clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
===
--- clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -304,6 +304,16 @@
   /// Returns the token that identifies the flow condition of the environment.
   AtomicBoolValue () const { return *FlowConditionToken; 
}
 
+  /// Builds and returns the logical formula defining the flow condition
+  /// identified by `Token`. If a value in the formula is present as a key in
+  /// `Substitutions`, it will be substituted with the value it maps to.
+  BoolValue (
+  AtomicBoolValue ,
+  llvm::DenseMap Substitutions) {
+return DACtx->buildAndSubstituteFlowCondition(Token,
+  std::move(Substitutions));
+  }
+
   /// Adds `Val` to the set of clauses that constitute the flow condition.
   void addToFlowCondition(BoolValue );
 


Index: clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp
@@ -16,7 +16,6 @@
 
 using namespace clang;
 using namespace dataflow;
-using testing::_;
 
 class DataflowAnalysisContextTest : public ::testing::Test {
 protected:
@@ -287,7 +286,7 @@
 
   // `True` should never be substituted
   EXPECT_DEATH(Context.buildAndSubstituteFlowCondition(FC, {{, }}),
-   _);
+   testing::_);
 }
 
 TEST_F(DataflowAnalysisContextTest, SubstituteFlowConditionsFalseUnchanged) {
@@ -300,7 +299,7 @@
 
   // `False` should never be substituted
   EXPECT_DEATH(Context.buildAndSubstituteFlowCondition(FC, {{, }}),
-   _);
+   testing::_);
 }
 
 TEST_F(DataflowAnalysisContextTest, SubstituteFlowConditionsAtomicFC) {
Index: clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -220,7 +220,7 @@
 BoolValue ::buildAndSubstituteFlowCondition(
 AtomicBoolValue ,
 llvm::DenseMap Substitutions) {
-  // Do not substitute true/false boolean literals.
+  // Do not try and substitute true/false boolean literals
   assert(
   Substitutions.find((true)) == Substitutions.end() &&
   Substitutions.find((false)) == Substitutions.end());
Index: clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
===
--- clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -304,6 +304,16 @@
   /// 

[PATCH] D128659: [clang][dataflow] Add `buildAndSubstituteFlowCondition` to `DataflowEnvironment`

2022-06-27 Thread weiyi via Phabricator via cfe-commits
wyt created this revision.
Herald added subscribers: martong, tschuett, xazax.hun.
Herald added a project: All.
wyt requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Depends On D128658 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128659

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h


Index: clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
===
--- clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -304,6 +304,17 @@
   /// Returns the token that identifies the flow condition of the environment.
   AtomicBoolValue () const { return *FlowConditionToken; 
}
 
+  /// Builds and returns the logical formula defining the flow condition
+  /// identified by `Token`. If a value in the formula is present as a key in
+  /// `Substitutions`, and it is not a True/False boolean literal, it will be
+  /// substituted with the value it maps to.
+  BoolValue (
+  AtomicBoolValue ,
+  llvm::DenseMap Substitutions) {
+return DACtx->buildAndSubstituteFlowCondition(Token,
+  std::move(Substitutions));
+  }
+
   /// Adds `Val` to the set of clauses that constitute the flow condition.
   void addToFlowCondition(BoolValue );
 


Index: clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
===
--- clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -304,6 +304,17 @@
   /// Returns the token that identifies the flow condition of the environment.
   AtomicBoolValue () const { return *FlowConditionToken; }
 
+  /// Builds and returns the logical formula defining the flow condition
+  /// identified by `Token`. If a value in the formula is present as a key in
+  /// `Substitutions`, and it is not a True/False boolean literal, it will be
+  /// substituted with the value it maps to.
+  BoolValue (
+  AtomicBoolValue ,
+  llvm::DenseMap Substitutions) {
+return DACtx->buildAndSubstituteFlowCondition(Token,
+  std::move(Substitutions));
+  }
+
   /// Adds `Val` to the set of clauses that constitute the flow condition.
   void addToFlowCondition(BoolValue );
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits