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 @@ -46,7 +46,7 @@ class DefaultEdgeFunctionSingletonCacheImpl

void insert(const EdgeFunctionTy *EF, const void *Mem) override {
assert(EF != nullptr);
auto [It, Inserted] = Cache.try_emplace(EF, Mem);
[[maybe_unused]] auto [It, Inserted] = Cache.try_emplace(EF, Mem);
assert(Inserted);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ class IterativeIDESolver

auto AtInstruction = NodeCompressor[AtInstructionId];

auto FunId = [=] {
auto FunId = [&] {
if constexpr (EnableJumpFunctionGC != JumpFunctionGCMode::Disabled) {

auto Ret = FunCompressor.getOrInsert(ICFG.getFunctionOf(AtInstruction));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,9 @@ class PathSensitivityManagerMixin {
if (LLVM_UNLIKELY(!Nod)) {
llvm::errs() << "Invalid Instruction-FlowFact pair. Only use those "
"pairs that are part of the IDE analysis results!\n";
llvm::errs() << "Fatal error occurred. Writing ESG to temp file...\n";
llvm::errs().flush();

auto FileName = std::string(tmpnam(nullptr)) + "-explicitesg-err.dot";

{
std::error_code EC;
llvm::raw_fd_ostream ROS(FileName, EC);
ESG.printAsDot(ROS);
}
llvm::errs() << "Fatal error occurred. Printing ESG ...\n";

llvm::errs() << "> ESG written to " << FileName << '\n';
ESG.printAsDot(llvm::errs());
llvm::errs().flush();

abort();
Expand Down
3 changes: 1 addition & 2 deletions lib/PhasarLLVM/ControlFlow/GlobalCtorsDtorsModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ static void insertGlobalCtorsDtorsImpl(MapTy &Into, const llvm::Module &M,
return;
}

if (const auto *FunArray =
llvm::dyn_cast<llvm::ArrayType>(Gtors->getValueType())) {
if (llvm::isa<llvm::ArrayType>(Gtors->getValueType())) {
if (const auto *ConstFunArray =
llvm::dyn_cast<llvm::ConstantArray>(Gtors->getInitializer())) {
for (const auto &Op : ConstFunArray->operands()) {
Expand Down
2 changes: 1 addition & 1 deletion lib/PhasarLLVM/ControlFlow/SVFGCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static bool shouldKeepInst(const llvm::Instruction *Inst,
const auto *ValTy = Val->getType();
bool ValPtr = ValTy->isPointerTy();

if (const auto *Call = llvm::dyn_cast<llvm::CallBase>(Inst)) {
if (llvm::isa<llvm::CallBase>(Inst)) {
if (llvm::isa<llvm::GlobalValue>(Val)) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ bool psr::glca::isConstant(const llvm::Value *Val) {
auto *Op1 = Gep->getOperand(0); // op1 is pointer-operand
if (auto *Glob = llvm::dyn_cast<llvm::GlobalVariable>(Op1);
Glob && Glob->hasInitializer()) {
if (auto *Cdat =
llvm::dyn_cast<llvm::ConstantDataArray>(Glob->getInitializer())) {
if (llvm::isa<llvm::ConstantDataArray>(Glob->getInitializer())) {
return true; // it is definitely a const string
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ IDEGeneralizedLCA::getNormalFlowFunction(IDEGeneralizedLCA::n_t Curr,
const auto *ValueOp = Store->getValueOperand();
if (isConstant(ValueOp)) {
// llvm::outs() << "==> constant store" << std::endl;
return lambdaFlow([=](IDEGeneralizedLCA::d_t Source)
return lambdaFlow([this, PointerOp](IDEGeneralizedLCA::d_t Source)
-> std::set<IDEGeneralizedLCA::d_t> {
// llvm::outs() << "##> normal lambdaFlow for: " <<
// llvmIRToString(curr)
Expand Down Expand Up @@ -131,7 +131,8 @@ IDEGeneralizedLCA::getNormalFlowFunction(IDEGeneralizedLCA::n_t Curr,
bool NoneConst = !LeftConst && !RightConst;

return lambdaFlow(
[=](IDEGeneralizedLCA::d_t Source) -> std::set<IDEGeneralizedLCA::d_t> {
[this, Lhs, Rhs, BothConst, NoneConst, Curr](
IDEGeneralizedLCA::d_t Source) -> std::set<IDEGeneralizedLCA::d_t> {
if (Source == Lhs || Source == Rhs ||
((BothConst || NoneConst) && isZeroValue(Source))) {
return {Source, Curr};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ IDEIIAFlowFact::IDEIIAFlowFact(
}

IDEIIAFlowFact IDEIIAFlowFact::create(const llvm::Value *BaseVal) {
if (const auto *Alloca = llvm::dyn_cast<llvm::AllocaInst>(BaseVal)) {
if (llvm::isa<llvm::AllocaInst>(BaseVal)) {
return {BaseVal};
}
if (const auto *Gep = llvm::dyn_cast<llvm::GetElementPtrInst>(BaseVal)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,7 @@ IDELinearConstantAnalysis::getNormalFlowFunction(n_t Curr, n_t /*Succ*/) {
/// We are extracting the result of a BinaryOpIntrinsic
/// The first parameter holds the resulting integer if
/// no error occured during the operation
if (const auto *BinIntrinsic =
llvm::dyn_cast<llvm::BinaryOpIntrinsic>(Agg)) {
if (llvm::isa<llvm::BinaryOpIntrinsic>(Agg)) {
if (Extract->getType()->isIntegerTy()) {
return generateFlow(Curr, Agg);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,7 @@ auto LLVMPathConstraints::getGEPInstAsZ3(const llvm::GetElementPtrInst *GEP)
.first->second;
}
// some other pointer, we can treat those as integers
if (const auto *PointerTy =
llvm::dyn_cast<llvm::PointerType>(GEP->getPointerOperandType())) {
if (llvm::isa<llvm::PointerType>(GEP->getPointerOperandType())) {
auto PointerConst = Z3Ctx->bv_const(Name.c_str(), 64);
return Z3Expr.try_emplace(GEP, ConstraintAndVariables{PointerConst, {GEP}})
.first->second;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ z3::expr Z3BasedPathSensitivityManagerBase::filterOutUnreachableNodes(
Ctx.Visited.resize(graph_traits_t::size(RevDAG));
Ctx.NodeConstraints.resize(graph_traits_t::size(RevDAG), Ctx.True);

size_t TotalNumEdges = 0;
[[maybe_unused]] size_t TotalNumEdges = 0;
for (auto I : graph_traits_t::vertices(RevDAG)) {
TotalNumEdges += graph_traits_t::outDegree(RevDAG, I);
}
Expand All @@ -55,7 +55,7 @@ z3::expr Z3BasedPathSensitivityManagerBase::filterOutUnreachableNodes(

llvm::SmallVector<z3::expr> Ys;

for (auto Iter = graph_traits_t::outEdges(RevDAG, Vtx).begin();
for (const auto *Iter = graph_traits_t::outEdges(RevDAG, Vtx).begin();
Iter != graph_traits_t::outEdges(RevDAG, Vtx).end();) {
// NOLINTNEXTLINE(readability-qualified-auto, llvm-qualified-auto)
auto It = Iter++;
Expand Down Expand Up @@ -103,7 +103,7 @@ z3::expr Z3BasedPathSensitivityManagerBase::filterOutUnreachableNodes(

z3::expr Ret = LPC.getContext().bool_val(false);

for (auto Iter = graph_traits_t::roots(RevDAG).begin();
for (const auto *Iter = graph_traits_t::roots(RevDAG).begin();
Iter != graph_traits_t::roots(RevDAG).end();) {
// NOLINTNEXTLINE(readability-qualified-auto, llvm-qualified-auto)
auto It = Iter++;
Expand Down Expand Up @@ -322,7 +322,7 @@ class ConstraintPathFilter {

ConstraintPathFilter(LLVMPathConstraints &LPC,
const z3::expr &AdditionalConstraint,
size_t *CompletedCtr) noexcept
const size_t *CompletedCtr) noexcept
: LPC(LPC), Solver(LPC.getContext()), CompletedCtr(*CompletedCtr) {
Solver.add(AdditionalConstraint);
Solver.push();
Expand Down Expand Up @@ -450,7 +450,7 @@ class ConstraintPathFilter {
size_t Ctr = 0;
size_t RejectedCtr = 0;
size_t IsValidCalls = 0;
size_t &CompletedCtr;
[[maybe_unused]] const size_t &CompletedCtr;
};

auto Z3BasedPathSensitivityManagerBase::filterAndFlattenRevDag(
Expand Down
3 changes: 1 addition & 2 deletions lib/PhasarLLVM/Passes/GeneralStatisticsAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ GeneralStatistics GeneralStatisticsAnalysis::runOnModule(llvm::Module &M) {
}

// check for alloca instruction for possible types
if (const llvm::AllocaInst *Alloc =
llvm::dyn_cast<llvm::AllocaInst>(&I)) {
if (llvm::isa<llvm::AllocaInst>(&I)) {
// do not add allocas from llvm internal functions
Stats.AllocaInstructions.insert(&I);
++Stats.AllocationSites;
Expand Down
2 changes: 1 addition & 1 deletion lib/PhasarLLVM/Pointer/FilteredAliasesUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ inline LLVM_LIBRARY_VISIBILITY bool mustNoalias(const llvm::Value *P1,
if (llvm::isa<llvm::AllocaInst>(P2) || isConstantGlobalValue(Glob1)) {
return true;
}
if (const auto *Glob2 = llvm::dyn_cast<llvm::GlobalValue>(P2)) {
if (llvm::isa<llvm::GlobalValue>(P2)) {
return true; // approximation
}
} else if (const auto *Glob2 = llvm::dyn_cast<llvm::GlobalValue>(P2)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/PhasarLLVM/Utils/Annotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace psr {

VarAnnotation::VarAnnotation(const llvm::CallBase *AnnotationCall) noexcept
: AnnotationCall(AnnotationCall) {
auto *Callee = AnnotationCall->getCalledFunction();
[[maybe_unused]] auto *Callee = AnnotationCall->getCalledFunction();
assert(Callee && Callee->hasName() &&
(Callee->getName() == "llvm.var.annotation" ||
Callee->getName().startswith("llvm.ptr.annotation")));
Expand Down
9 changes: 5 additions & 4 deletions lib/Utils/PAMM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ void PAMM::startTimer(llvm::StringRef TimerId) {
}

void PAMM::resetTimer(llvm::StringRef TimerId) {
bool InRunningTimers = RunningTimer.erase(TimerId);
bool InStoppedTimers = StoppedTimer.erase(TimerId);
[[maybe_unused]] bool InRunningTimers = RunningTimer.erase(TimerId);
[[maybe_unused]] bool InStoppedTimers = StoppedTimer.erase(TimerId);

assert((InRunningTimers && !InStoppedTimers) ||
(!InRunningTimers && InStoppedTimers) &&
Expand Down Expand Up @@ -149,7 +149,8 @@ std::string PAMM::getPrintableDuration(uint64_t Duration) {
}

void PAMM::regCounter(llvm::StringRef CounterId, unsigned IntialValue) {
auto [It, Inserted] = Counter.try_emplace(CounterId, IntialValue);
[[maybe_unused]] auto [It, Inserted] =
Counter.try_emplace(CounterId, IntialValue);
assert(Inserted && "regCounter failed due to an invalid counter id");
}

Expand Down Expand Up @@ -214,7 +215,7 @@ PAMM::getSumCount(std::initializer_list<llvm::StringRef> CounterIds) {
}

void PAMM::regHistogram(llvm::StringRef HistogramId) {
auto [It, Inserted] = Histogram.try_emplace(HistogramId);
[[maybe_unused]] auto [It, Inserted] = Histogram.try_emplace(HistogramId);
assert(Inserted && "failed to register new histogram due to an invalid id");
}

Expand Down
2 changes: 1 addition & 1 deletion tools/example-tool/myphasartool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int main(int Argc, const char **Argv) {
return 1;
}

if (const auto *F = HA.getProjectIRDB().getFunctionDefinition("main")) {
if (HA.getProjectIRDB().getFunctionDefinition("main")) {
// print type hierarchy
HA.getTypeHierarchy().print();
// print points-to information
Expand Down
Loading