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);
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);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits