[clang] c107231 - [clang][dataflow] Fix -Wdeprecated-declarations after D147302 (NFC)

Jie Fu via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 4 01:18:18 PDT 2023


Author: Jie Fu
Date: 2023-04-04T16:17:25+08:00
New Revision: c107231cde99c0b8cdda5c5befe6354750ca03f2

URL: https://github.com/llvm/llvm-project/commit/c107231cde99c0b8cdda5c5befe6354750ca03f2
DIFF: https://github.com/llvm/llvm-project/commit/c107231cde99c0b8cdda5c5befe6354750ca03f2.diff

LOG: [clang][dataflow] Fix -Wdeprecated-declarations after D147302 (NFC)

Replace:
 1. createAtomicBoolValue() --> create<AtomicBoolValue>()
 2. createTopBoolValue()    --> create<TopBoolValue>()

/Users/jiefu/llvm-project/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h:386:19: error: 'createAtomicBoolValue' is deprecated: use create<AtomicBoolValue> instead [-Werror,-Wdeprecated-declarations]
    return DACtx->createAtomicBoolValue();
                  ^~~~~~~~~~~~~~~~~~~~~
                  create<AtomicBoolValue>
/Users/jiefu/llvm-project/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:215:3: note: 'createAtomicBoolValue' has been explicitly marked deprecated here
  LLVM_DEPRECATED("use create<AtomicBoolValue> instead",
  ^
/Users/jiefu/llvm-project/llvm/include/llvm/Support/Compiler.h:143:50: note: expanded from macro 'LLVM_DEPRECATED'
                                                 ^
In file included from /Users/jiefu/llvm-project/clang/lib/Analysis/FlowSensitive/Transfer.cpp:14:
In file included from /Users/jiefu/llvm-project/clang/include/clang/Analysis/FlowSensitive/Transfer.h:19:
/Users/jiefu/llvm-project/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h:391:19: error: 'createTopBoolValue' is deprecated: use create<TopBoolValue> instead [-Werror,-Wdeprecated-declarations]
    return DACtx->createTopBoolValue();
                  ^~~~~~~~~~~~~~~~~~
                  create<TopBoolValue>
/Users/jiefu/llvm-project/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:227:3: note: 'createTopBoolValue' has been explicitly marked deprecated here
  LLVM_DEPRECATED("use create<TopBoolValue> instead", "create<TopBoolValue>")
  ^
/Users/jiefu/llvm-project/llvm/include/llvm/Support/Compiler.h:143:50: note: expanded from macro 'LLVM_DEPRECATED'
                                                 ^
2 errors generated.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
index ce11fc1c2b2d7..97ea6a573cffd 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -383,12 +383,12 @@ class Environment {
 
   /// Returns an atomic boolean value.
   BoolValue &makeAtomicBoolValue() const {
-    return DACtx->createAtomicBoolValue();
+    return DACtx->create<AtomicBoolValue>();
   }
 
   /// Returns a unique instance of boolean Top.
   BoolValue &makeTopBoolValue() const {
-    return DACtx->createTopBoolValue();
+    return DACtx->create<TopBoolValue>();
   }
 
   /// Returns a boolean value that represents the conjunction of `LHS` and

diff  --git a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
index 5a49ef195c0b1..4d8a42c1390c2 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -157,7 +157,7 @@ BoolValue &DataflowAnalysisContext::getOrCreateIff(BoolValue &LHS,
 }
 
 AtomicBoolValue &DataflowAnalysisContext::makeFlowConditionToken() {
-  return createAtomicBoolValue();
+  return create<AtomicBoolValue>();
 }
 
 void DataflowAnalysisContext::addFlowConditionConstraint(
@@ -378,8 +378,8 @@ DataflowAnalysisContext::getControlFlowContext(const FunctionDecl *F) {
 
 DataflowAnalysisContext::DataflowAnalysisContext(std::unique_ptr<Solver> S,
                                                  Options Opts)
-    : S(std::move(S)), TrueVal(createAtomicBoolValue()),
-      FalseVal(createAtomicBoolValue()), Opts(Opts) {
+    : S(std::move(S)), TrueVal(create<AtomicBoolValue>()),
+      FalseVal(create<AtomicBoolValue>()), Opts(Opts) {
   assert(this->S != nullptr);
   // If the -dataflow-log command-line flag was set, synthesize a logger.
   // This is ugly but provides a uniform method for ad-hoc debugging dataflow-

diff  --git a/clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp b/clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp
index 0efb341cc06e7..52b2d5c7a33a3 100644
--- a/clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp
@@ -27,35 +27,35 @@ class DataflowAnalysisContextTest : public ::testing::Test {
 
 TEST_F(DataflowAnalysisContextTest,
        CreateAtomicBoolValueReturnsDistinctValues) {
-  auto &X = Context.createAtomicBoolValue();
-  auto &Y = Context.createAtomicBoolValue();
+  auto &X = Context.create<AtomicBoolValue>();
+  auto &Y = Context.create<AtomicBoolValue>();
   EXPECT_NE(&X, &Y);
 }
 
 TEST_F(DataflowAnalysisContextTest,
        CreateTopBoolValueReturnsDistinctValues) {
-  auto &X = Context.createTopBoolValue();
-  auto &Y = Context.createTopBoolValue();
+  auto &X = Context.create<TopBoolValue>();
+  auto &Y = Context.create<TopBoolValue>();
   EXPECT_NE(&X, &Y);
 }
 
 TEST_F(DataflowAnalysisContextTest, DistinctTopsNotEquivalent) {
-  auto &X = Context.createTopBoolValue();
-  auto &Y = Context.createTopBoolValue();
+  auto &X = Context.create<TopBoolValue>();
+  auto &Y = Context.create<TopBoolValue>();
   EXPECT_FALSE(Context.equivalentBoolValues(X, Y));
 }
 
 TEST_F(DataflowAnalysisContextTest,
        GetOrCreateConjunctionReturnsSameExprGivenSameArgs) {
-  auto &X = Context.createAtomicBoolValue();
+  auto &X = Context.create<AtomicBoolValue>();
   auto &XAndX = Context.getOrCreateConjunction(X, X);
   EXPECT_EQ(&XAndX, &X);
 }
 
 TEST_F(DataflowAnalysisContextTest,
        GetOrCreateConjunctionReturnsSameExprOnSubsequentCalls) {
-  auto &X = Context.createAtomicBoolValue();
-  auto &Y = Context.createAtomicBoolValue();
+  auto &X = Context.create<AtomicBoolValue>();
+  auto &Y = Context.create<AtomicBoolValue>();
   auto &XAndY1 = Context.getOrCreateConjunction(X, Y);
   auto &XAndY2 = Context.getOrCreateConjunction(X, Y);
   EXPECT_EQ(&XAndY1, &XAndY2);
@@ -63,22 +63,22 @@ TEST_F(DataflowAnalysisContextTest,
   auto &YAndX = Context.getOrCreateConjunction(Y, X);
   EXPECT_EQ(&XAndY1, &YAndX);
 
-  auto &Z = Context.createAtomicBoolValue();
+  auto &Z = Context.create<AtomicBoolValue>();
   auto &XAndZ = Context.getOrCreateConjunction(X, Z);
   EXPECT_NE(&XAndY1, &XAndZ);
 }
 
 TEST_F(DataflowAnalysisContextTest,
        GetOrCreateDisjunctionReturnsSameExprGivenSameArgs) {
-  auto &X = Context.createAtomicBoolValue();
+  auto &X = Context.create<AtomicBoolValue>();
   auto &XOrX = Context.getOrCreateDisjunction(X, X);
   EXPECT_EQ(&XOrX, &X);
 }
 
 TEST_F(DataflowAnalysisContextTest,
        GetOrCreateDisjunctionReturnsSameExprOnSubsequentCalls) {
-  auto &X = Context.createAtomicBoolValue();
-  auto &Y = Context.createAtomicBoolValue();
+  auto &X = Context.create<AtomicBoolValue>();
+  auto &Y = Context.create<AtomicBoolValue>();
   auto &XOrY1 = Context.getOrCreateDisjunction(X, Y);
   auto &XOrY2 = Context.getOrCreateDisjunction(X, Y);
   EXPECT_EQ(&XOrY1, &XOrY2);
@@ -86,34 +86,34 @@ TEST_F(DataflowAnalysisContextTest,
   auto &YOrX = Context.getOrCreateDisjunction(Y, X);
   EXPECT_EQ(&XOrY1, &YOrX);
 
-  auto &Z = Context.createAtomicBoolValue();
+  auto &Z = Context.create<AtomicBoolValue>();
   auto &XOrZ = Context.getOrCreateDisjunction(X, Z);
   EXPECT_NE(&XOrY1, &XOrZ);
 }
 
 TEST_F(DataflowAnalysisContextTest,
        GetOrCreateNegationReturnsSameExprOnSubsequentCalls) {
-  auto &X = Context.createAtomicBoolValue();
+  auto &X = Context.create<AtomicBoolValue>();
   auto &NotX1 = Context.getOrCreateNegation(X);
   auto &NotX2 = Context.getOrCreateNegation(X);
   EXPECT_EQ(&NotX1, &NotX2);
 
-  auto &Y = Context.createAtomicBoolValue();
+  auto &Y = Context.create<AtomicBoolValue>();
   auto &NotY = Context.getOrCreateNegation(Y);
   EXPECT_NE(&NotX1, &NotY);
 }
 
 TEST_F(DataflowAnalysisContextTest,
        GetOrCreateImplicationReturnsTrueGivenSameArgs) {
-  auto &X = Context.createAtomicBoolValue();
+  auto &X = Context.create<AtomicBoolValue>();
   auto &XImpliesX = Context.getOrCreateImplication(X, X);
   EXPECT_EQ(&XImpliesX, &Context.getBoolLiteralValue(true));
 }
 
 TEST_F(DataflowAnalysisContextTest,
        GetOrCreateImplicationReturnsSameExprOnSubsequentCalls) {
-  auto &X = Context.createAtomicBoolValue();
-  auto &Y = Context.createAtomicBoolValue();
+  auto &X = Context.create<AtomicBoolValue>();
+  auto &Y = Context.create<AtomicBoolValue>();
   auto &XImpliesY1 = Context.getOrCreateImplication(X, Y);
   auto &XImpliesY2 = Context.getOrCreateImplication(X, Y);
   EXPECT_EQ(&XImpliesY1, &XImpliesY2);
@@ -121,21 +121,21 @@ TEST_F(DataflowAnalysisContextTest,
   auto &YImpliesX = Context.getOrCreateImplication(Y, X);
   EXPECT_NE(&XImpliesY1, &YImpliesX);
 
-  auto &Z = Context.createAtomicBoolValue();
+  auto &Z = Context.create<AtomicBoolValue>();
   auto &XImpliesZ = Context.getOrCreateImplication(X, Z);
   EXPECT_NE(&XImpliesY1, &XImpliesZ);
 }
 
 TEST_F(DataflowAnalysisContextTest, GetOrCreateIffReturnsTrueGivenSameArgs) {
-  auto &X = Context.createAtomicBoolValue();
+  auto &X = Context.create<AtomicBoolValue>();
   auto &XIffX = Context.getOrCreateIff(X, X);
   EXPECT_EQ(&XIffX, &Context.getBoolLiteralValue(true));
 }
 
 TEST_F(DataflowAnalysisContextTest,
        GetOrCreateIffReturnsSameExprOnSubsequentCalls) {
-  auto &X = Context.createAtomicBoolValue();
-  auto &Y = Context.createAtomicBoolValue();
+  auto &X = Context.create<AtomicBoolValue>();
+  auto &Y = Context.create<AtomicBoolValue>();
   auto &XIffY1 = Context.getOrCreateIff(X, Y);
   auto &XIffY2 = Context.getOrCreateIff(X, Y);
   EXPECT_EQ(&XIffY1, &XIffY2);
@@ -143,27 +143,27 @@ TEST_F(DataflowAnalysisContextTest,
   auto &YIffX = Context.getOrCreateIff(Y, X);
   EXPECT_EQ(&XIffY1, &YIffX);
 
-  auto &Z = Context.createAtomicBoolValue();
+  auto &Z = Context.create<AtomicBoolValue>();
   auto &XIffZ = Context.getOrCreateIff(X, Z);
   EXPECT_NE(&XIffY1, &XIffZ);
 }
 
 TEST_F(DataflowAnalysisContextTest, EmptyFlowCondition) {
   auto &FC = Context.makeFlowConditionToken();
-  auto &C = Context.createAtomicBoolValue();
+  auto &C = Context.create<AtomicBoolValue>();
   EXPECT_FALSE(Context.flowConditionImplies(FC, C));
 }
 
 TEST_F(DataflowAnalysisContextTest, AddFlowConditionConstraint) {
   auto &FC = Context.makeFlowConditionToken();
-  auto &C = Context.createAtomicBoolValue();
+  auto &C = Context.create<AtomicBoolValue>();
   Context.addFlowConditionConstraint(FC, C);
   EXPECT_TRUE(Context.flowConditionImplies(FC, C));
 }
 
 TEST_F(DataflowAnalysisContextTest, ForkFlowCondition) {
   auto &FC1 = Context.makeFlowConditionToken();
-  auto &C1 = Context.createAtomicBoolValue();
+  auto &C1 = Context.create<AtomicBoolValue>();
   Context.addFlowConditionConstraint(FC1, C1);
 
   // Forked flow condition inherits the constraints of its parent flow
@@ -173,16 +173,16 @@ TEST_F(DataflowAnalysisContextTest, ForkFlowCondition) {
 
   // Adding a new constraint to the forked flow condition does not affect its
   // parent flow condition.
-  auto &C2 = Context.createAtomicBoolValue();
+  auto &C2 = Context.create<AtomicBoolValue>();
   Context.addFlowConditionConstraint(FC2, C2);
   EXPECT_TRUE(Context.flowConditionImplies(FC2, C2));
   EXPECT_FALSE(Context.flowConditionImplies(FC1, C2));
 }
 
 TEST_F(DataflowAnalysisContextTest, JoinFlowConditions) {
-  auto &C1 = Context.createAtomicBoolValue();
-  auto &C2 = Context.createAtomicBoolValue();
-  auto &C3 = Context.createAtomicBoolValue();
+  auto &C1 = Context.create<AtomicBoolValue>();
+  auto &C2 = Context.create<AtomicBoolValue>();
+  auto &C3 = Context.create<AtomicBoolValue>();
 
   auto &FC1 = Context.makeFlowConditionToken();
   Context.addFlowConditionConstraint(FC1, C1);
@@ -214,7 +214,7 @@ TEST_F(DataflowAnalysisContextTest, FlowConditionTautologies) {
   EXPECT_FALSE(Context.flowConditionIsTautology(FC3));
 
   // We can't prove that an arbitrary bool A is always true...
-  auto &C1 = Context.createAtomicBoolValue();
+  auto &C1 = Context.create<AtomicBoolValue>();
   auto &FC4 = Context.makeFlowConditionToken();
   Context.addFlowConditionConstraint(FC4, C1);
   EXPECT_FALSE(Context.flowConditionIsTautology(FC4));
@@ -227,9 +227,9 @@ TEST_F(DataflowAnalysisContextTest, FlowConditionTautologies) {
 }
 
 TEST_F(DataflowAnalysisContextTest, EquivBoolVals) {
-  auto &X = Context.createAtomicBoolValue();
-  auto &Y = Context.createAtomicBoolValue();
-  auto &Z = Context.createAtomicBoolValue();
+  auto &X = Context.create<AtomicBoolValue>();
+  auto &Y = Context.create<AtomicBoolValue>();
+  auto &Z = Context.create<AtomicBoolValue>();
   auto &True = Context.getBoolLiteralValue(true);
   auto &False = Context.getBoolLiteralValue(false);
 
@@ -292,7 +292,7 @@ TEST_F(DataflowAnalysisContextTest, EquivBoolVals) {
 #if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST
 TEST_F(DataflowAnalysisContextTest, SubstituteFlowConditionsTrueUnchanged) {
   auto &True = Context.getBoolLiteralValue(true);
-  auto &Other = Context.createAtomicBoolValue();
+  auto &Other = Context.create<AtomicBoolValue>();
 
   // FC = True
   auto &FC = Context.makeFlowConditionToken();
@@ -305,7 +305,7 @@ TEST_F(DataflowAnalysisContextTest, SubstituteFlowConditionsTrueUnchanged) {
 
 TEST_F(DataflowAnalysisContextTest, SubstituteFlowConditionsFalseUnchanged) {
   auto &False = Context.getBoolLiteralValue(false);
-  auto &Other = Context.createAtomicBoolValue();
+  auto &Other = Context.create<AtomicBoolValue>();
 
   // FC = False
   auto &FC = Context.makeFlowConditionToken();
@@ -318,7 +318,7 @@ TEST_F(DataflowAnalysisContextTest, SubstituteFlowConditionsFalseUnchanged) {
 #endif
 
 TEST_F(DataflowAnalysisContextTest, SubstituteFlowConditionContainingAtomic) {
-  auto &X = Context.createAtomicBoolValue();
+  auto &X = Context.create<AtomicBoolValue>();
   auto &True = Context.getBoolLiteralValue(true);
   auto &False = Context.getBoolLiteralValue(false);
 
@@ -338,7 +338,7 @@ TEST_F(DataflowAnalysisContextTest, SubstituteFlowConditionContainingAtomic) {
 }
 
 TEST_F(DataflowAnalysisContextTest, SubstituteFlowConditionContainingNegation) {
-  auto &X = Context.createAtomicBoolValue();
+  auto &X = Context.create<AtomicBoolValue>();
   auto &True = Context.getBoolLiteralValue(true);
   auto &False = Context.getBoolLiteralValue(false);
 
@@ -358,8 +358,8 @@ TEST_F(DataflowAnalysisContextTest, SubstituteFlowConditionContainingNegation) {
 }
 
 TEST_F(DataflowAnalysisContextTest, SubstituteFlowConditionContainingDisjunction) {
-  auto &X = Context.createAtomicBoolValue();
-  auto &Y = Context.createAtomicBoolValue();
+  auto &X = Context.create<AtomicBoolValue>();
+  auto &Y = Context.create<AtomicBoolValue>();
   auto &True = Context.getBoolLiteralValue(true);
   auto &False = Context.getBoolLiteralValue(false);
 
@@ -379,8 +379,8 @@ TEST_F(DataflowAnalysisContextTest, SubstituteFlowConditionContainingDisjunction
 }
 
 TEST_F(DataflowAnalysisContextTest, SubstituteFlowConditionContainingConjunction) {
-  auto &X = Context.createAtomicBoolValue();
-  auto &Y = Context.createAtomicBoolValue();
+  auto &X = Context.create<AtomicBoolValue>();
+  auto &Y = Context.create<AtomicBoolValue>();
   auto &True = Context.getBoolLiteralValue(true);
   auto &False = Context.getBoolLiteralValue(false);
 
@@ -400,8 +400,8 @@ TEST_F(DataflowAnalysisContextTest, SubstituteFlowConditionContainingConjunction
 }
 
 TEST_F(DataflowAnalysisContextTest, SubstituteFlowConditionContainingImplication) {
-  auto &X = Context.createAtomicBoolValue();
-  auto &Y = Context.createAtomicBoolValue();
+  auto &X = Context.create<AtomicBoolValue>();
+  auto &Y = Context.create<AtomicBoolValue>();
   auto &True = Context.getBoolLiteralValue(true);
   auto &False = Context.getBoolLiteralValue(false);
 
@@ -432,8 +432,8 @@ TEST_F(DataflowAnalysisContextTest, SubstituteFlowConditionContainingImplication
 }
 
 TEST_F(DataflowAnalysisContextTest, SubstituteFlowConditionContainingBiconditional) {
-  auto &X = Context.createAtomicBoolValue();
-  auto &Y = Context.createAtomicBoolValue();
+  auto &X = Context.create<AtomicBoolValue>();
+  auto &Y = Context.create<AtomicBoolValue>();
   auto &True = Context.getBoolLiteralValue(true);
   auto &False = Context.getBoolLiteralValue(false);
 
@@ -465,9 +465,9 @@ TEST_F(DataflowAnalysisContextTest, SubstituteFlowConditionContainingBicondition
 }
 
 TEST_F(DataflowAnalysisContextTest, SubstituteFlowConditionsForkedFC) {
-  auto &X = Context.createAtomicBoolValue();
-  auto &Y = Context.createAtomicBoolValue();
-  auto &Z = Context.createAtomicBoolValue();
+  auto &X = Context.create<AtomicBoolValue>();
+  auto &Y = Context.create<AtomicBoolValue>();
+  auto &Z = Context.create<AtomicBoolValue>();
   auto &True = Context.getBoolLiteralValue(true);
   auto &False = Context.getBoolLiteralValue(false);
 
@@ -501,9 +501,9 @@ TEST_F(DataflowAnalysisContextTest, SubstituteFlowConditionsForkedFC) {
 }
 
 TEST_F(DataflowAnalysisContextTest, SubstituteFlowConditionsJoinedFC) {
-  auto &X = Context.createAtomicBoolValue();
-  auto &Y = Context.createAtomicBoolValue();
-  auto &Z = Context.createAtomicBoolValue();
+  auto &X = Context.create<AtomicBoolValue>();
+  auto &Y = Context.create<AtomicBoolValue>();
+  auto &Z = Context.create<AtomicBoolValue>();
   auto &True = Context.getBoolLiteralValue(true);
   auto &False = Context.getBoolLiteralValue(false);
 


        


More information about the cfe-commits mailing list