| 35 | } |
| 36 | |
| 37 | bool TargetLibAnalyzer::analyze() { |
| 38 | if (!SL || !AL) |
| 39 | return false; |
| 40 | |
| 41 | AC = AL->load(); |
| 42 | SC = SL->load(); |
| 43 | if (!SC) |
| 44 | return false; |
| 45 | |
| 46 | auto &M = *const_cast<llvm::Module *>(&SC->getLLVMModule()); |
| 47 | std::vector<clang::ASTUnit *> ASTUnits; |
| 48 | for (auto *ASTUnit : SC->getASTUnits()) { |
| 49 | assert(ASTUnit && "Unexpected Program State"); |
| 50 | ASTUnits.push_back(ASTUnit); |
| 51 | } |
| 52 | |
| 53 | AnalyzedTargetLib = std::make_unique<TargetLib>(AC); |
| 54 | if (!AnalyzedTargetLib) |
| 55 | return false; |
| 56 | |
| 57 | prepareLLVMAnalysis(M); |
| 58 | |
| 59 | auto Funcs = collectAnalyzableIRFunctions(); |
| 60 | Analyzers.emplace_back( |
| 61 | std::make_unique<AllocSizeAnalyzer>(&Solver, Funcs, &AllocSizeReport)); |
| 62 | Analyzers.emplace_back( |
| 63 | std::make_unique<ArrayAnalyzer>(&Solver, Funcs, FAM, &ArrayReport)); |
| 64 | Analyzers.emplace_back(std::make_unique<ConstAnalyzer>(ASTUnits)); |
| 65 | Analyzers.emplace_back( |
| 66 | std::make_unique<DirectionAnalyzer>(&Solver, Funcs, &DirectionReport)); |
| 67 | Analyzers.emplace_back( |
| 68 | std::make_unique<FilePathAnalyzer>(&Solver, Funcs, &FilePathReport)); |
| 69 | Analyzers.emplace_back( |
| 70 | std::make_unique<LoopAnalyzer>(&Solver, Funcs, FAM, &LoopReport)); |
| 71 | Analyzers.emplace_back( |
| 72 | std::make_unique<ParamNumberAnalyzer>(ASTUnits, M, AC)); |
| 73 | Analyzers.emplace_back(std::make_unique<TypeAnalyzer>(ASTUnits)); |
| 74 | |
| 75 | for (auto &Analyzer : Analyzers) { |
| 76 | if (!Analyzer) |
| 77 | continue; |
| 78 | |
| 79 | Reports.emplace_back(Analyzer->getReport()); |
| 80 | } |
| 81 | return true; |
| 82 | } |
| 83 | |
| 84 | bool TargetLibAnalyzer::dump(std::string OutputFilePath) const { |
| 85 | if (!AnalyzedTargetLib) |
nothing calls this directly
no test coverage detected