MCPcopy Create free account
hub / github.com/EmbeddedRPC/erpc / isNeedCallFree

Method isNeedCallFree

erpcgen/src/CGenerator.cpp:3027–3081  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3025}
3026
3027bool CGenerator::isNeedCallFree(DataType *dataType)
3028{
3029 DataType *trueDataType = dataType->getTrueDataType();
3030 switch (trueDataType->getDataType())
3031 {
3032 case DataType::data_type_t::kArrayType:
3033 {
3034 ArrayType *arrayType = dynamic_cast<ArrayType *>(trueDataType);
3035 assert(arrayType);
3036 return isNeedCallFree(arrayType->getElementType());
3037 }
3038 case DataType::data_type_t::kBuiltinType:
3039 {
3040 BuiltinType *builtinType = dynamic_cast<BuiltinType *>(trueDataType);
3041 assert(builtinType);
3042 return builtinType->isString() || builtinType->isBinary();
3043 }
3044 case DataType::data_type_t::kListType:
3045 {
3046 return true;
3047 }
3048 case DataType::data_type_t::kStructType:
3049 {
3050 StructType *structType = dynamic_cast<StructType *>(trueDataType);
3051 assert(structType);
3052 set<DataType *> loopDetection;
3053 return structType->containListMember() || structType->containStringMember() ||
3054 containsByrefParamToFree(structType, loopDetection);
3055 }
3056 case DataType::data_type_t::kUnionType:
3057 {
3058 UnionType *unionType = dynamic_cast<UnionType *>(trueDataType);
3059 assert(unionType);
3060 for (auto unionCase : unionType->getCases())
3061 {
3062 if (!unionCase->caseMemberIsVoid())
3063 {
3064 for (auto caseMemberName : unionCase->getMemberDeclarationNames())
3065 {
3066 StructMember *memberDeclaration = unionCase->getUnionMemberDeclaration(caseMemberName);
3067 if (isNeedCallFree(memberDeclaration->getDataType()))
3068 {
3069 return true;
3070 }
3071 }
3072 }
3073 }
3074 return false;
3075 }
3076 default:
3077 {
3078 return false;
3079 }
3080 }
3081}
3082
3083void CGenerator::setCallingFreeFunctions(Symbol *symbol, data_map &info, bool returnType)
3084{

Callers

nothing calls this directly

Calls 10

getTrueDataTypeMethod · 0.80
containListMemberMethod · 0.80
containStringMemberMethod · 0.80
caseMemberIsVoidMethod · 0.80
getDataTypeMethod · 0.45
getElementTypeMethod · 0.45
isStringMethod · 0.45
isBinaryMethod · 0.45

Tested by

no test coverage detected