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

Method ParamNumberAnalyzer

lib/analysis/ParamNumberAnalyzer.cpp:9–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7namespace ftg {
8
9ParamNumberAnalyzer::ParamNumberAnalyzer(
10 const std::vector<clang::ASTUnit *> &ASTUnits, const llvm::Module &M,
11 std::set<std::string> FuncNames) {
12 std::map<std::string, const llvm::Constant *> GlobalAliasMap;
13 for (const auto &A : M.aliases())
14 GlobalAliasMap.emplace(A.getName().str(), A.getAliasee());
15
16 for (auto *ASTUnit : ASTUnits) {
17 for (auto *FD :
18 util::findDefinedFunctionDecls(ASTUnit->getASTContext(), FuncNames)) {
19 if (!FD)
20 continue;
21
22 // NOTE: Unexpected when multiple functions are matched by one clang
23 // NamedDecl.
24 const llvm::Function *F = nullptr;
25 for (auto &MangledName : util::getMangledNames(*FD)) {
26 auto FuncName = MangledName;
27 auto Iter = GlobalAliasMap.find(MangledName);
28 if (Iter != GlobalAliasMap.end() && Iter->second)
29 FuncName = Iter->second->getName();
30 F = M.getFunction(FuncName);
31 if (F)
32 break;
33 }
34 if (!F)
35 continue;
36
37 unsigned BeginIndex = 0;
38 if (F->hasStructRetAttr())
39 BeginIndex += 1;
40
41 if (llvm::isa<clang::CXXMethodDecl>(FD) && !FD->isStatic())
42 BeginIndex += 1;
43
44 Report.add(F->getName().str(), F->arg_size(), BeginIndex);
45 }
46 }
47}
48
49std::unique_ptr<AnalyzerReport> ParamNumberAnalyzer::getReport() {
50 return std::make_unique<ParamNumberAnalysisReport>(Report);

Callers

nothing calls this directly

Calls 7

findDefinedFunctionDeclsFunction · 0.85
getMangledNamesFunction · 0.85
endMethod · 0.80
getFunctionMethod · 0.80
getNameMethod · 0.45
findMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected