Skip to content

Commit

Permalink
the type of the cpp class is treated as PointerType
Browse files Browse the repository at this point in the history
yuleisui committed Dec 20, 2023
1 parent b229528 commit f55414b
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions svf-llvm/lib/SymbolTableBuilder.cpp
Original file line number Diff line number Diff line change
@@ -759,15 +759,18 @@ u32_t SymbolTableBuilder::analyzeHeapObjType(ObjTypeInfo* typeinfo, const Value*
{
typeinfo->setFlag(ObjTypeInfo::HEAP_OBJ);
const Type* objTy = getTypeOfHeapAlloc(SVFUtil::cast<Instruction>(val));
typeinfo->resetTypeForHeapStaticObj(LLVMModuleSet::getLLVMModuleSet()->getSVFType(castUse->getType()));
typeinfo->resetTypeForHeapStaticObj(LLVMModuleSet::getLLVMModuleSet()->getSVFType(objTy));
analyzeObjType(typeinfo,castUse);
if(SVFUtil::isa<ArrayType>(objTy))
return getNumOfElements(objTy);
else if(const StructType* st = SVFUtil::dyn_cast<StructType>(objTy))
{
/// For an C++ class, it can have variant elements depending on the vtable size, hence we only handle non-cpp-class object
/// For an C++ class, it can have variant elements depending on the vtable size,
/// Hence we only handle non-cpp-class object, the type of the cpp class is treated as PointerType at the cast site
if(getClassNameFromType(st).empty())
return getNumOfElements(objTy);
else
typeinfo->resetTypeForHeapStaticObj(LLVMModuleSet::getLLVMModuleSet()->getSVFType(castUse->getType()));
}
}
else
@@ -786,8 +789,7 @@ void SymbolTableBuilder::analyzeStaticObjType(ObjTypeInfo* typeinfo, const Value
if(const Value* castUse = getUniqueUseViaCastInst(val))
{
typeinfo->setFlag(ObjTypeInfo::STATIC_OBJ);
typeinfo->resetTypeForHeapStaticObj(
LLVMModuleSet::getLLVMModuleSet()->getSVFType(castUse->getType()));
typeinfo->resetTypeForHeapStaticObj(LLVMModuleSet::getLLVMModuleSet()->getSVFType(castUse->getType()));
analyzeObjType(typeinfo,castUse);
}
else
2 changes: 1 addition & 1 deletion svf/lib/SVFIR/SymbolTableInfo.cpp
Original file line number Diff line number Diff line change
@@ -373,7 +373,7 @@ bool ObjTypeInfo::isNonPtrFieldObj(const APOffset& apOffset)
if (hasPtrObj() == false)
return true;

const SVFType* ety = getType();
const SVFType* ety = type;

if (SVFUtil::isa<SVFStructType, SVFArrayType>(ety))
{

0 comments on commit f55414b

Please sign in to comment.