diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h --- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h +++ b/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 Substitutions) { + return DACtx->buildAndSubstituteFlowCondition(Token, + std::move(Substitutions)); + } + /// Adds `Val` to the set of clauses that constitute the flow condition. void addToFlowCondition(BoolValue &Val); diff --git a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp --- a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp +++ b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp @@ -220,7 +220,7 @@ BoolValue &DataflowAnalysisContext::buildAndSubstituteFlowCondition( AtomicBoolValue &Token, llvm::DenseMap 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()); diff --git a/clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp b/clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp --- a/clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp +++ b/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) {