1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef LIBARK_DEFECT_SCAN_AUX_INCLUDE_CALLEE_INFO_H 17 #define LIBARK_DEFECT_SCAN_AUX_INCLUDE_CALLEE_INFO_H 18 19 #include "graph.h" 20 21 namespace panda::defect_scan_aux { 22 class Class; 23 class Function; 24 25 class CalleeInfo final { 26 public: CalleeInfo(const Inst & call_inst,const Function * caller)27 CalleeInfo(const Inst &call_inst, const Function *caller) : call_inst_(call_inst), caller_(caller) {} 28 ~CalleeInfo() = default; 29 NO_COPY_SEMANTIC(CalleeInfo); 30 NO_MOVE_SEMANTIC(CalleeInfo); 31 32 bool IsCalleeDefinite() const; 33 int GetCalleeArgCount() const; 34 const Inst &GetCallInst() const; 35 const Function *GetCaller() const; 36 const Class *GetClass() const; 37 const Function *GetCallee() const; 38 const std::string &GetFunctionName() const; 39 const std::string &GetClassName() const; 40 const std::string &GetExternalModuleName() const; 41 const std::string &GetGlobalVarName() const; 42 43 private: 44 void SetCalleeArgCount(int arg_count); 45 void SetClass(const Class *clazz); 46 void SetCallee(const Function *func); 47 void SetFunctionName(std::string_view func_name); 48 void SetClassName(std::string_view class_name); 49 void SetExternalModuleName(std::string_view external_module_name); 50 void SetGlobalVarName(std::string_view global_var_name); 51 52 bool is_definite_ {false}; 53 // -1 means arg count of callee is unknown 54 int arg_count_ {-1}; 55 const Inst call_inst_; 56 const Function *caller_ {nullptr}; 57 const Class *class_ {nullptr}; 58 const Function *func_ {nullptr}; 59 std::string func_name_; 60 std::string class_name_; 61 std::string external_module_name_; 62 std::string global_var_name_; 63 64 friend class AbcFile; 65 }; 66 } // namespace panda::defect_scan_aux 67 #endif // LIBARK_DEFECT_SCAN_AUX_INCLUDE_CALLEE_INFO_H