@@ -19,26 +19,36 @@ import codingstandards.cpp.autosar
1919/**
2020 * Holds if the class has a non-virtual member function with the given name.
2121 */
22+ pragma [ noinline, nomagic]
2223predicate hasNonVirtualMemberFunction ( Class clazz , MemberFunction mf , string name ) {
2324 mf .getDeclaringType ( ) = clazz and
2425 mf .getName ( ) = name and
2526 not mf .isVirtual ( )
2627}
2728
28- from FunctionDeclarationEntry overridingDecl , MemberFunction hiddenDecl
29+ /**
30+ * Holds if the member function is in a class with the given base class, and has the given name.
31+ */
32+ pragma [ noinline, nomagic]
33+ predicate hasDeclarationBaseClass ( MemberFunction mf , Class baseClass , string functionName ) {
34+ baseClass = mf .getDeclaringType ( ) .getABaseClass ( ) and
35+ functionName = mf .getName ( )
36+ }
37+
38+ from MemberFunction overridingDecl , MemberFunction hiddenDecl , Class baseClass , string name
2939where
3040 not isExcluded ( overridingDecl , ScopePackage:: hiddenInheritedNonOverridableMemberFunctionQuery ( ) ) and
3141 // Check if we are overriding a non-virtual inherited member function
32- hasNonVirtualMemberFunction ( overridingDecl . getDeclaration ( ) . getDeclaringType ( ) . getABaseClass ( ) ,
33- hiddenDecl , overridingDecl . getName ( ) ) and
42+ hasNonVirtualMemberFunction ( baseClass , hiddenDecl , name ) and
43+ hasDeclarationBaseClass ( overridingDecl , baseClass , name ) and
3444 // Where the hidden member function isn't explicitly brought in scope through a using declaration.
3545 not exists ( UsingDeclarationEntry ude |
3646 ude .getDeclaration ( ) = hiddenDecl and
37- ude .getEnclosingElement ( ) = overridingDecl .getDeclaration ( ) . getDeclaringType ( )
47+ ude .getEnclosingElement ( ) = overridingDecl .getDeclaringType ( )
3848 ) and
3949 // Exclude compiler generated member functions which include things like copy constructor that hide base class
4050 // copy constructors.
41- not overridingDecl .getDeclaration ( ) . isCompilerGenerated ( )
51+ not overridingDecl .isCompilerGenerated ( )
4252select overridingDecl ,
43- "Declaration for member '" + overridingDecl . getName ( ) +
44- "' hides non-overridable inherited member function $@" , hiddenDecl , hiddenDecl .getName ( )
53+ "Declaration for member '" + name + "' hides non-overridable inherited member function $@" ,
54+ hiddenDecl , hiddenDecl .getName ( )
0 commit comments