MCPcopy Create free account
hub / github.com/csmith-project/csmith / make_builtin_function

Method make_builtin_function

src/Function.cpp:741–780  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

739}
740
741void
742Function::make_builtin_function(const string &function_string)
743{
744 vector<string> v;
745 StringUtils::split_string(function_string, v, ";");
746 if (v.size() == 4) {
747 if (!CGOptions::enabled_builtin(v[3]))
748 return;
749 }
750 else if (v.size() == 3) {
751 if (!CGOptions::enabled_builtin("generic"))
752 return;
753 }
754 else {
755 assert(0 && "Invalid builtin function format!");
756 }
757
758 const Type *ty = Type::get_type_from_string(v[0]);
759 Function *f = new Function(v[1], ty, /*is_builtin*/true);
760
761 // dummy variable representing return variable, we don't care about the type, so use 0
762 string rvname = f->name + "_" + "rv";
763 CVQualifiers ret_qfer = CVQualifiers::random_qualifiers(ty);
764 f->rv = Variable::CreateVariable(rvname, ty, NULL, &ret_qfer);
765
766 // create a fact manager for this function, with empty global facts
767 FactMgr* fm = new FactMgr(f);
768 FMList.push_back(fm);
769
770 GenerateParameterListFromString(*f, StringUtils::get_substring(v[2], '(', ')'));
771 f->GenerateBody(CGContext::get_empty_context());
772
773 // update global facts to merged facts at all possible function exits
774 fm->global_facts = fm->map_facts_out[f->body];
775 f->body->add_back_return_facts(fm, fm->global_facts);
776
777 // collect info about global dangling pointers
778 fm->find_dangling_global_ptrs(f);
779 ++builtin_functions_cnt;
780}
781
782void
783Function::compute_summary(void)

Callers

nothing calls this directly

Calls 5

sizeMethod · 0.80
GenerateBodyMethod · 0.80
add_back_return_factsMethod · 0.80

Tested by

no test coverage detected