Skip to content

Commit 1fc1920

Browse files
committed
Fix errors introduced by merging
1 parent f6ffb9b commit 1fc1920

3 files changed

Lines changed: 33 additions & 42 deletions

File tree

include/phasar/PhasarLLVM/Pointer/PointsToSetOwner.h

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include <type_traits>
1717

1818
#include "llvm/ADT/DenseSet.h"
19+
#include "llvm/ADT/STLExtras.h"
20+
#include "llvm/ADT/iterator_range.h"
1921
#include "llvm/Support/ErrorHandling.h"
2022

2123
#include "phasar/PhasarLLVM/Pointer/DynamicPointsToSetPtr.h"
@@ -51,6 +53,7 @@ template <typename PointsToSetTy> class PointsToSetOwner {
5153
OwnedPTS.insert(Ptr);
5254
return &AllPTS.emplace_back(Ptr);
5355
}
56+
5457
void release(PointsToSetTy *PTS) noexcept {
5558
if (LLVM_UNLIKELY(!OwnedPTS.erase(PTS))) {
5659
llvm::report_fatal_error(
@@ -64,23 +67,8 @@ template <typename PointsToSetTy> class PointsToSetOwner {
6467

6568
void reserve(size_t Capacity) { OwnedPTS.reserve(Capacity); }
6669

67-
template <typename CallBackTy,
68-
typename = std::enable_if_t<
69-
std::is_invocable_v<CallBackTy, PointsToSetTy *>>>
70-
void forEachPointsToSet(CallBackTy &&CallBack) {
71-
for (auto &[PTS, Unused] : OwnedPTS) {
72-
std::invoke(std::forward<CallBackTy>(CallBack), PTS);
73-
}
74-
}
75-
76-
template <typename CallBackTy,
77-
typename = std::enable_if_t<
78-
std::is_invocable_v<CallBackTy, const PointsToSetTy *>>>
79-
void forEachPointsToSet(CallBackTy &&CallBack) const {
80-
for (auto &[PTS, Unused] : OwnedPTS) {
81-
std::invoke(std::forward<CallBackTy>(CallBack),
82-
static_cast<const PointsToSetTy *>(PTS));
83-
}
70+
[[nodiscard]] auto getAllPointsToSets() const noexcept {
71+
return llvm::make_range(OwnedPTS.begin(), OwnedPTS.end());
8472
}
8573

8674
private:

lib/PhasarLLVM/Pointer/LLVMPointsToSet.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ LLVMPointsToSet::LLVMPointsToSet(ProjectIRDB &IRDB,
105105
Owner.reserve(Sets.size());
106106
for (const auto &PtsJson : Sets) {
107107
assert(PtsJson.is_array());
108-
auto *PTS = Owner.acquire();
108+
auto PTS = Owner.acquire();
109109
for (auto Alias : PtsJson) {
110110
const auto *Inst = fromMetaDataId(IRDB, Alias.get<std::string>());
111111
if (!Inst) {
@@ -696,7 +696,8 @@ nlohmann::json LLVMPointsToSet::getAsJson() const {
696696

697697
/// Serialize the PointsToSets
698698
auto &Sets = J["PointsToSets"];
699-
Owner.forEachPointsToSet([&Sets](const PointsToSetTy *PTS) {
699+
700+
for (const PointsToSetTy *PTS : Owner.getAllPointsToSets()) {
700701
auto PtsJson = nlohmann::json::array();
701702
for (const auto *Alias : *PTS) {
702703
auto Id = getMetaDataID(Alias);
@@ -707,7 +708,7 @@ nlohmann::json LLVMPointsToSet::getAsJson() const {
707708
if (!PtsJson.empty()) {
708709
Sets.push_back(std::move(PtsJson));
709710
}
710-
});
711+
}
711712

712713
/// Serialize the AnalyzedFunctions
713714
auto &Fns = J["AnalyzedFunctions"];

tools/phasar-llvm/phasar-llvm.cpp

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -473,26 +473,28 @@ int main(int Argc, const char **Argv) {
473473
if (PhasarConfig::VariablesMap().count("persisted-summaries")) {
474474
SolverConfig.setComputePersistedSummaries(
475475
PhasarConfig::VariablesMap()["persisted-summaries"].as<bool>());
476-
nlohmann::json PrecomputedPointsToSet;
477-
if (auto PTAFile = PhasarConfig::VariablesMap().find("load-pta-from-json");
478-
PTAFile != PhasarConfig::VariablesMap().end()) {
479-
PrecomputedPointsToSet =
480-
readJsonFile(llvm::StringRef(PTAFile->second.as<std::string>()));
481-
}
482-
// setup output directory
483-
std::string OutDirectory;
484-
if (PhasarConfig::VariablesMap().count("out")) {
485-
OutDirectory = PhasarConfig::VariablesMap()["out"].as<std::string>();
486-
}
487-
// setup phasar project id
488-
std::string ProjectID;
489-
if (PhasarConfig::VariablesMap().count("project-id")) {
490-
ProjectID = PhasarConfig::VariablesMap()["project-id"].as<std::string>();
491-
}
492-
AnalysisController Controller(
493-
IRDB, DataFlowAnalyses, AnalysisConfigs, PTATy, CGTy, SoundnessLevel,
494-
PhasarConfig::VariablesMap()["auto-globals"].as<bool>(), EntryPoints,
495-
Strategy, EmitterOptions, ProjectID, OutDirectory,
496-
PrecomputedPointsToSet);
497-
return 0;
498476
}
477+
nlohmann::json PrecomputedPointsToSet;
478+
if (auto PTAFile = PhasarConfig::VariablesMap().find("load-pta-from-json");
479+
PTAFile != PhasarConfig::VariablesMap().end()) {
480+
PrecomputedPointsToSet =
481+
readJsonFile(llvm::StringRef(PTAFile->second.as<std::string>()));
482+
}
483+
// setup output directory
484+
std::string OutDirectory;
485+
if (PhasarConfig::VariablesMap().count("out")) {
486+
OutDirectory = PhasarConfig::VariablesMap()["out"].as<std::string>();
487+
}
488+
// setup phasar project id
489+
std::string ProjectID;
490+
if (PhasarConfig::VariablesMap().count("project-id")) {
491+
ProjectID = PhasarConfig::VariablesMap()["project-id"].as<std::string>();
492+
}
493+
AnalysisController Controller(
494+
IRDB, std::move(DataFlowAnalyses), std::move(AnalysisConfigs), PTATy,
495+
CGTy, SoundnessLevel,
496+
PhasarConfig::VariablesMap()["auto-globals"].as<bool>(), EntryPoints,
497+
Strategy, EmitterOptions, SolverConfig, ProjectID, OutDirectory,
498+
PrecomputedPointsToSet);
499+
return 0;
500+
}

0 commit comments

Comments
 (0)