[PATCH] D141319: [clang][dataflow][NFC] Refine names and comments for field filtering.
Yitzhak Mandelbaum via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 10 06:29:17 PST 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG089a54469f63: [clang][dataflow][NFC] Refine names and comments for field filtering. (authored by ymandel).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D141319/new/
https://reviews.llvm.org/D141319
Files:
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===================================================================
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -253,7 +253,7 @@
initVars(Vars);
// These have to be set before the lines that follow to ensure that create*
// work correctly for structs.
- DACtx.addFieldsReferencedInScope(std::move(Fields));
+ DACtx.addModeledFields(Fields);
for (const auto *ParamDecl : FuncDecl->parameters()) {
assert(ParamDecl != nullptr);
@@ -342,7 +342,7 @@
}
getFieldsAndGlobalVars(*FuncDecl->getBody(), Fields, Vars);
initVars(Vars);
- DACtx->addFieldsReferencedInScope(std::move(Fields));
+ DACtx->addModeledFields(Fields);
const auto *ParamIt = FuncDecl->param_begin();
Index: clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
===================================================================
--- clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -25,15 +25,15 @@
namespace clang {
namespace dataflow {
-void DataflowAnalysisContext::addFieldsReferencedInScope(
- llvm::DenseSet<const FieldDecl *> Fields) {
- llvm::set_union(FieldsReferencedInScope, Fields);
+void DataflowAnalysisContext::addModeledFields(
+ const llvm::DenseSet<const FieldDecl *> &Fields) {
+ llvm::set_union(ModeledFields, Fields);
}
llvm::DenseSet<const FieldDecl *>
DataflowAnalysisContext::getReferencedFields(QualType Type) {
llvm::DenseSet<const FieldDecl *> Fields = getObjectFields(Type);
- llvm::set_intersect(Fields, FieldsReferencedInScope);
+ llvm::set_intersect(Fields, ModeledFields);
return Fields;
}
@@ -46,7 +46,7 @@
// the allocation. Since we only collect fields used in the function where
// the allocation occurs, we can't apply that filter when performing
// context-sensitive analysis. But, this only applies to storage locations,
- // since fields access it not allowed to fail. In contrast, field *values*
+ // since field access it not allowed to fail. In contrast, field *values*
// don't need this allowance, since the API allows for uninitialized fields.
auto Fields = Opts.ContextSensitiveOpts ? getObjectFields(Type)
: getReferencedFields(Type);
Index: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
===================================================================
--- clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
+++ clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
@@ -269,8 +269,6 @@
/// returns null.
const ControlFlowContext *getControlFlowContext(const FunctionDecl *F);
- void addFieldsReferencedInScope(llvm::DenseSet<const FieldDecl *> Fields);
-
const Options &getOptions() { return Opts; }
private:
@@ -287,8 +285,11 @@
using DenseMapInfo::isEqual;
};
- /// Returns the subset of fields of `Type` that are referenced in the scope of
- /// the analysis.
+ // Extends the set of modeled field declarations.
+ void addModeledFields(const llvm::DenseSet<const FieldDecl *> &Fields);
+
+ /// Returns the fields of `Type`, limited to the set of fields modeled by this
+ /// context.
llvm::DenseSet<const FieldDecl *> getReferencedFields(QualType Type);
/// Adds all constraints of the flow condition identified by `Token` and all
@@ -388,8 +389,8 @@
llvm::DenseMap<const FunctionDecl *, ControlFlowContext> FunctionContexts;
- // All fields referenced (statically) in the scope of the analysis.
- llvm::DenseSet<const FieldDecl *> FieldsReferencedInScope;
+ // Fields modeled by environments covered by this context.
+ llvm::DenseSet<const FieldDecl *> ModeledFields;
};
} // namespace dataflow
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141319.487779.patch
Type: text/x-patch
Size: 3911 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230110/2b0429d1/attachment-0001.bin>
More information about the cfe-commits
mailing list