MCPcopy Create free account
hub / github.com/Samsung/UTopia / analyzeUTDef

Method analyzeUTDef

lib/inputanalysis/DefAnalyzer.cpp:107–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107std::vector<DefAnalyzer::FuncDef>
108DefAnalyzer::analyzeUTDef(Unittest &UnitTest) {
109 assert(Finder && Analyzer && "Unexpected Program State");
110
111 std::vector<DefAnalyzer::FuncDef> Result;
112
113 auto Links = UnitTest.getLinks();
114 if (Links.size() == 0)
115 return Result;
116
117 Analyzer->setSearchSpace(Links);
118 auto FoundCalls = Finder->findAPICallers(Links);
119 std::vector<llvm::CallBase *> APICalls(FoundCalls.begin(), FoundCalls.end());
120
121 // APICalls filtering
122 APICalls.erase(std::remove_if(APICalls.begin(), APICalls.end(),
123 [](const llvm::CallBase *CB) {
124 // 1. When it points null.
125 if (!CB)
126 return true;
127
128 // 2. When it does not have debug location
129 // information.
130 return !CB->getDebugLoc();
131 }),
132 APICalls.end());
133
134 std::sort(APICalls.begin(), APICalls.end(), [](auto *Src1, auto *Src2) {
135 assert(Src1 && Src2 && "Unexpected Program State");
136 return IRNode(*Src1) < IRNode(*Src2);
137 });
138
139 for (unsigned S = 0, E = APICalls.size(); S < E; ++S) {
140 auto *APICall = APICalls[S];
141 assert(APICall && "Unexpected Program State");
142
143 llvm::outs() << "[I] Analyze APICall (" << S + 1 << " / " << E << ")\n";
144 Result.push_back(analyzeTargetCall(*APICall));
145 }
146
147 return Result;
148}
149
150DefAnalyzer::FuncDef DefAnalyzer::analyzeTargetCall(llvm::CallBase &CB) {
151 DefAnalyzer::FuncDef Result(CB);

Callers

nothing calls this directly

Calls 7

IRNodeClass · 0.85
getLinksMethod · 0.80
sizeMethod · 0.80
setSearchSpaceMethod · 0.80
findAPICallersMethod · 0.80
beginMethod · 0.80
endMethod · 0.80

Tested by

no test coverage detected