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 #include "callee_info.h" 17 #include "function.h" 18 #include "class.h" 19 20 namespace panda::defect_scan_aux { IsCalleeDefinite() const21bool CalleeInfo::IsCalleeDefinite() const 22 { 23 return is_definite_; 24 } 25 GetCalleeArgCount() const26int CalleeInfo::GetCalleeArgCount() const 27 { 28 return arg_count_; 29 } 30 GetCallInst() const31const Inst &CalleeInfo::GetCallInst() const 32 { 33 return call_inst_; 34 } 35 GetCaller() const36const Function *CalleeInfo::GetCaller() const 37 { 38 return caller_; 39 } 40 GetClass() const41const Class *CalleeInfo::GetClass() const 42 { 43 return class_; 44 } 45 GetCallee() const46const Function *CalleeInfo::GetCallee() const 47 { 48 return func_; 49 } 50 GetFunctionName() const51const std::string &CalleeInfo::GetFunctionName() const 52 { 53 return func_name_; 54 } 55 GetClassName() const56const std::string &CalleeInfo::GetClassName() const 57 { 58 return class_name_; 59 } 60 GetExternalModuleName() const61const std::string &CalleeInfo::GetExternalModuleName() const 62 { 63 return external_module_name_; 64 } 65 GetGlobalVarName() const66const std::string &CalleeInfo::GetGlobalVarName() const 67 { 68 return global_var_name_; 69 } 70 SetCalleeArgCount(int arg_count)71void CalleeInfo::SetCalleeArgCount(int arg_count) 72 { 73 arg_count_ = arg_count; 74 } 75 SetClass(const Class *clazz)76void CalleeInfo::SetClass(const Class *clazz) 77 { 78 class_ = clazz; 79 } 80 SetCallee(const Function *func)81void CalleeInfo::SetCallee(const Function *func) 82 { 83 ASSERT(func != nullptr); 84 func_ = func; 85 is_definite_ = true; 86 SetCalleeArgCount(static_cast<int>(func->GetArgCount())); 87 SetFunctionName(func->GetFunctionName()); 88 SetClass(func->GetClass()); 89 if (class_ != nullptr) { 90 SetClassName(func->GetRecordName() + class_->GetClassName()); 91 } 92 } 93 SetFunctionName(std::string_view func_name)94void CalleeInfo::SetFunctionName(std::string_view func_name) 95 { 96 func_name_ = func_name; 97 } 98 SetClassName(std::string_view class_name)99void CalleeInfo::SetClassName(std::string_view class_name) 100 { 101 class_name_ = class_name; 102 } 103 SetExternalModuleName(std::string_view external_module_name)104void CalleeInfo::SetExternalModuleName(std::string_view external_module_name) 105 { 106 external_module_name_ = external_module_name; 107 } 108 SetGlobalVarName(std::string_view global_var_name)109void CalleeInfo::SetGlobalVarName(std::string_view global_var_name) 110 { 111 global_var_name_ = global_var_name; 112 } 113 } // namespace panda::defect_scan_aux