retdec
Functions
retdec::bin2llvmir::llvm_utils Namespace Reference

Functions

llvm::Value * skipCasts (llvm::Value *val)
 
llvm::IntegerType * getCharType (llvm::LLVMContext &ctx)
 
llvm::PointerType * getCharPointerType (llvm::LLVMContext &ctx)
 
bool isCharType (const llvm::Type *t)
 
bool isCharPointerType (const llvm::Type *t)
 
bool isStringArrayType (const llvm::Type *t)
 
bool isStringArrayPointeType (const llvm::Type *t)
 
llvm::Type * stringToLlvmType (llvm::LLVMContext &ctx, const std::string &str)
 
llvm::Type * stringToLlvmTypeDefault (llvm::Module *m, const std::string &str)
 
std::vector< llvm::Type * > parseFormatString (llvm::Module *module, const std::string &format, llvm::Function *calledFnc=nullptr)
 
bool parseTypeList (LLVMContext &ctx, std::string list, std::vector< Type * > &typeList)
 
Type * stringToLlvmType (LLVMContext &ctx, const std::string &str)
 

Function Documentation

◆ getCharPointerType()

llvm::PointerType * retdec::bin2llvmir::llvm_utils::getCharPointerType ( llvm::LLVMContext &  ctx)

◆ getCharType()

llvm::IntegerType * retdec::bin2llvmir::llvm_utils::getCharType ( llvm::LLVMContext &  ctx)

◆ isCharPointerType()

bool retdec::bin2llvmir::llvm_utils::isCharPointerType ( const llvm::Type *  t)
Returns
True if t is the same as getCharPointerType() result, false otherwise.

◆ isCharType()

bool retdec::bin2llvmir::llvm_utils::isCharType ( const llvm::Type *  t)
Returns
True if t is the same as getCharType() result, false otherwise.

◆ isStringArrayPointeType()

bool retdec::bin2llvmir::llvm_utils::isStringArrayPointeType ( const llvm::Type *  t)
Returns
True if t is a pointer to string array type (see isStringArrayType), false otherwise.

◆ isStringArrayType()

bool retdec::bin2llvmir::llvm_utils::isStringArrayType ( const llvm::Type *  t)
Returns
True if t is a string array – an array of char elements, false otherwise.

◆ parseFormatString()

std::vector< llvm::Type * > retdec::bin2llvmir::llvm_utils::parseFormatString ( llvm::Module *  module,
const std::string &  format,
llvm::Function *  calledFnc 
)

Parse format string format used in functions such as printf or scanf into vector of data types in context of module module. If calledFnc provided and called function name contains "scan" string, all types are transformed to pointers.

Returns
Vector of data types used in format string.

This is done according to: http://www.cplusplus.com/reference/cstdio/printf/ but we need small updates, because it is used for scanf where are small differences in floating point numbers: http://www.cplusplus.com/reference/cstdio/scanf/

◆ parseTypeList()

bool retdec::bin2llvmir::llvm_utils::parseTypeList ( LLVMContext &  ctx,
std::string  list,
std::vector< Type * > &  typeList 
)

Parse string with list of LLVM types (i.e. "t1,..,tn") into vector of LLVM types.

Parameters
ctxContext in which the LLVM type is created.
listString list to parse.
[out]typeListOutput vector to fill.
Returns
False if parsing was successful, true otherwise.

◆ skipCasts()

llvm::Value * retdec::bin2llvmir::llvm_utils::skipCasts ( llvm::Value *  val)

Skips both casts and getelementptr instructions and constant expressions.

◆ stringToLlvmType() [1/2]

llvm::Type* retdec::bin2llvmir::llvm_utils::stringToLlvmType ( llvm::LLVMContext &  ctx,
const std::string &  str 
)

◆ stringToLlvmType() [2/2]

Type* retdec::bin2llvmir::llvm_utils::stringToLlvmType ( LLVMContext &  ctx,
const std::string &  str 
)

Convert the provided LLVM type string representation into an LLVM type.

Parameters
ctxContext in which the LLVM type is created.
strString with LLVM type representation.
Returns
LLVM type if the conversion was successful, nullptr otherwise.

◆ stringToLlvmTypeDefault()

llvm::Type * retdec::bin2llvmir::llvm_utils::stringToLlvmTypeDefault ( llvm::Module *  m,
const std::string &  str 
)

This is the same as stringToLlvmType(), but default type is returned instead of nulltpr.