From 950f9c8024eea7ae3dcf1322b75099690ed75439 Mon Sep 17 00:00:00 2001 From: "jiawei.wang" Date: Mon, 28 Aug 2023 21:27:56 +1000 Subject: [PATCH] fix accumulateOffset --- svf/lib/MemoryModel/AccessPath.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/svf/lib/MemoryModel/AccessPath.cpp b/svf/lib/MemoryModel/AccessPath.cpp index 784955b5d..216a85b4a 100644 --- a/svf/lib/MemoryModel/AccessPath.cpp +++ b/svf/lib/MemoryModel/AccessPath.cpp @@ -141,8 +141,15 @@ APOffset AccessPath::computeConstantOffset() const else { APOffset offset = op->getSExtValue(); - u32_t flattenOffset = SymbolTableInfo::SymbolInfo()->getFlattenedElemIdx(type, offset); - totalConstOffset += flattenOffset; + if (offset >= 0) + { + u32_t flattenOffset = + SymbolTableInfo::SymbolInfo()->getFlattenedElemIdx(type, + offset); + totalConstOffset += flattenOffset; + } + else + totalConstOffset += offset; } } return totalConstOffset;