|
16 | 16 | import cpp
|
17 | 17 | import codingstandards.cpp.autosar
|
18 | 18 |
|
19 |
| -from FunctionDeclarationEntry overridingDecl, FunctionDeclarationEntry hiddenDecl |
| 19 | +/** |
| 20 | + * Holds if the class has a non-virtual member function with the given name. |
| 21 | + */ |
| 22 | +predicate hasNonVirtualMemberFunction(Class clazz, MemberFunction mf, string name) { |
| 23 | + mf.getDeclaringType() = clazz and |
| 24 | + mf.getName() = name and |
| 25 | + not mf.isVirtual() |
| 26 | +} |
| 27 | + |
| 28 | +from FunctionDeclarationEntry overridingDecl, MemberFunction hiddenDecl |
20 | 29 | where
|
21 | 30 | not isExcluded(overridingDecl, ScopePackage::hiddenInheritedNonOverridableMemberFunctionQuery()) and
|
22 | 31 | // Check if we are overriding a non-virtual inherited member function
|
23 |
| - overridingDecl.getName() = hiddenDecl.getName() and |
24 |
| - overridingDecl.getDeclaration().getDeclaringType().getABaseClass() = |
25 |
| - hiddenDecl.getDeclaration().getDeclaringType() and |
26 |
| - not hiddenDecl.getDeclaration().isVirtual() and |
| 32 | + hasNonVirtualMemberFunction(overridingDecl.getDeclaration().getDeclaringType().getABaseClass(), |
| 33 | + hiddenDecl, overridingDecl.getName()) and |
27 | 34 | // Where the hidden member function isn't explicitly brought in scope through a using declaration.
|
28 | 35 | not exists(UsingDeclarationEntry ude |
|
29 |
| - ude.getDeclaration() = hiddenDecl.getDeclaration() and |
| 36 | + ude.getDeclaration() = hiddenDecl and |
30 | 37 | ude.getEnclosingElement() = overridingDecl.getDeclaration().getDeclaringType() and
|
31 | 38 | ude.getLocation().getStartLine() < overridingDecl.getLocation().getStartLine()
|
32 | 39 | ) and
|
|
0 commit comments