Skip to content

Commit 2b99734

Browse files
committed
fixup! fixup! fixup! fixup! [clang][dataflow] Add support for serialization and deserialization.
adjust algorithm for dep. collection
1 parent 2dfb0ab commit 2b99734

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,7 @@ class DataflowAnalysisContext {
260260
/// Computes the transitive closure of dependencies of (flow-condition)
261261
/// `Tokens`. That is, the set of flow-condition tokens reachable from
262262
/// `Tokens` in the dependency graph.
263-
llvm::DenseSet<Atom>
264-
collectDependencies(const llvm::DenseSet<Atom> &Tokens) const;
263+
llvm::DenseSet<Atom> collectDependencies(llvm::DenseSet<Atom> Tokens) const;
265264

266265
// Extends the set of modeled field declarations.
267266
void addModeledFields(const FieldSet &Fields);

clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -209,24 +209,21 @@ bool DataflowAnalysisContext::equivalentFormulas(const Formula &Val1,
209209
}
210210

211211
llvm::DenseSet<Atom> DataflowAnalysisContext::collectDependencies(
212-
const llvm::DenseSet<Atom> &Tokens) const {
213-
llvm::DenseSet<Atom> VisitedTokens;
214-
// Use a worklist algorithm, with `Remaining` holding the worklist.
212+
llvm::DenseSet<Atom> Tokens) const {
213+
// Use a worklist algorithm, with `Remaining` holding the worklist and
214+
// `Tokens` tracking which atoms have already been added to the worklist.
215215
std::vector<Atom> Remaining(Tokens.begin(), Tokens.end());
216-
217-
// For each token in `Remaining`, add its dependencies to the worklist.
218216
while (!Remaining.empty()) {
219-
auto Token = Remaining.back();
217+
Atom CurrentToken = Remaining.back();
220218
Remaining.pop_back();
221-
if (!VisitedTokens.insert(Token).second)
222-
continue;
223-
if (auto DepsIt = FlowConditionDeps.find(Token);
219+
if (auto DepsIt = FlowConditionDeps.find(CurrentToken);
224220
DepsIt != FlowConditionDeps.end())
225221
for (Atom A : DepsIt->second)
226-
Remaining.push_back(A);
222+
if (Tokens.insert(A).second)
223+
Remaining.push_back(A);
227224
}
228225

229-
return VisitedTokens;
226+
return Tokens;
230227
}
231228

232229
void DataflowAnalysisContext::addTransitiveFlowConditionConstraints(
@@ -294,7 +291,7 @@ SimpleLogicalContext DataflowAnalysisContext::exportLogicalContext(
294291
}
295292

296293
llvm::DenseSet<dataflow::Atom> Dependencies =
297-
collectDependencies(TargetTokens);
294+
collectDependencies(std::move(TargetTokens));
298295

299296
for (dataflow::Atom Token : Dependencies) {
300297
// Only process the token if it is constrained. Unconstrained tokens don't

0 commit comments

Comments
 (0)