There are three types of functions(definitions) in extapi.c: 1. (Fun_Overwrite): Functions with "OVERWRITE" annotion: These functions are used to replace the corresponding function definitions in the application. 2. (Fun_Annotation): Functions with annotation(s) but without "OVERWRITE" annotation: These functions are used to tell SVF to do special processing, like malloc().
| 674 | 4. appFunDef --> Fun_Annotation: Replace the appFunDef with appFunDecl and move the annotions to appFunDecl in application |
| 675 | */ |
| 676 | void LLVMModuleSet::buildFunToFunMap() |
| 677 | { |
| 678 | Set<const Function*> appFunDecls, appFunDefs, extFuncs, clonedFuncs; |
| 679 | OrderedSet<string> appFuncDeclNames, appFuncDefNames, extFunDefNames, intersectNames; |
| 680 | Map<const Function*, const Function*> extFuncs2ClonedFuncs; |
| 681 | Module* appModule = nullptr; |
| 682 | Module* extModule = nullptr; |
| 683 | |
| 684 | for (Module& mod : modules) |
| 685 | { |
| 686 | // extapi.bc functions |
| 687 | if (mod.getName().str() == ExtAPI::getExtAPI()->getExtBcPath()) |
| 688 | { |
| 689 | collectExtFunAnnotations(&mod); |
| 690 | extModule = &mod; |
| 691 | for (const Function& fun : mod.functions()) |
| 692 | { |
| 693 | // there is main declaration in ext bc, it should be mapped to |
| 694 | // main definition in app bc. |
| 695 | if (fun.getName().str() == "main") |
| 696 | { |
| 697 | appFunDecls.insert(&fun); |
| 698 | appFuncDeclNames.insert(fun.getName().str()); |
| 699 | } |
| 700 | /// Keep svf_main() function and all the functions called in svf_main() |
| 701 | else if (fun.getName().str() == "svf__main") |
| 702 | { |
| 703 | ExtFuncsVec.push_back(&fun); |
| 704 | } |
| 705 | else |
| 706 | { |
| 707 | extFuncs.insert(&fun); |
| 708 | extFunDefNames.insert(fun.getName().str()); |
| 709 | } |
| 710 | } |
| 711 | } |
| 712 | else |
| 713 | { |
| 714 | appModule = &mod; |
| 715 | /// app functions |
| 716 | for (const Function& fun : mod.functions()) |
| 717 | { |
| 718 | if (fun.isDeclaration()) |
| 719 | { |
| 720 | appFunDecls.insert(&fun); |
| 721 | appFuncDeclNames.insert(fun.getName().str()); |
| 722 | } |
| 723 | else |
| 724 | { |
| 725 | appFunDefs.insert(&fun); |
| 726 | appFuncDefNames.insert(fun.getName().str()); |
| 727 | } |
| 728 | } |
| 729 | } |
| 730 | } |
| 731 | |
| 732 | // Find the intersectNames between appFuncDefNames and externalFunDefNames |
| 733 | std::set_intersection( |
nothing calls this directly
no test coverage detected