Skip to content

Commit 23ea6b9

Browse files
mxHuberfabianbs96
andauthored
fixed warnings coming from phasar code (#799)
* fixed warnings coming from phasar code * Fixed error + missed Z3 warnings * changed tmpnam for mkstemp + maybe unused flags * removed mkstemp, print ESG to llvm::errs() --------- Co-authored-by: Fabian Schiebel <52407375+fabianbs96@users.noreply.github.com>
1 parent 4e7aa00 commit 23ea6b9

File tree

16 files changed

+27
-39
lines changed

16 files changed

+27
-39
lines changed

include/phasar/DataFlow/IfdsIde/DefaultEdgeFunctionSingletonCache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class DefaultEdgeFunctionSingletonCacheImpl
4646

4747
void insert(const EdgeFunctionTy *EF, const void *Mem) override {
4848
assert(EF != nullptr);
49-
auto [It, Inserted] = Cache.try_emplace(EF, Mem);
49+
[[maybe_unused]] auto [It, Inserted] = Cache.try_emplace(EF, Mem);
5050
assert(Inserted);
5151
}
5252

include/phasar/DataFlow/IfdsIde/Solver/IterativeIDESolver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ class IterativeIDESolver
569569

570570
auto AtInstruction = NodeCompressor[AtInstructionId];
571571

572-
auto FunId = [=] {
572+
auto FunId = [&] {
573573
if constexpr (EnableJumpFunctionGC != JumpFunctionGCMode::Disabled) {
574574

575575
auto Ret = FunCompressor.getOrInsert(ICFG.getFunctionOf(AtInstruction));

include/phasar/DataFlow/PathSensitivity/PathSensitivityManagerMixin.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,9 @@ class PathSensitivityManagerMixin {
8989
if (LLVM_UNLIKELY(!Nod)) {
9090
llvm::errs() << "Invalid Instruction-FlowFact pair. Only use those "
9191
"pairs that are part of the IDE analysis results!\n";
92-
llvm::errs() << "Fatal error occurred. Writing ESG to temp file...\n";
93-
llvm::errs().flush();
94-
95-
auto FileName = std::string(tmpnam(nullptr)) + "-explicitesg-err.dot";
96-
97-
{
98-
std::error_code EC;
99-
llvm::raw_fd_ostream ROS(FileName, EC);
100-
ESG.printAsDot(ROS);
101-
}
92+
llvm::errs() << "Fatal error occurred. Printing ESG ...\n";
10293

103-
llvm::errs() << "> ESG written to " << FileName << '\n';
94+
ESG.printAsDot(llvm::errs());
10495
llvm::errs().flush();
10596

10697
abort();

lib/PhasarLLVM/ControlFlow/GlobalCtorsDtorsModel.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ static void insertGlobalCtorsDtorsImpl(MapTy &Into, const llvm::Module &M,
3030
return;
3131
}
3232

33-
if (const auto *FunArray =
34-
llvm::dyn_cast<llvm::ArrayType>(Gtors->getValueType())) {
33+
if (llvm::isa<llvm::ArrayType>(Gtors->getValueType())) {
3534
if (const auto *ConstFunArray =
3635
llvm::dyn_cast<llvm::ConstantArray>(Gtors->getInitializer())) {
3736
for (const auto &Op : ConstFunArray->operands()) {

lib/PhasarLLVM/ControlFlow/SVFGCache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static bool shouldKeepInst(const llvm::Instruction *Inst,
9494
const auto *ValTy = Val->getType();
9595
bool ValPtr = ValTy->isPointerTy();
9696

97-
if (const auto *Call = llvm::dyn_cast<llvm::CallBase>(Inst)) {
97+
if (llvm::isa<llvm::CallBase>(Inst)) {
9898
if (llvm::isa<llvm::GlobalValue>(Val)) {
9999
return true;
100100
}

lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEGeneralizedLCA/ConstantHelper.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ bool psr::glca::isConstant(const llvm::Value *Val) {
3232
auto *Op1 = Gep->getOperand(0); // op1 is pointer-operand
3333
if (auto *Glob = llvm::dyn_cast<llvm::GlobalVariable>(Op1);
3434
Glob && Glob->hasInitializer()) {
35-
if (auto *Cdat =
36-
llvm::dyn_cast<llvm::ConstantDataArray>(Glob->getInitializer())) {
35+
if (llvm::isa<llvm::ConstantDataArray>(Glob->getInitializer())) {
3736
return true; // it is definitely a const string
3837
}
3938
}

lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEGeneralizedLCA/IDEGeneralizedLCA.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ IDEGeneralizedLCA::getNormalFlowFunction(IDEGeneralizedLCA::n_t Curr,
6161
const auto *ValueOp = Store->getValueOperand();
6262
if (isConstant(ValueOp)) {
6363
// llvm::outs() << "==> constant store" << std::endl;
64-
return lambdaFlow([=](IDEGeneralizedLCA::d_t Source)
64+
return lambdaFlow([this, PointerOp](IDEGeneralizedLCA::d_t Source)
6565
-> std::set<IDEGeneralizedLCA::d_t> {
6666
// llvm::outs() << "##> normal lambdaFlow for: " <<
6767
// llvmIRToString(curr)
@@ -131,7 +131,8 @@ IDEGeneralizedLCA::getNormalFlowFunction(IDEGeneralizedLCA::n_t Curr,
131131
bool NoneConst = !LeftConst && !RightConst;
132132

133133
return lambdaFlow(
134-
[=](IDEGeneralizedLCA::d_t Source) -> std::set<IDEGeneralizedLCA::d_t> {
134+
[this, Lhs, Rhs, BothConst, NoneConst, Curr](
135+
IDEGeneralizedLCA::d_t Source) -> std::set<IDEGeneralizedLCA::d_t> {
135136
if (Source == Lhs || Source == Rhs ||
136137
((BothConst || NoneConst) && isZeroValue(Source))) {
137138
return {Source, Curr};

lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEInstInteractionAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ IDEIIAFlowFact::IDEIIAFlowFact(
3535
}
3636

3737
IDEIIAFlowFact IDEIIAFlowFact::create(const llvm::Value *BaseVal) {
38-
if (const auto *Alloca = llvm::dyn_cast<llvm::AllocaInst>(BaseVal)) {
38+
if (llvm::isa<llvm::AllocaInst>(BaseVal)) {
3939
return {BaseVal};
4040
}
4141
if (const auto *Gep = llvm::dyn_cast<llvm::GetElementPtrInst>(BaseVal)) {

lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysis.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,7 @@ IDELinearConstantAnalysis::getNormalFlowFunction(n_t Curr, n_t /*Succ*/) {
347347
/// We are extracting the result of a BinaryOpIntrinsic
348348
/// The first parameter holds the resulting integer if
349349
/// no error occured during the operation
350-
if (const auto *BinIntrinsic =
351-
llvm::dyn_cast<llvm::BinaryOpIntrinsic>(Agg)) {
350+
if (llvm::isa<llvm::BinaryOpIntrinsic>(Agg)) {
352351
if (Extract->getType()->isIntegerTy()) {
353352
return generateFlow(Curr, Agg);
354353
}

lib/PhasarLLVM/DataFlow/PathSensitivity/LLVMPathConstraints.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,7 @@ auto LLVMPathConstraints::getGEPInstAsZ3(const llvm::GetElementPtrInst *GEP)
609609
.first->second;
610610
}
611611
// some other pointer, we can treat those as integers
612-
if (const auto *PointerTy =
613-
llvm::dyn_cast<llvm::PointerType>(GEP->getPointerOperandType())) {
612+
if (llvm::isa<llvm::PointerType>(GEP->getPointerOperandType())) {
614613
auto PointerConst = Z3Ctx->bv_const(Name.c_str(), 64);
615614
return Z3Expr.try_emplace(GEP, ConstraintAndVariables{PointerConst, {GEP}})
616615
.first->second;

0 commit comments

Comments
 (0)