Skip to content

Commit

Permalink
[clang][dataflow] Eliminate deprecated DataflowAnalysis constructor.
Browse files Browse the repository at this point in the history
Reviewed By: ymandel, xazax.hun

Differential Revision: https://reviews.llvm.org/D159261
  • Loading branch information
martinboehme committed Sep 4, 2023
1 parent fb03cd5 commit 37458c6
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 26 deletions.
8 changes: 0 additions & 8 deletions clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,6 @@ class DataflowAnalysis : public TypeErasedDataflowAnalysis {

explicit DataflowAnalysis(ASTContext &Context) : Context(Context) {}

/// Deprecated. Use the `DataflowAnalysisOptions` constructor instead.
explicit DataflowAnalysis(ASTContext &Context, bool ApplyBuiltinTransfer)
: DataflowAnalysis(
Context,
{ApplyBuiltinTransfer
? DataflowAnalysisContext::Options{}
: std::optional<DataflowAnalysisContext::Options>()}) {}

explicit DataflowAnalysis(ASTContext &Context,
DataflowAnalysisOptions Options)
: TypeErasedDataflowAnalysis(Options), Context(Context) {}
Expand Down
9 changes: 0 additions & 9 deletions clang/include/clang/Analysis/FlowSensitive/NoopAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ class NoopAnalysis : public DataflowAnalysis<NoopAnalysis, NoopLattice> {
NoopAnalysis(ASTContext &Context)
: DataflowAnalysis<NoopAnalysis, NoopLattice>(Context) {}

/// Deprecated. Use the `DataflowAnalysisOptions` constructor instead.
NoopAnalysis(ASTContext &Context, bool ApplyBuiltinTransfer)
: DataflowAnalysis<NoopAnalysis, NoopLattice>(Context,
ApplyBuiltinTransfer) {}

/// `ApplyBuiltinTransfer` controls whether to run the built-in transfer
/// functions that model memory during the analysis. Their results are not
/// used by `NoopAnalysis`, but tests that need to inspect the environment
/// should enable them.
NoopAnalysis(ASTContext &Context, DataflowAnalysisOptions Options)
: DataflowAnalysis<NoopAnalysis, NoopLattice>(Context, Options) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ class ModelAdaptorAnalysis
: public DataflowAnalysis<ModelAdaptorAnalysis<Model>, NoopLattice> {
public:
explicit ModelAdaptorAnalysis(ASTContext &Context)
: DataflowAnalysis<ModelAdaptorAnalysis, NoopLattice>(
Context, /*ApplyBuiltinTransfer=*/true) {}
: DataflowAnalysis<ModelAdaptorAnalysis, NoopLattice>(Context) {}

static NoopLattice initialElement() { return NoopLattice(); }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ void checkDataflow(
Code, std::move(TargetFuncMatcher),
[](ASTContext &Context, Environment &) {
return NoopAnalysis(
Context, /*ApplyBuiltinTransfer=*/false);
Context,
// Don't apply builtin transfer function.
DataflowAnalysisOptions{std::nullopt});
})
.withASTBuildArgs({"-fsyntax-only", "-std=c++17"}),
/*VerifyResults=*/std::move(Expectations)),
Expand Down
4 changes: 1 addition & 3 deletions clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1418,9 +1418,7 @@ TEST(TransferTest, BaseClassInitializer) {
checkDataflow<NoopAnalysis>(
AnalysisInputs<NoopAnalysis>(
Code, cxxConstructorDecl(ofClass(hasName("B"))),
[](ASTContext &C, Environment &) {
return NoopAnalysis(C, /*ApplyBuiltinTransfer=*/true);
})
[](ASTContext &C, Environment &) { return NoopAnalysis(C); })
.withASTBuildArgs(
{"-fsyntax-only", "-fno-delayed-template-parsing",
"-std=" + std::string(LangStandard::getLangStandardForKind(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ runAnalysis(llvm::StringRef Code, AnalysisT (*MakeAnalysis)(ASTContext &)) {
TEST(DataflowAnalysisTest, NoopAnalysis) {
auto BlockStates = llvm::cantFail(
runAnalysis<NoopAnalysis>("void target() {}", [](ASTContext &C) {
return NoopAnalysis(C, false);
return NoopAnalysis(C,
// Don't use builtin transfer function.
DataflowAnalysisOptions{std::nullopt});
}));
EXPECT_EQ(BlockStates.size(), 2u);
EXPECT_TRUE(BlockStates[0].has_value());
Expand Down Expand Up @@ -130,7 +132,8 @@ class NonConvergingAnalysis
explicit NonConvergingAnalysis(ASTContext &Context)
: DataflowAnalysis<NonConvergingAnalysis, NonConvergingLattice>(
Context,
/*ApplyBuiltinTransfer=*/false) {}
// Don't apply builtin transfer function.
DataflowAnalysisOptions{std::nullopt}) {}

static NonConvergingLattice initialElement() { return {0}; }

Expand Down Expand Up @@ -811,7 +814,7 @@ class FlowConditionTest : public Test {
AnalysisInputs<NoopAnalysis>(
Code, ast_matchers::hasName("target"),
[](ASTContext &Context, Environment &Env) {
return NoopAnalysis(Context, true);
return NoopAnalysis(Context);
})
.withASTBuildArgs({"-fsyntax-only", "-std=c++17"}),
/*VerifyResults=*/[&Match](const llvm::StringMap<
Expand Down

0 comments on commit 37458c6

Please sign in to comment.