| 10 | namespace ftg { |
| 11 | |
| 12 | template <typename T> class ArgPropAnalysisReport : public AnalyzerReport { |
| 13 | |
| 14 | public: |
| 15 | std::tuple<std::string, unsigned, std::vector<int>> |
| 16 | decomposeArgPropReportKey(std::string Key) const { |
| 17 | auto Result = |
| 18 | std::make_tuple<std::string, unsigned, std::vector<int>>("", 0, {}); |
| 19 | |
| 20 | try { |
| 21 | auto SIdx = Key.find("("); |
| 22 | auto EIdx = Key.find(")"); |
| 23 | if (SIdx == std::string::npos || EIdx == std::string::npos) |
| 24 | return Result; |
| 25 | if (EIdx <= SIdx + 1) |
| 26 | return Result; |
| 27 | |
| 28 | std::get<0>(Result) = Key.substr(0, SIdx); |
| 29 | std::get<1>(Result) = std::stol(Key.substr(SIdx + 1, EIdx)); |
| 30 | |
| 31 | SIdx = Key.rfind("["); |
| 32 | EIdx = Key.rfind("]"); |
| 33 | if (SIdx == std::string::npos || EIdx == std::string::npos) |
| 34 | return Result; |
| 35 | |
| 36 | std::vector<int> Indices; |
| 37 | unsigned BaseOffset = SIdx + 1; |
| 38 | for (unsigned S = SIdx + 1; S < EIdx; ++S) { |
| 39 | if (Key[S] != ',') |
| 40 | continue; |
| 41 | Indices.emplace_back(std::stoi(Key.substr(BaseOffset, S))); |
| 42 | BaseOffset = S + 1; |
| 43 | } |
| 44 | std::get<2>(Result) = Indices; |
| 45 | } catch (std::exception &E) { |
| 46 | } |
| 47 | return Result; |
| 48 | } |
| 49 | |
| 50 | void set(const llvm::Argument &Key, T Value, std::vector<int> Indices = {}) { |
| 51 | auto RealKey = getAsKey(Key, Indices); |
| 52 | Result.emplace(RealKey, Value); |
| 53 | } |
| 54 | |
| 55 | void set(std::string FuncName, unsigned ArgIdx, T Value, |
| 56 | std::vector<int> Indices = {}) { |
| 57 | Result.emplace(getAsKey(FuncName, ArgIdx, Indices), Value); |
| 58 | } |
| 59 | |
| 60 | void set(std::string Key, T Value) { Result.emplace(Key, Value); } |
| 61 | |
| 62 | void set(const std::map<std::string, T> &Map) { Result = Map; } |
| 63 | |
| 64 | bool has(const llvm::Argument &Key, std::vector<int> Indices = {}) const { |
| 65 | auto RealKey = getAsKey(Key, Indices); |
| 66 | return Result.find(RealKey) != Result.end(); |
| 67 | } |
| 68 | |
| 69 | bool has(std::string FuncName, unsigned ArgIdx, |
nothing calls this directly
no outgoing calls
no test coverage detected