Skip to content

Commit

Permalink
SVF code formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
yuleisui committed Jan 25, 2024
1 parent 6bf9865 commit 7a5a0ba
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 102 deletions.
12 changes: 8 additions & 4 deletions svf-llvm/include/SVF-LLVM/ObjTypeInference.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
#include "SVFIR/SVFValue.h"
#include "Util/ThreadAPI.h"

namespace SVF {
class ObjTypeInference {
namespace SVF
{
class ObjTypeInference
{

public:
typedef Set<const Value *> ValueSet;
Expand Down Expand Up @@ -72,12 +74,14 @@ class ObjTypeInference {
const Type *defaultType(const Value *val);

/// Pointer type
inline const Type *ptrType() {
inline const Type *ptrType()
{
return PointerType::getUnqual(getLLVMCtx());
}

/// Int8 type
inline const IntegerType *int8Type() {
inline const IntegerType *int8Type()
{
return Type::getInt8Ty(getLLVMCtx());
}

Expand Down
8 changes: 5 additions & 3 deletions svf-llvm/lib/CppUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,11 @@ std::string cppUtil::getClassNameOfThisPtr(const CallBase* inst)
if (thisPtrClassName.size() == 0)
{
const Value* thisPtr = getVCallThisPtr(inst);
if (const PointerType *ptrTy = SVFUtil::dyn_cast<PointerType>(thisPtr->getType())) {
if (const PointerType *ptrTy = SVFUtil::dyn_cast<PointerType>(thisPtr->getType()))
{
// TODO: getPtrElementType need type inference
if (const StructType *st = SVFUtil::dyn_cast<StructType>(LLVMUtil::getPtrElementType(ptrTy))) {
if (const StructType *st = SVFUtil::dyn_cast<StructType>(LLVMUtil::getPtrElementType(ptrTy)))
{
thisPtrClassName = getClassNameFromType(st);
}
}
Expand All @@ -527,7 +529,7 @@ std::string cppUtil::getClassNameOfThisPtr(const CallBase* inst)
if (found != std::string::npos)
{
if (found != thisPtrClassName.size() - 1 &&
thisPtrClassName[found] == '.')
thisPtrClassName[found] == '.')
{
return thisPtrClassName.substr(0, found);
}
Expand Down
6 changes: 4 additions & 2 deletions svf-llvm/lib/LLVMModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,14 @@ LLVMModuleSet::LLVMModuleSet()
{
}

LLVMModuleSet::~LLVMModuleSet() {
LLVMModuleSet::~LLVMModuleSet()
{
delete typeInference;
typeInference = nullptr;
}

ObjTypeInference* LLVMModuleSet::getTypeInference() {
ObjTypeInference* LLVMModuleSet::getTypeInference()
{
return typeInference;
}

Expand Down
3 changes: 2 additions & 1 deletion svf-llvm/lib/LLVMUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,8 @@ std::string LLVMUtil::dumpType(const Type* type)
return rawstr.str();
}

std::string LLVMUtil::dumpValueAndDbgInfo(const Value *val) {
std::string LLVMUtil::dumpValueAndDbgInfo(const Value *val)
{
std::string str;
llvm::raw_string_ostream rawstr(str);
if (val)
Expand Down
Loading

0 comments on commit 7a5a0ba

Please sign in to comment.