1 /** 2 * Copyright (c) 2024 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 CFI_CLASS_HIERARCHY_H 17 #define CFI_CLASS_HIERARCHY_H 18 19 #include "cfi_util.h" 20 21 struct A { 22 virtual void Test(); 23 }; 24 Test()25void A::Test() 26 { 27 printf("A::Test()\n"); 28 } 29 30 struct B : A { 31 void Test() override; 32 }; 33 Test()34void B::Test() 35 { 36 printf("B::Test()\n"); 37 } 38 39 struct C : A { 40 }; 41 42 struct D { 43 virtual void Test(); 44 }; 45 Test()46void D::Test() 47 { 48 printf("D::Test()\n"); 49 } 50 51 struct CallTestA { 52 virtual void VcallFunc(); 53 void CallFunc(); 54 }; 55 VcallFunc()56void CallTestA::VcallFunc() 57 { 58 printf("CallTestA::VcallFunc()\n"); 59 } 60 CallFunc()61void CallTestA::CallFunc() 62 { 63 printf("CallTestA::CallFunc()\n"); 64 } 65 66 struct CallTestB { 67 virtual void VcallFunc(); 68 void CallFunc(); 69 }; 70 VcallFunc()71void CallTestB::VcallFunc() 72 { 73 printf("CallTestB::VcallFunc()\n"); 74 } 75 CallFunc()76void CallTestB::CallFunc() 77 { 78 printf("CallTestB::CallFunc()\n"); 79 } 80 81 #endif