Tweaks elements of the new API for filtering the set of modeled fields.
Differential Revision: https://reviews.llvm.org/D141319
/// returns null.
const ControlFlowContext *getControlFlowContext(const FunctionDecl *F);
- void addFieldsReferencedInScope(llvm::DenseSet<const FieldDecl *> Fields);
-
const Options &getOptions() { return Opts; }
private:
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
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
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;
}
// 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);
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);
}
getFieldsAndGlobalVars(*FuncDecl->getBody(), Fields, Vars);
initVars(Vars);
- DACtx->addFieldsReferencedInScope(std::move(Fields));
+ DACtx->addModeledFields(Fields);
const auto *ParamIt = FuncDecl->param_begin();