|
16 | 16 |
|
17 | 17 | import cpp |
18 | 18 | import codingstandards.cpp.misra |
| 19 | +import codingstandards.cpp.types.Compatible |
19 | 20 |
|
20 | | -predicate isInline(DeclarationEntry d) { |
21 | | - // There is no way to detect if a `GlobalVariable` is declared inline. |
22 | | - d.getDeclaration().(Function).isInline() |
| 21 | +predicate isInline(FunctionDeclarationEntry d) { d.getDeclaration().isInline() } |
| 22 | + |
| 23 | +predicate interestedInFunctions(FunctionDeclarationEntry f1, FunctionDeclarationEntry f2) { |
| 24 | + f1.isDefinition() and |
| 25 | + f2.isDefinition() and |
| 26 | + f1.getDeclaration().getQualifiedName() = f2.getDeclaration().getQualifiedName() and |
| 27 | + isInline(f1) and |
| 28 | + isInline(f2) and |
| 29 | + not f1.getFile() = f2.getFile() |
23 | 30 | } |
24 | 31 |
|
25 | | -from DeclarationEntry d1, DeclarationEntry d2, string namespace, string name |
| 32 | +module FunDeclEquiv = |
| 33 | + FunctionDeclarationTypeEquivalence<TypesCompatibleConfig, interestedInFunctions/2>; |
| 34 | + |
| 35 | +from FunctionDeclarationEntry d1, FunctionDeclarationEntry d2, string namespace, string name |
26 | 36 | where |
27 | 37 | not isExcluded([d1, d2], Declarations8Package::sourceCodeImplementedOnlyOnceQuery()) and |
28 | | - d1 != d2 and |
29 | | - d1.isDefinition() and |
30 | | - d2.isDefinition() and |
31 | | - isInline(d1) and |
32 | | - isInline(d2) and |
| 38 | + interestedInFunctions(d1, d2) and |
| 39 | + FunDeclEquiv::equalParameterTypes(d1, d2) and |
33 | 40 | d1.getDeclaration().hasQualifiedName(namespace, name) and |
34 | 41 | d2.getDeclaration().hasQualifiedName(namespace, name) and |
35 | | - d1.getFile() != d2.getFile() and |
36 | 42 | d1.getFile().getAbsolutePath() < d2.getFile().getAbsolutePath() |
37 | | -select d1, |
38 | | - "Inline variable '" + d1.getName() + |
39 | | - "' is defined in multiple files, violating the source code uniqueness requirement." |
| 43 | +select d1, "Inline function '" + d1.getName() + "' is implemented in multiple files: $@ and $@.", |
| 44 | + d1, d1.getFile().getBaseName(), d2, d2.getFile().getBaseName() |
0 commit comments