[clang] 5ddb623 - [clang][dataflow] Remove unnecessary `ASTContext` parameter from `ControlFlowContext::build` overload.
Martin Braenne via cfe-commits
cfe-commits at lists.llvm.org
Tue May 30 00:05:47 PDT 2023
Author: Martin Braenne
Date: 2023-05-30T07:05:35Z
New Revision: 5ddb623952cacba0a3933dacd4c70439ca95c70d
URL: https://github.com/llvm/llvm-project/commit/5ddb623952cacba0a3933dacd4c70439ca95c70d
DIFF: https://github.com/llvm/llvm-project/commit/5ddb623952cacba0a3933dacd4c70439ca95c70d.diff
LOG: [clang][dataflow] Remove unnecessary `ASTContext` parameter from `ControlFlowContext::build` overload.
When introducing this new overload in https://reviews.llvm.org/D151183, I didn't consider that the `ASTContext` parameter was unnecessary because it could also be obtained from the `FunctionDecl`.
Reviewed By: gribozavr2, xazax.hun
Differential Revision: https://reviews.llvm.org/D151549
Added:
Modified:
clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
clang/unittests/Analysis/FlowSensitive/TestingSupport.h
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h b/clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
index f327011766069..bb36ed237c1e3 100644
--- a/clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
+++ b/clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
@@ -33,8 +33,7 @@ class ControlFlowContext {
public:
/// Builds a ControlFlowContext from a `FunctionDecl`.
/// `Func.hasBody()` must be true, and `Func.isTemplated()` must be false.
- static llvm::Expected<ControlFlowContext> build(const FunctionDecl &Func,
- ASTContext &C);
+ static llvm::Expected<ControlFlowContext> build(const FunctionDecl &Func);
/// Builds a ControlFlowContext from an AST node. `D` is the function in which
/// `S` resides. `D.isTemplated()` must be false.
diff --git a/clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp b/clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
index c62bff33524cf..c80525dc4f34f 100644
--- a/clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
+++ b/clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
@@ -68,13 +68,13 @@ static llvm::BitVector findReachableBlocks(const CFG &Cfg) {
}
llvm::Expected<ControlFlowContext>
-ControlFlowContext::build(const FunctionDecl &Func, ASTContext &C) {
+ControlFlowContext::build(const FunctionDecl &Func) {
if (!Func.hasBody())
return llvm::createStringError(
std::make_error_code(std::errc::invalid_argument),
"Cannot analyze function without a body");
- return build(Func, *Func.getBody(), C);
+ return build(Func, *Func.getBody(), Func.getASTContext());
}
llvm::Expected<ControlFlowContext>
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
index 32612397ec024..27ec15adc5350 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -211,7 +211,7 @@ DataflowAnalysisContext::getControlFlowContext(const FunctionDecl *F) {
return &It->second;
if (F->hasBody()) {
- auto CFCtx = ControlFlowContext::build(*F, F->getASTContext());
+ auto CFCtx = ControlFlowContext::build(*F);
// FIXME: Handle errors.
assert(CFCtx);
auto Result = FunctionContexts.insert({F, std::move(*CFCtx)});
diff --git a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h b/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
index d5591bee12dc2..aa2b2a241b224 100644
--- a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
+++ b/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
@@ -241,7 +241,7 @@ checkDataflow(AnalysisInputs<AnalysisT> AI,
llvm::errc::invalid_argument, "Could not find the target function.");
// Build the control flow graph for the target function.
- auto MaybeCFCtx = ControlFlowContext::build(*Target, Context);
+ auto MaybeCFCtx = ControlFlowContext::build(*Target);
if (!MaybeCFCtx) return MaybeCFCtx.takeError();
auto &CFCtx = *MaybeCFCtx;
diff --git a/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp b/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
index 1d94b69cfce81..473750ad7a6cb 100644
--- a/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -65,7 +65,7 @@ runAnalysis(llvm::StringRef Code, AnalysisT (*MakeAnalysis)(ASTContext &)) {
assert(Func != nullptr);
auto CFCtx =
- llvm::cantFail(ControlFlowContext::build(*Func, AST->getASTContext()));
+ llvm::cantFail(ControlFlowContext::build(*Func));
AnalysisT Analysis = MakeAnalysis(AST->getASTContext());
DataflowAnalysisContext DACtx(std::make_unique<WatchedLiteralsSolver>());
More information about the cfe-commits
mailing list