diff --git a/include/phasar/DataFlow/IfdsIde/DefaultEdgeFunctionSingletonCache.h b/include/phasar/DataFlow/IfdsIde/DefaultEdgeFunctionSingletonCache.h index e78af20707..5bba997606 100644 --- a/include/phasar/DataFlow/IfdsIde/DefaultEdgeFunctionSingletonCache.h +++ b/include/phasar/DataFlow/IfdsIde/DefaultEdgeFunctionSingletonCache.h @@ -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); } diff --git a/include/phasar/DataFlow/IfdsIde/Solver/IterativeIDESolver.h b/include/phasar/DataFlow/IfdsIde/Solver/IterativeIDESolver.h index 9ae1b0a2db..2fab0ac482 100644 --- a/include/phasar/DataFlow/IfdsIde/Solver/IterativeIDESolver.h +++ b/include/phasar/DataFlow/IfdsIde/Solver/IterativeIDESolver.h @@ -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)); diff --git a/include/phasar/DataFlow/PathSensitivity/PathSensitivityManagerMixin.h b/include/phasar/DataFlow/PathSensitivity/PathSensitivityManagerMixin.h index 74ed9e1c51..761d7a88de 100644 --- a/include/phasar/DataFlow/PathSensitivity/PathSensitivityManagerMixin.h +++ b/include/phasar/DataFlow/PathSensitivity/PathSensitivityManagerMixin.h @@ -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(); diff --git a/lib/PhasarLLVM/ControlFlow/GlobalCtorsDtorsModel.cpp b/lib/PhasarLLVM/ControlFlow/GlobalCtorsDtorsModel.cpp index cffe27cb89..be92564c4f 100644 --- a/lib/PhasarLLVM/ControlFlow/GlobalCtorsDtorsModel.cpp +++ b/lib/PhasarLLVM/ControlFlow/GlobalCtorsDtorsModel.cpp @@ -30,8 +30,7 @@ static void insertGlobalCtorsDtorsImpl(MapTy &Into, const llvm::Module &M, return; } - if (const auto *FunArray = - llvm::dyn_cast(Gtors->getValueType())) { + if (llvm::isa(Gtors->getValueType())) { if (const auto *ConstFunArray = llvm::dyn_cast(Gtors->getInitializer())) { for (const auto &Op : ConstFunArray->operands()) { diff --git a/lib/PhasarLLVM/ControlFlow/SVFGCache.cpp b/lib/PhasarLLVM/ControlFlow/SVFGCache.cpp index c7a49c7ac4..97b98e93d9 100644 --- a/lib/PhasarLLVM/ControlFlow/SVFGCache.cpp +++ b/lib/PhasarLLVM/ControlFlow/SVFGCache.cpp @@ -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(Inst)) { + if (llvm::isa(Inst)) { if (llvm::isa(Val)) { return true; } diff --git a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEGeneralizedLCA/ConstantHelper.cpp b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEGeneralizedLCA/ConstantHelper.cpp index 587a3bb2ac..81d4290d5d 100644 --- a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEGeneralizedLCA/ConstantHelper.cpp +++ b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEGeneralizedLCA/ConstantHelper.cpp @@ -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(Op1); Glob && Glob->hasInitializer()) { - if (auto *Cdat = - llvm::dyn_cast(Glob->getInitializer())) { + if (llvm::isa(Glob->getInitializer())) { return true; // it is definitely a const string } } diff --git a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEGeneralizedLCA/IDEGeneralizedLCA.cpp b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEGeneralizedLCA/IDEGeneralizedLCA.cpp index 9ca21c73c5..5395cda525 100644 --- a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEGeneralizedLCA/IDEGeneralizedLCA.cpp +++ b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEGeneralizedLCA/IDEGeneralizedLCA.cpp @@ -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 { // llvm::outs() << "##> normal lambdaFlow for: " << // llvmIRToString(curr) @@ -131,7 +131,8 @@ IDEGeneralizedLCA::getNormalFlowFunction(IDEGeneralizedLCA::n_t Curr, bool NoneConst = !LeftConst && !RightConst; return lambdaFlow( - [=](IDEGeneralizedLCA::d_t Source) -> std::set { + [this, Lhs, Rhs, BothConst, NoneConst, Curr]( + IDEGeneralizedLCA::d_t Source) -> std::set { if (Source == Lhs || Source == Rhs || ((BothConst || NoneConst) && isZeroValue(Source))) { return {Source, Curr}; diff --git a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEInstInteractionAnalysis.cpp b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEInstInteractionAnalysis.cpp index 2952fc354f..8cb3908fa0 100644 --- a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEInstInteractionAnalysis.cpp +++ b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEInstInteractionAnalysis.cpp @@ -35,7 +35,7 @@ IDEIIAFlowFact::IDEIIAFlowFact( } IDEIIAFlowFact IDEIIAFlowFact::create(const llvm::Value *BaseVal) { - if (const auto *Alloca = llvm::dyn_cast(BaseVal)) { + if (llvm::isa(BaseVal)) { return {BaseVal}; } if (const auto *Gep = llvm::dyn_cast(BaseVal)) { diff --git a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysis.cpp b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysis.cpp index 107694bd90..465239ef73 100644 --- a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysis.cpp +++ b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysis.cpp @@ -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(Agg)) { + if (llvm::isa(Agg)) { if (Extract->getType()->isIntegerTy()) { return generateFlow(Curr, Agg); } diff --git a/lib/PhasarLLVM/DataFlow/PathSensitivity/LLVMPathConstraints.cpp b/lib/PhasarLLVM/DataFlow/PathSensitivity/LLVMPathConstraints.cpp index 9ea5c94fcc..f1ef9ee1c3 100644 --- a/lib/PhasarLLVM/DataFlow/PathSensitivity/LLVMPathConstraints.cpp +++ b/lib/PhasarLLVM/DataFlow/PathSensitivity/LLVMPathConstraints.cpp @@ -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(GEP->getPointerOperandType())) { + if (llvm::isa(GEP->getPointerOperandType())) { auto PointerConst = Z3Ctx->bv_const(Name.c_str(), 64); return Z3Expr.try_emplace(GEP, ConstraintAndVariables{PointerConst, {GEP}}) .first->second; diff --git a/lib/PhasarLLVM/DataFlow/PathSensitivity/Z3BasedPathSensitivityManager.cpp b/lib/PhasarLLVM/DataFlow/PathSensitivity/Z3BasedPathSensitivityManager.cpp index 801a8e10f1..65c121163c 100644 --- a/lib/PhasarLLVM/DataFlow/PathSensitivity/Z3BasedPathSensitivityManager.cpp +++ b/lib/PhasarLLVM/DataFlow/PathSensitivity/Z3BasedPathSensitivityManager.cpp @@ -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); } @@ -55,7 +55,7 @@ z3::expr Z3BasedPathSensitivityManagerBase::filterOutUnreachableNodes( llvm::SmallVector 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++; @@ -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++; @@ -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(); @@ -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( diff --git a/lib/PhasarLLVM/Passes/GeneralStatisticsAnalysis.cpp b/lib/PhasarLLVM/Passes/GeneralStatisticsAnalysis.cpp index c18afd258b..991d9b5b5a 100644 --- a/lib/PhasarLLVM/Passes/GeneralStatisticsAnalysis.cpp +++ b/lib/PhasarLLVM/Passes/GeneralStatisticsAnalysis.cpp @@ -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(&I)) { + if (llvm::isa(&I)) { // do not add allocas from llvm internal functions Stats.AllocaInstructions.insert(&I); ++Stats.AllocationSites; diff --git a/lib/PhasarLLVM/Pointer/FilteredAliasesUtils.h b/lib/PhasarLLVM/Pointer/FilteredAliasesUtils.h index 79a6d4574d..47e64f7cae 100644 --- a/lib/PhasarLLVM/Pointer/FilteredAliasesUtils.h +++ b/lib/PhasarLLVM/Pointer/FilteredAliasesUtils.h @@ -57,7 +57,7 @@ inline LLVM_LIBRARY_VISIBILITY bool mustNoalias(const llvm::Value *P1, if (llvm::isa(P2) || isConstantGlobalValue(Glob1)) { return true; } - if (const auto *Glob2 = llvm::dyn_cast(P2)) { + if (llvm::isa(P2)) { return true; // approximation } } else if (const auto *Glob2 = llvm::dyn_cast(P2)) { diff --git a/lib/PhasarLLVM/Utils/Annotation.cpp b/lib/PhasarLLVM/Utils/Annotation.cpp index b97f2429a7..0883217d98 100644 --- a/lib/PhasarLLVM/Utils/Annotation.cpp +++ b/lib/PhasarLLVM/Utils/Annotation.cpp @@ -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"))); diff --git a/lib/Utils/PAMM.cpp b/lib/Utils/PAMM.cpp index b1ea931ac2..7d51f7defc 100644 --- a/lib/Utils/PAMM.cpp +++ b/lib/Utils/PAMM.cpp @@ -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) && @@ -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"); } @@ -214,7 +215,7 @@ PAMM::getSumCount(std::initializer_list 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"); } diff --git a/tools/example-tool/myphasartool.cpp b/tools/example-tool/myphasartool.cpp index 8080dabbe1..d8eccad7d1 100644 --- a/tools/example-tool/myphasartool.cpp +++ b/tools/example-tool/myphasartool.cpp @@ -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