Code Structure Analysis
Code Structure Analysis
Home| Services| C++ Grammar | Examples of Analysis | Contacts|

Member functions overwriting analysis

It is well known that methods can be overwritten in the derived classes. This technique is useful and it is used widely. Nevertheless, as the number of classes and the number overwritten methods increases, it becomes more and more difficult to maintain the source code. Difficulty comes from the fact that overwritten methods create interdependencies. It is not easy to remember exactly if a particular method was already overwritten in one of the parent classes or not. When the hierarchy is deep, the method can be overwritten several times. Dependencies like this can be comprehended using either graphs or matrixes.

This report describes analysis of overwritten methods in a hierarchy of classes. As a test data set, a hierarchy of 80 classes is taken. Definitions of these classes reside in a single file that is about 2000 lines long. This file can be viewed in a separate window.

The overview of inheritance relations between the classes in the test set is shown in the picture below. This is a scaled picture.

The results of analysis are presented in a table. The rows of this table describe classes. The name of the class is written on the left side. Indentation of the class name shows the derivation layer, similar to how file system explorers show the hierarchy of folders.

The columns of the tables describe methods of the classes. Analysis looks for methods that are overwritten (C++ standard uses the term override) in the derived classes. This analysis collects onformation both on virtual and non virtual methods. Those methods, which are present only in one class and are never overwritten are not included. Methods that differ by their set of parameters (C++ standard calls this overloading) are considered as different methods in this analysis. The test data set does not have such examples. The columns of the tables describe methods of the classes. The analysis looks for methods that are overwritten (C++ standard uses the term override) in the derived classes. This analysis collects information on both virtual and non-virtual methods. Methods that are present only in one class and are never overwritten are not included. Methods that differ in their set of parameters (C++ standard calls this overloading) are considered as different methods in this analysis. The test data set does not have such examples.

The cell of the table contains a word "new" if this method was introduced in this class, and it does not appear in any of its base classes. The cell contains a minus symbol if this method is not mentioned in the current class. If the method is overridden in the class, the cell contains the word "ovrd".

When overwriting a method, C++ standard allows changing its access level. Changing any other property of the method will cause either overloading or a syntax error. When analysis tool notices that access level of the method has changed, it shows the word "ovrd" in a different color. Test set contains such case. You can take a look and verify this in the source code. This is real analysis.



