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

weiyi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 27 10:39:13 PDT 2022


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, {{&True, &Other}}),
-               _);
+               testing::_);
 }
 
 TEST_F(DataflowAnalysisContextTest, SubstituteFlowConditionsFalseUnchanged) {
@@ -300,7 +299,7 @@
 
   // `False` should never be substituted
   EXPECT_DEATH(Context.buildAndSubstituteFlowCondition(FC, {{&False, &Other}}),
-               _);
+               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 &DataflowAnalysisContext::buildAndSubstituteFlowCondition(
     AtomicBoolValue &Token,
     llvm::DenseMap<AtomicBoolValue *, BoolValue *> Substitutions) {
-  // Do not substitute true/false boolean literals.
+  // Do not try and substitute true/false boolean literals
   assert(
       Substitutions.find(&getBoolLiteralValue(true)) == Substitutions.end() &&
       Substitutions.find(&getBoolLiteralValue(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 &getFlowConditionToken() 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 &buildAndSubstituteFlowCondition(
+      AtomicBoolValue &Token,
+      llvm::DenseMap<AtomicBoolValue *, BoolValue *> Substitutions) {
+    return DACtx->buildAndSubstituteFlowCondition(Token,
+                                                  std::move(Substitutions));
+  }
+
   /// Adds `Val` to the set of clauses that constitute the flow condition.
   void addToFlowCondition(BoolValue &Val);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128659.440305.patch
Type: text/x-patch
Size: 2852 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220627/ad4f73b5/attachment-0001.bin>


More information about the cfe-commits mailing list