@@ -18,27 +18,36 @@ import cpp
1818import codingstandards.cpp.misra
1919import codingstandards.cpp.types.Compatible
2020
21- predicate isInline ( FunctionDeclarationEntry d ) { d .getDeclaration ( ) .isInline ( ) }
21+ class RelevantDeclaration extends FunctionDeclarationEntry {
22+ Function function ;
23+
24+ RelevantDeclaration ( ) {
25+ isDefinition ( ) and
26+ function = getDeclaration ( ) and
27+ function .isInline ( )
28+ }
29+
30+ string getQualifiedName ( ) { result = function .getQualifiedName ( ) }
31+ }
2232
2333predicate 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 ( )
34+ not f1 = f2 and
35+ exists ( RelevantDeclaration d1 , RelevantDeclaration d2 |
36+ f1 = d1 and
37+ f2 = d2 and
38+ d1 .getQualifiedName ( ) = d2 .getQualifiedName ( ) and
39+ not f1 .getFile ( ) = f2 .getFile ( )
40+ )
3041}
3142
3243module FunDeclEquiv =
3344 FunctionDeclarationTypeEquivalence< TypesCompatibleConfig , interestedInFunctions / 2 > ;
3445
35- from FunctionDeclarationEntry d1 , FunctionDeclarationEntry d2 , string namespace , string name
46+ from RelevantDeclaration d1 , RelevantDeclaration d2
3647where
3748 not isExcluded ( [ d1 , d2 ] , Declarations8Package:: duplicateInlineFunctionDefinitionsQuery ( ) ) and
3849 interestedInFunctions ( d1 , d2 ) and
3950 FunDeclEquiv:: equalParameterTypes ( d1 , d2 ) and
40- d1 .getDeclaration ( ) .hasQualifiedName ( namespace , name ) and
41- d2 .getDeclaration ( ) .hasQualifiedName ( namespace , name ) and
4251 d1 .getFile ( ) .getAbsolutePath ( ) < d2 .getFile ( ) .getAbsolutePath ( )
4352select d1 , "Inline function '" + d1 .getName ( ) + "' is implemented in multiple files: $@ and $@." ,
4453 d1 , d1 .getFile ( ) .getBaseName ( ) , d2 , d2 .getFile ( ) .getBaseName ( )
0 commit comments