@@ -19,26 +19,36 @@ import codingstandards.cpp.autosar
19
19
/**
20
20
* Holds if the class has a non-virtual member function with the given name.
21
21
*/
22
+ pragma [ noinline, nomagic]
22
23
predicate hasNonVirtualMemberFunction ( Class clazz , MemberFunction mf , string name ) {
23
24
mf .getDeclaringType ( ) = clazz and
24
25
mf .getName ( ) = name and
25
26
not mf .isVirtual ( )
26
27
}
27
28
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
29
39
where
30
40
not isExcluded ( overridingDecl , ScopePackage:: hiddenInheritedNonOverridableMemberFunctionQuery ( ) ) and
31
41
// 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
34
44
// Where the hidden member function isn't explicitly brought in scope through a using declaration.
35
45
not exists ( UsingDeclarationEntry ude |
36
46
ude .getDeclaration ( ) = hiddenDecl and
37
- ude .getEnclosingElement ( ) = overridingDecl .getDeclaration ( ) . getDeclaringType ( )
47
+ ude .getEnclosingElement ( ) = overridingDecl .getDeclaringType ( )
38
48
) and
39
49
// Exclude compiler generated member functions which include things like copy constructor that hide base class
40
50
// copy constructors.
41
- not overridingDecl .getDeclaration ( ) . isCompilerGenerated ( )
51
+ not overridingDecl .isCompilerGenerated ( )
42
52
select 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