Skip to content

[clang][dataflow] Remove DataflowAnalysisContext::flowConditionIsTautology(). #69601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 23, 2023

Conversation

martinboehme
Copy link
Contributor

It's only used in its own unit tests.

…tology()`.

It's only used in its own unit tests.
@martinboehme martinboehme requested a review from ymand October 19, 2023 12:44
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:dataflow Clang Dataflow Analysis framework - https://clang.llvm.org/docs/DataFlowAnalysisIntro.html clang:analysis labels Oct 19, 2023
@llvmbot
Copy link
Member

llvmbot commented Oct 19, 2023

@llvm/pr-subscribers-clang-analysis

@llvm/pr-subscribers-clang

Author: None (martinboehme)

Changes

It's only used in its own unit tests.


Full diff: https://github.com/llvm/llvm-project/pull/69601.diff

3 Files Affected:

  • (modified) clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h (-4)
  • (modified) clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp (-9)
  • (modified) clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp (-27)
diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
index c46109a02921e7f..a792c3f911b1dd0 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
@@ -133,10 +133,6 @@ class DataflowAnalysisContext {
   /// identified by `Token` imply that `Val` is true.
   bool flowConditionImplies(Atom Token, const Formula &);
 
-  /// Returns true if and only if the constraints of the flow condition
-  /// identified by `Token` are always true.
-  bool flowConditionIsTautology(Atom Token);
-
   /// Returns true if `Val1` is equivalent to `Val2`.
   /// Note: This function doesn't take into account constraints on `Val1` and
   /// `Val2` imposed by the flow condition.
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
index fa9b40fc49b3ae7..894610ab27fb699 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -160,15 +160,6 @@ bool DataflowAnalysisContext::flowConditionImplies(Atom Token,
   return isUnsatisfiable(std::move(Constraints));
 }
 
-bool DataflowAnalysisContext::flowConditionIsTautology(Atom Token) {
-  // Returns true if and only if we cannot prove that the flow condition can
-  // ever be false.
-  llvm::SetVector<const Formula *> Constraints;
-  Constraints.insert(&arena().makeNot(arena().makeAtomRef(Token)));
-  addTransitiveFlowConditionConstraints(Token, Constraints);
-  return isUnsatisfiable(std::move(Constraints));
-}
-
 bool DataflowAnalysisContext::equivalentFormulas(const Formula &Val1,
                                                  const Formula &Val2) {
   llvm::SetVector<const Formula *> Constraints;
diff --git a/clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp b/clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp
index fb7642c131e3190..88eb11045b9e9f9 100644
--- a/clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp
@@ -99,33 +99,6 @@ TEST_F(DataflowAnalysisContextTest, JoinFlowConditions) {
   EXPECT_TRUE(Context.flowConditionImplies(FC3, C3));
 }
 
-TEST_F(DataflowAnalysisContextTest, FlowConditionTautologies) {
-  // Fresh flow condition with empty/no constraints is always true.
-  Atom FC1 = A.makeFlowConditionToken();
-  EXPECT_TRUE(Context.flowConditionIsTautology(FC1));
-
-  // Literal `true` is always true.
-  Atom FC2 = A.makeFlowConditionToken();
-  Context.addFlowConditionConstraint(FC2, A.makeLiteral(true));
-  EXPECT_TRUE(Context.flowConditionIsTautology(FC2));
-
-  // Literal `false` is never true.
-  Atom FC3 = A.makeFlowConditionToken();
-  Context.addFlowConditionConstraint(FC3, A.makeLiteral(false));
-  EXPECT_FALSE(Context.flowConditionIsTautology(FC3));
-
-  // We can't prove that an arbitrary bool A is always true...
-  auto &C1 = A.makeAtomRef(A.makeAtom());
-  Atom FC4 = A.makeFlowConditionToken();
-  Context.addFlowConditionConstraint(FC4, C1);
-  EXPECT_FALSE(Context.flowConditionIsTautology(FC4));
-
-  // ... but we can prove A || !A is true.
-  Atom FC5 = A.makeFlowConditionToken();
-  Context.addFlowConditionConstraint(FC5, A.makeOr(C1, A.makeNot(C1)));
-  EXPECT_TRUE(Context.flowConditionIsTautology(FC5));
-}
-
 TEST_F(DataflowAnalysisContextTest, EquivBoolVals) {
   auto &X = A.makeAtomRef(A.makeAtom());
   auto &Y = A.makeAtomRef(A.makeAtom());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:analysis clang:dataflow Clang Dataflow Analysis framework - https://clang.llvm.org/docs/DataFlowAnalysisIntro.html clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants