Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ enum class SolverConfigOptions : uint32_t {
EmitESG = 16,
ComputePersistedSummaries = 32,

All = ~0u
All = ~0U
};

struct IFDSIDESolverConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,12 @@ template <typename D, typename N> class IFDSSummary : FlowFunction<D> {
: StartNode(Start), EndNode(End), Context(std::move(C)), Outputs(Gen),
ZeroValue(ZV) {}
virtual ~IFDSSummary() = default;
std::set<D> computeTargets(D source) override {
if (source == ZeroValue) {
Outputs.insert(source);
std::set<D> computeTargets(D Source) override {
if (Source == ZeroValue) {
Outputs.insert(Source);
return Outputs;
} else {
return {source};
}
return {Source};
}

N getStartNode() const { return StartNode; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class IFDSTabulationProblem

/// Sets the level of soundness to be used by the analysis. Returns false if
/// the level of soundness is ignored. Otherwise, true.
virtual bool setSoundness(Soundness S) { return false; }
virtual bool setSoundness(Soundness /*S*/) { return false; }
};
} // namespace psr

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ template <typename N, typename D, typename L> class InitialSeeds {

void dump(std::ostream &OS = std::cerr) {

auto printNode = [&](auto &&Node) {
auto printNode = [&](auto &&Node) { // NOLINT
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the problem here?

if constexpr (std::is_same_v<const llvm::Instruction *, N>) {
OS << llvmIRToString(Node);
} else {
OS << Node;
}
};

auto printFact = [&](auto &&Node) {
auto printFact = [&](auto &&Node) { // NOLINT
if constexpr (std::is_same_v<const llvm::Value *, D>) {
OS << llvmIRToString(Node);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ template <typename AnalysisDomainTy> class JoinLattice {
virtual ~JoinLattice() = default;
virtual l_t topElement() = 0;
virtual l_t bottomElement() = 0;
virtual l_t join(l_t lhs, l_t rhs) = 0;
virtual l_t join(l_t Lhs, l_t Rhs) = 0;
};
} // namespace psr

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ namespace psr {
/// \brief Automatically kills temporary loads that are no longer in use.
class AutoKillTMPs : public FlowFunction<const llvm::Value *> {
protected:
FlowFunctionPtrType delegate;
const llvm::Instruction *inst;
FlowFunctionPtrType Delegate;
const llvm::Instruction *Inst;

public:
AutoKillTMPs(FlowFunctionPtrType FF, const llvm::Instruction *In)
: delegate(std::move(FF)), inst(In) {}
virtual ~AutoKillTMPs() = default;
: Delegate(std::move(FF)), Inst(In) {}
~AutoKillTMPs() override = default;

container_type computeTargets(const llvm::Value *Source) override {
container_type Result = delegate->computeTargets(Source);
for (const llvm::Use &U : inst->operands()) {
container_type Result = Delegate->computeTargets(Source);
for (const llvm::Use &U : Inst->operands()) {
if (llvm::isa<llvm::LoadInst>(U)) {
Result.erase(U);
}
Expand Down Expand Up @@ -368,11 +368,11 @@ template <typename D> class PropagateLoad : public FlowFunction<D> {
PropagateLoad(const llvm::LoadInst *L) : Load(L) {}
virtual ~PropagateLoad() = default;

std::set<D> computeTargets(D source) override {
if (source == Load->getPointerOperand()) {
return {source, Load};
std::set<D> computeTargets(D Source) override {
if (Source == Load->getPointerOperand()) {
return {Source, Load};
}
return {source};
return {Source};
}
};

Expand All @@ -384,11 +384,11 @@ template <typename D> class PropagateStore : public FlowFunction<D> {
PropagateStore(const llvm::StoreInst *S) : Store(S) {}
virtual ~PropagateStore() = default;

std::set<D> computeTargets(D source) override {
if (Store->getValueOperand() == source) {
return {source, Store->getPointerOperand()};
std::set<D> computeTargets(D Source) override {
if (Store->getValueOperand() == Source) {
return {Source, Store->getPointerOperand()};
}
return {source};
return {Source};
}
};

Expand All @@ -402,17 +402,17 @@ template <typename D> class StrongUpdateStore : public FlowFunction<D> {

public:
StrongUpdateStore(const llvm::StoreInst *S, std::function<bool(D)> P)
: Store(S), Predicate(P) {}
virtual ~StrongUpdateStore() = default;
: Store(S), Predicate(std::move(P)) {}
~StrongUpdateStore() override = default;

std::set<D> computeTargets(D source) override {
if (source == Store->getPointerOperand()) {
std::set<D> computeTargets(D Source) override {
if (Source == Store->getPointerOperand()) {
return {};
} else if (Predicate(source)) {
return {source, Store->getPointerOperand()};
} else {
return {source};
}
if (Predicate(Source)) {
return {Source, Store->getPointerOperand()};
}
return {Source};
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class LLVMZeroValue : public llvm::GlobalVariable {
LLVMZeroValueInternalName) {
setAlignment(llvm::MaybeAlign(4));
}
static constexpr char LLVMZeroValueInternalName[] = "zero_value";
~LLVMZeroValue() = default;
static constexpr auto LLVMZeroValueInternalName = "zero_value";

public:
LLVMZeroValue(const LLVMZeroValue &Z) = delete;
Expand All @@ -65,7 +66,7 @@ class LLVMZeroValue : public llvm::GlobalVariable {

llvm::StringRef getName() const { return LLVMZeroValueInternalName; }

bool isLLVMZeroValue(const llvm::Value *V) {
bool isLLVMZeroValue(const llvm::Value *V) const {
if (V && V->hasName()) {
// checks if V's name start with "zero_value"
return V->getName().find(LLVMZeroValueInternalName) !=
Expand All @@ -75,9 +76,9 @@ class LLVMZeroValue : public llvm::GlobalVariable {
}

// Do not specify a destructor (at all)!
static LLVMZeroValue *getInstance() {
static LLVMZeroValue *zv = new LLVMZeroValue;
return zv;
static const LLVMZeroValue *getInstance() {
static const auto *ZV = new LLVMZeroValue;
return ZV;
}
};
} // namespace psr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ template <typename D, typename V = BinaryDomain> class SpecialSummaries {
// flow functions.
SpecialSummaries() {
// insert default flow and edge functions
for (auto function_name :
for (const auto &FunctionName :
PhasarConfig::getPhasarConfig().specialFunctionNames()) {
SpecialFlowFunctions.insert(
std::make_pair(function_name, Identity<D>::getInstance()));
std::make_pair(FunctionName, Identity<D>::getInstance()));
SpecialEdgeFunctions.insert(
std::make_pair(function_name, EdgeIdentity<V>::getInstance()));
std::make_pair(FunctionName, EdgeIdentity<V>::getInstance()));
}
}

Expand All @@ -64,62 +64,62 @@ template <typename D, typename V = BinaryDomain> class SpecialSummaries {
~SpecialSummaries() = default;

static SpecialSummaries<D, V> &getInstance() {
static SpecialSummaries<D, V> instance;
return instance;
static SpecialSummaries<D, V> Instance;
return Instance;
}

// Returns true, when an existing function is overwritten, false otherwise.
bool provideSpecialSummary(const std::string &name,
FlowFunctionPtrType flowfunction) {
bool Override = containsSpecialSummary(name);
SpecialFlowFunctions[name] = flowfunction;
bool provideSpecialSummary(const std::string &Name,
FlowFunctionPtrType FlowFunc) {
bool Override = containsSpecialSummary(Name);
SpecialFlowFunctions[Name] = FlowFunc;
return Override;
}

// Returns true, when an existing function is overwritten, false otherwise.
bool provideSpecialSummary(const std::string &name,
FlowFunctionPtrType flowfunction,
std::shared_ptr<EdgeFunction<V>> edgefunction) {
bool Override = containsSpecialSummary(name);
SpecialFlowFunctions[name] = flowfunction;
SpecialEdgeFunctions[name] = edgefunction;
bool provideSpecialSummary(const std::string &Name,
FlowFunctionPtrType FlowFunc,
std::shared_ptr<EdgeFunction<V>> EdgeFunc) {
bool Override = containsSpecialSummary(Name);
SpecialFlowFunctions[Name] = FlowFunc;
SpecialEdgeFunctions[Name] = EdgeFunc;
return Override;
}

bool containsSpecialSummary(const llvm::Function *function) {
return containsSpecialSummary(function->getName().str());
bool containsSpecialSummary(const llvm::Function *Func) {
return containsSpecialSummary(Func->getName().str());
}

bool containsSpecialSummary(const std::string &name) {
return SpecialFlowFunctions.count(name);
bool containsSpecialSummary(const std::string &Name) {
return SpecialFlowFunctions.count(Name);
}

FlowFunctionPtrType
getSpecialFlowFunctionSummary(const llvm::Function *function) {
return getSpecialFlowFunctionSummary(function->getName().str());
getSpecialFlowFunctionSummary(const llvm::Function *Func) {
return getSpecialFlowFunctionSummary(Func->getName().str());
}

FlowFunctionPtrType getSpecialFlowFunctionSummary(const std::string &name) {
return SpecialFlowFunctions[name];
FlowFunctionPtrType getSpecialFlowFunctionSummary(const std::string &Name) {
return SpecialFlowFunctions[Name];
}

std::shared_ptr<EdgeFunction<V>>
getSpecialEdgeFunctionSummary(const llvm::Function *function) {
return getSpecialEdgeFunctionSummary(function->getName().str());
getSpecialEdgeFunctionSummary(const llvm::Function *Func) {
return getSpecialEdgeFunctionSummary(Func->getName().str());
}

std::shared_ptr<EdgeFunction<V>>
getSpecialEdgeFunctionSummary(const std::string &name) {
return SpecialEdgeFunctions[name];
getSpecialEdgeFunctionSummary(const std::string &Name) {
return SpecialEdgeFunctions[Name];
}

friend std::ostream &operator<<(std::ostream &os,
const SpecialSummaries<D> &ss) {
os << "SpecialSummaries:\n";
for (auto &entry : ss.SpecialFunctionNames) {
os << entry.first << " ";
friend std::ostream &operator<<(std::ostream &OS,
const SpecialSummaries<D> &SpecialSumms) {
OS << "SpecialSummaries:\n";
for (auto &Entry : SpecialSumms.SpecialFunctionNames) {
OS << Entry.first << " ";
}
return os;
return OS;
}
};
} // namespace psr
Expand Down