Skip to content

Commit

Permalink
Integrated comments on initial pull request SVF-tools#1376; fixed C++…
Browse files Browse the repository at this point in the history
… copy-elision; fixed non-specific return types
  • Loading branch information
Johanmyst committed Feb 16, 2024
1 parent 78cb220 commit cb22e19
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 19 deletions.
2 changes: 0 additions & 2 deletions svf-llvm/include/SVF-LLVM/CppUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ std::string extractClsNameFromDynCast(const CallBase* callBase);

const Type *cppClsNameToType(const std::string &className);

std::string typeToClsName(const Type *ty);


/// Constants pertaining to CTir, for C and C++.
/// TODO: move helper functions here too?
Expand Down
5 changes: 3 additions & 2 deletions svf-llvm/include/SVF-LLVM/ObjTypeInference.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ObjTypeInference
typedef Map<const Value *, const Type *> ValueToType;
typedef std::pair<const Value *, bool> ValueBoolPair;
typedef Map<const Value *, Set<std::string>> ValueToClassNames;
typedef Map<const Value *, Set<const Value *>> ObjToClsNameSources;
typedef Map<const Value *, Set<const CallBase *>> ObjToClsNameSources;


private:
Expand Down Expand Up @@ -122,7 +122,8 @@ class ObjTypeInference
Set<const Value *> &bwFindAllocOrClsNameSources(const Value *startValue);

/// forward find class name sources starting from an allocation
Set<const Value *> &fwFindClsNameSources(const Value *startValue);
Set<const CallBase *> &fwFindClsNameSources(const Value *startValue);
};

}
#endif //SVF_OBJTYPEINFERENCE_H
12 changes: 0 additions & 12 deletions svf-llvm/lib/CppUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -883,15 +883,3 @@ const Type *cppUtil::cppClsNameToType(const std::string &className)
clsName + className);
return classTy ? classTy : LLVMModuleSet::getLLVMModuleSet()->getTypeInference()->ptrType();
}

std::string cppUtil::typeToClsName(const Type *ty)
{
if (const auto *stTy = SVFUtil::dyn_cast<StructType>(ty))
{
const std::string &typeName = stTy->getName().str();
const std::string &className = typeName.substr(
clsName.size(), typeName.size() - clsName.size());
return className;
}
return "";
}
6 changes: 3 additions & 3 deletions svf-llvm/lib/ObjTypeInference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ Set<std::string> &ObjTypeInference::inferThisPtrClsName(const Value *thisPtr)
auto addNamesFromFunc = [&names](const Function *func) -> void
{
ABORT_IFNOT(isClsNameSource(func), "Func is invalid class name source: " + dumpValueAndDbgInfo(func));
for (auto name : extractClsNamesFromFunc(func)) names.insert(name);
for (const auto &name : extractClsNamesFromFunc(func)) names.insert(name);
};

// Lambda for getting callee & extracting class name for calls to constructors/destructors/template funcs
Expand Down Expand Up @@ -806,7 +806,7 @@ Set<const Value *> &ObjTypeInference::bwFindAllocOrClsNameSources(const Value *s
return _valueToAllocOrClsNameSources[startValue];
}

Set<const Value *> &ObjTypeInference::fwFindClsNameSources(const Value *startValue)
Set<const CallBase *> &ObjTypeInference::fwFindClsNameSources(const Value *startValue)
{
assert(startValue && "startValue was null?");

Expand All @@ -817,7 +817,7 @@ Set<const Value *> &ObjTypeInference::fwFindClsNameSources(const Value *startVal
return tIt->second;
}

Set<const Value *> sources;
Set<const CallBase *> sources;

// Lambda for adding a callee to the sources iff it is a constructor/destructor/template/dyncast
auto inferViaCppCall = [&sources](const CallBase *caller)
Expand Down

0 comments on commit cb22e19

Please sign in to comment.