Skip to content

Commit d4b61a7

Browse files
committed
Fix example
1 parent 3477d40 commit d4b61a7

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

examples/how-to/07-write-ifds-analysis/simple.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77

88
namespace {
99

10-
void populateWithMayAliases(psr::LLVMAliasInfoRef AS,
11-
std::set<const llvm::Value *> &Facts);
10+
void populateWithMayAliases(psr::LLVMAliasIteratorRef AS,
11+
std::set<const llvm::Value *> &Facts,
12+
const llvm::Instruction *At);
1213

1314
/// To create a custom IFDS analysis, we must create a subclass of the
1415
/// IFDSTabulationProblem.
@@ -23,7 +24,7 @@ class ExampleTaintAnalysis : public psr::DefaultAliasAwareIFDSProblem {
2324
/// The last parameter of the base-ctor denotes the special zero-value of the
2425
/// IFDS problem. We use LLVMZeroValue for this.
2526
explicit ExampleTaintAnalysis(const psr::LLVMProjectIRDB *IRDB,
26-
psr::LLVMAliasInfoRef AS,
27+
psr::LLVMAliasIteratorRef AS,
2728
const psr::LLVMTaintConfig *Config,
2829
std::vector<std::string> EntryPoints)
2930
: psr::DefaultAliasAwareIFDSProblem(IRDB, AS, std::move(EntryPoints),
@@ -63,8 +64,8 @@ class ExampleTaintAnalysis : public psr::DefaultAliasAwareIFDSProblem {
6364
}
6465

6566
// Since our analysis is alias-aware, we must handle aliasing here:
66-
populateWithMayAliases(getAliasInfo(), Gen);
67-
populateWithMayAliases(getAliasInfo(), Leak);
67+
populateWithMayAliases(getAliasInfo(), Gen, CallSite);
68+
populateWithMayAliases(getAliasInfo(), Leak, CallSite);
6869

6970
// We have special behavior to communicate to the analysis solver, so create
7071
// a flow-function that captures this behavior:
@@ -101,12 +102,12 @@ class ExampleTaintAnalysis : public psr::DefaultAliasAwareIFDSProblem {
101102
};
102103

103104
// For all given facts, we add their aliases:
104-
void populateWithMayAliases(psr::LLVMAliasInfoRef AS,
105-
std::set<const llvm::Value *> &Facts) {
105+
void populateWithMayAliases(psr::LLVMAliasIteratorRef AS,
106+
std::set<const llvm::Value *> &Facts,
107+
const llvm::Instruction *At) {
106108
auto Tmp = Facts;
107109
for (const auto *Fact : Facts) {
108-
auto Aliases = AS.getAliasSet(Fact);
109-
Tmp.insert(Aliases->begin(), Aliases->end());
110+
AS.forallAliasesOf(Fact, At, [&](const auto *Alias) { Tmp.insert(Alias); });
110111
}
111112

112113
Facts = std::move(Tmp);

0 commit comments

Comments
 (0)