From 57fa8b2c5af80343dc857dd9fd873a2ebfeb69ff Mon Sep 17 00:00:00 2001 From: jumormt Date: Wed, 6 Mar 2024 16:27:20 +1100 Subject: [PATCH] fix some non-ret and unused var warning --- svf-llvm/lib/LLVMUtil.cpp | 3 +-- svf-llvm/lib/SVFIRBuilder.cpp | 2 +- svf-llvm/tools/AE/ae.cpp | 3 +-- svf/include/Graphs/WTO.h | 1 + svf/lib/AE/Svfexe/AbstractExecution.cpp | 1 + svf/lib/AE/Svfexe/BufOverflowChecker.cpp | 1 + svf/lib/AE/Svfexe/ICFGSimplification.cpp | 3 +-- svf/lib/AE/Svfexe/SVFIR2ItvExeState.cpp | 1 + svf/lib/MemoryModel/AccessPath.cpp | 11 +++++------ 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/svf-llvm/lib/LLVMUtil.cpp b/svf-llvm/lib/LLVMUtil.cpp index 72a1be48a..930c2a1c2 100644 --- a/svf-llvm/lib/LLVMUtil.cpp +++ b/svf-llvm/lib/LLVMUtil.cpp @@ -363,8 +363,7 @@ void LLVMUtil::getPrevInsts(const Instruction* curInst, std::vector(val->getType()); - assert(type && "this value should be a pointer type!"); + assert(SVFUtil::isa(val->getType()) && "this value should be a pointer type!"); /// If type is void* (i8*) and val is immediately used at a bitcast instruction const Value *latestUse = nullptr; for (const auto &it : val->uses()) diff --git a/svf-llvm/lib/SVFIRBuilder.cpp b/svf-llvm/lib/SVFIRBuilder.cpp index df97916d3..0f1341cf0 100644 --- a/svf-llvm/lib/SVFIRBuilder.cpp +++ b/svf-llvm/lib/SVFIRBuilder.cpp @@ -290,7 +290,7 @@ bool SVFIRBuilder::computeGepOffset(const User *V, AccessPath& ap) assert((prevPtrOperand && svfGepTy->isPointerTy()) == false && "Expect no more than one gep operand to be of a pointer type"); - if(svfGepTy->isPointerTy()) prevPtrOperand = true; + if(!prevPtrOperand && svfGepTy->isPointerTy()) prevPtrOperand = true; const Value* offsetVal = gi.getOperand(); const SVFValue* offsetSvfVal = LLVMModuleSet::getLLVMModuleSet()->getSVFValue(offsetVal); assert(gepTy != offsetVal->getType() && "iteration and operand have the same type?"); diff --git a/svf-llvm/tools/AE/ae.cpp b/svf-llvm/tools/AE/ae.cpp index bb9465c71..cf4c8dcd5 100644 --- a/svf-llvm/tools/AE/ae.cpp +++ b/svf-llvm/tools/AE/ae.cpp @@ -631,11 +631,10 @@ int main(int argc, char** argv) arg_value[arg_num] = argv[arg_num]; } // add extra options - int orgArgNum = arg_num; arg_value[arg_num++] = (char*) "-model-consts=true"; arg_value[arg_num++] = (char*) "-model-arrays=true"; arg_value[arg_num++] = (char*) "-pre-field-sensitive=false"; - assert(arg_num == (orgArgNum + extraArgc) && "more extra arguments? Change the value of extraArgc"); + assert(arg_num == (argc + extraArgc) && "more extra arguments? Change the value of extraArgc"); std::vector moduleNameVec; moduleNameVec = OptionBase::parseOptions( diff --git a/svf/include/Graphs/WTO.h b/svf/include/Graphs/WTO.h index 29e9f0e64..846fac07f 100644 --- a/svf/include/Graphs/WTO.h +++ b/svf/include/Graphs/WTO.h @@ -36,6 +36,7 @@ #include "SVFIR/SVFType.h" #include "SVFIR/SVFValue.h" +#include namespace SVF { diff --git a/svf/lib/AE/Svfexe/AbstractExecution.cpp b/svf/lib/AE/Svfexe/AbstractExecution.cpp index e5ebdfddb..f0f1c4fcf 100644 --- a/svf/lib/AE/Svfexe/AbstractExecution.cpp +++ b/svf/lib/AE/Svfexe/AbstractExecution.cpp @@ -1383,6 +1383,7 @@ u32_t AEAPI::getAllocaInstByteSize(const AddrStmt *addr) } } assert (false && "Addr rhs value is not ObjVar"); + abort(); } IntervalValue AEAPI::traceMemoryAllocationSize(const SVFValue *value) diff --git a/svf/lib/AE/Svfexe/BufOverflowChecker.cpp b/svf/lib/AE/Svfexe/BufOverflowChecker.cpp index f4e9ee1d2..c08bd688e 100644 --- a/svf/lib/AE/Svfexe/BufOverflowChecker.cpp +++ b/svf/lib/AE/Svfexe/BufOverflowChecker.cpp @@ -414,6 +414,7 @@ bool BufOverflowCheckerAPI::detectStrcat(const CallICFGNode *call) else { assert(false && "unknown strcat function, please add it to strcatGroup or strncatGroup"); + abort(); } } diff --git a/svf/lib/AE/Svfexe/ICFGSimplification.cpp b/svf/lib/AE/Svfexe/ICFGSimplification.cpp index 87361c01b..253cf8d78 100644 --- a/svf/lib/AE/Svfexe/ICFGSimplification.cpp +++ b/svf/lib/AE/Svfexe/ICFGSimplification.cpp @@ -126,8 +126,7 @@ void ICFGSimplification::mergeAdjacentNodes(ICFG* icfg) // merge the following nodes, until the next subnode while (subNodes.find(next) == subNodes.end()) { - ICFGNode* rep_next = const_cast(icfg->getRepNode(next)); - assert(rep_next != head && "should not find a circle here"); + assert(icfg->getRepNode(next) != head && "should not find a circle here"); icfg->removeICFGEdge(*head->getOutEdges().begin()); std::vector rm_edges; // Step 1: merge the out edges of next to head diff --git a/svf/lib/AE/Svfexe/SVFIR2ItvExeState.cpp b/svf/lib/AE/Svfexe/SVFIR2ItvExeState.cpp index 43e15f838..ee85266b3 100644 --- a/svf/lib/AE/Svfexe/SVFIR2ItvExeState.cpp +++ b/svf/lib/AE/Svfexe/SVFIR2ItvExeState.cpp @@ -105,6 +105,7 @@ IntervalValue SVFIR2ItvExeState::getRangeLimitFromType(const SVFType* type) else { assert(false && "cannot support"); + abort(); } } diff --git a/svf/lib/MemoryModel/AccessPath.cpp b/svf/lib/MemoryModel/AccessPath.cpp index b295cd044..af4f87686 100644 --- a/svf/lib/MemoryModel/AccessPath.cpp +++ b/svf/lib/MemoryModel/AccessPath.cpp @@ -165,17 +165,16 @@ u32_t AccessPath::getStructFieldOffset(const SVFVar* idxOperandVar, const SVFStr { const SVFValue* idxValue = idxOperandVar->getValue(); u32_t structByteOffset = 0; - if (const SVFConstantInt *op = SVFUtil::dyn_cast(idxValue)) - { - for (u32_t structField = 0; structField < (u32_t)op->getSExtValue(); ++structField) - { + if (const SVFConstantInt *op = SVFUtil::dyn_cast(idxValue)) { + for (u32_t structField = 0; structField < (u32_t) op->getSExtValue(); ++structField) { u32_t flattenIdx = idxOperandType->getTypeInfo()->getFlattenedFieldIdxVec()[structField]; structByteOffset += idxOperandType->getTypeInfo()->getOriginalElemType(flattenIdx)->getByteSize(); } return structByteOffset; - } - else + } else { assert(false && "struct type can only pair with constant idx"); + abort(); + } } /// Return accumulated constant offset