AddChildItem
AddToNestedDefnsSpace
CanHaveChildren
GetAssocDefnsSpaceRefsList
GetConstOperandValue
GetNestedDefnsSpace
GetNestedMembersList
GetUnresolvedNamesList
IsBlock
IsClassTemplateFamily
IsDataType
IsDefinition
IsExpression
IsFunctionFamily
IsFunctionName
IsFunctionType
IsNamespace
IsStatementBase
IsStructType
IsUnresolvedObject
Class names NewIndirectChildNotification
TCppItemBase new-new--- --newnewnewnew newnewnewnewnewnew newnewnew
TCppStatementBase ------ ------ -----ovrd ---
TCppDefnBase -new-new-new newnew---ovrd ------ ---
TCppDataTypeBase ------ ----ovrd- ------ ---
TCppBuiltInTypeDefn ------ ------ ------ ---
TCppBitFieldTypeDefn ovrd-ovrd--- ------ ------ --ovrd
TCppCvPtrRefTypeDefn ------ ------ ------ ---
TCppArrayTypeDefn ovrd-ovrd--- ------ ------ --ovrd
TCppStructTypeDefn ovrdovrdovrdovrd-ovrd ovrd----- ------ ovrd-ovrd
TCppClassTemplateDefn ------ ---ovrdovrd- ------ ---
TCppUnresolvedClassTemplate ovrd-ovrd--- -ovrd---- ------ -ovrdovrd
TCppClassTemplateSpecialization ovrd-ovrd--- ---ovrdovrd- ------ --ovrd
TCppClassTemplateInstantiation ovrd-ovrd--- ---ovrd-- ------ --ovrd
TCppUnresolvedStructType ovrd-ovrd--- -ovrd---- ------ -ovrdovrd
TCppDataTypeAliasDefn ------ ------ ------ ---
TCppEnumTypeDefn ovrd-ovrd--- ------ ------ --ovrd
TCppTemplateTypeParamDefn ------ ------ ------ ---
TCppUnresolvedDataType ovrd-ovrd--- -ovrd---- ------ -ovrdovrd
TCppFunctionTypeBase ------ ------ ---ovrd-- ---
TCppFunctionTypeDefn ovrd-ovrd--- ------ --ovrd--- --ovrd
TCppCodeEntryPointDefn ------ ------ -ovrd---- ---
TCppFunctionTemplateDefn ------ ------ ---ovrd-- ---
TCppUnresolvedFunctionTemplate ovrd-ovrd--- -ovrd---- ------ -ovrdovrd
TCppFunctionTemplateSpecialization ovrd-ovrd--- ------ ---ovrd-- --ovrd
TCppFunctionTemplateInstantiation ovrd-ovrd--- ------ ------ --ovrd
TCppUnresolvedCodeEntryPoint ovrd-ovrd--- -ovrd---- -ovrd---- -ovrdovrd
TCppFunctionTypeAliasDefn ------ ------ ------ ---
TCppDataFieldDefn ovrd-ovrd--- ------ ------ --ovrd
TCppUnresolvedDataField ovrd-ovrd--- -ovrd---- ------ -ovrdovrd
TCppBlockDefn ovrdovrdovrdovrd-ovrd ovrd-ovrd--- ------ --ovrd
TCppTryBlockDefn ------ ------ ------ ---
TCppCatchBlockDefn ------ ------ ------ ---
TCppLabelDefn ------ ------ ------ ---
TCppCaseLabelDefn ovrd-ovrd--- ------ ------ --ovrd
TCppEnumMemberDefn ovrd-ovrd--- ------ ------ --ovrd
TCppBaseClassSpec ------ ------ ------ ---
TCppNamespaceDefn ovrdovrdovrdovrd-ovrd ovrd----- ----ovrd- --ovrd
TCppGlobalNamespaceDefn ovrdovrdovrdovrd-ovrd ovrd----- ----ovrd- --ovrd
TCppNamespaceAliasDefn ------ ------ ------ ---
TCppUsingDeclarationDefn ------ ------ ------ ---
TCppUsingDirectiveDefn ------ ------ ------ ---
TCppAsmInsertDefn ------ ------ ------ ---
TCppTemplateTemplateParamDefn ovrd-ovrd--- ------ ------ --ovrd
TCppUnresolvedNameInfo ovrd-ovrd--- ------ ------ --ovrd
TCppExpressionBase --ovrd-new- ------ ovrd----- ---
TCppUnaryExpr ovrd---ovrd- ------ ------ --ovrd
TCppBinaryExpr ovrd---ovrd- ------ ------ --ovrd
TCppMultiOpExpr ovrd---ovrd- ------ ------ --ovrd
TCppAssignmentExpr ovrd----- ------ ------ --ovrd
TCppThrowExpr ovrd----- ------ ------ --ovrd
TCppConditionalExpr ovrd---ovrd- ------ ------ --ovrd
TCppFieldAccessExpr ovrd----- ------ ------ --ovrd
TCppFieldAccessPtrExpr ovrd----- ------ ------ --ovrd
TCppArrayIndexExpr ovrd---ovrd- ------ ------ --ovrd
TCppFunctionCallExpr ovrd----- ------ ------ --ovrd
TCppCastExpr ovrd---ovrd- ------ ------ --ovrd
TCppSizeofExpr ovrd---ovrd- ------ ------ --ovrd
TCppNewExpr ovrd----- ------ ------ --ovrd
TCppDeleteExpr ovrd----- ------ ------ --ovrd
TCppTypeidExpr ovrd----- ------ ------ --ovrd
TCppOperandExpr --ovrd-ovrd- ------ ------ ---
TCppEmptyStatement ------ ------ ------ ---
TCppIfStatement ovrd-ovrd--- ------ ------ --ovrd
TCppSwitchStatement ovrd-ovrd--- ------ ------ --ovrd
TCppForStatement ovrd-ovrd--- ------ ------ --ovrd
TCppWhileStatement ovrd-ovrd--- ------ ------ --ovrd
TCppDoWhileStatement ovrd-ovrd--- ------ ------ --ovrd
TCppGotoStatement ------ ------ ------ ---
TCppBreakStatement ------ ------ ------ ---
TCppContinueStatement ------ ------ ------ ---
TCppReturnStatement ovrd-ovrd--- ------ ------ --ovrd
TCppLightBlockDefn ovrd-ovrd--- ------ ------ --ovrd
TCppDataFieldInitializer ovrd-ovrd--- ------ ------ --ovrd
TCppPossibleExceptionSpec ------ ------ ------ ---
TCppLinkageSpec ------ ------ ------ ---
TCppFieldAlignSpec ovrd-ovrd--- ------ ------ --ovrd
TCppFriendSpec ------ ------ ------ ---
TCppTemplateTypeArgument ------ ------ ------ ---
TCppTemplateTemplateArgument ------ ------ ------ ---



The table above is a sample analysis. Customer may ask to split this table into several tables, ask to show a subset of methods, ask to display additional properties of the methods or classes, etc. This is all possible.


If you have any questions regarding this report, send us a message using the contacts page.