@@ -18,27 +18,21 @@ import codingstandards.cpp.Linkage
18
18
19
19
class ExternalIdentifiers extends Declaration {
20
20
ExternalIdentifiers ( ) { hasExternalLinkage ( this ) }
21
- }
22
21
23
- class ExternalIdentifiersLong extends ExternalIdentifiers {
24
- ExternalIdentifiersLong ( ) { this .getName ( ) .length ( ) >= 32 }
25
- }
26
-
27
- predicate notSame ( ExternalIdentifiers d , ExternalIdentifiers d2 ) {
28
- not d = d2 and
29
- d .getLocation ( ) .getStartLine ( ) >= d2 .getLocation ( ) .getStartLine ( )
22
+ string getSignificantName ( ) {
23
+ //C99 states the first 31 characters of external identifiers are significant
24
+ //C90 states the first 6 characters of external identifiers are significant and case is not required to be significant
25
+ //C90 is not currently considered by this rule
26
+ result = this .getName ( ) .prefix ( 31 )
27
+ }
30
28
}
31
29
32
30
from ExternalIdentifiers d , ExternalIdentifiers d2
33
31
where
34
32
not isExcluded ( d , Declarations1Package:: externalIdentifiersNotDistinctQuery ( ) ) and
35
- notSame ( d , d2 ) and
36
- //C99 states the first 31 characters of external identifiers are significant
37
- //C90 states the first 6 characters of external identifiers are significant and case is not required to be significant
38
- //C90 is not currently considered by this rule
39
- if d instanceof ExternalIdentifiersLong and d2 instanceof ExternalIdentifiersLong
40
- then d .getName ( ) .prefix ( 31 ) = d2 .getName ( ) .prefix ( 31 )
41
- else d .getName ( ) = d2 .getName ( )
33
+ not d = d2 and
34
+ d .getLocation ( ) .getStartLine ( ) >= d2 .getLocation ( ) .getStartLine ( ) and
35
+ d .getSignificantName ( ) = d2 .getSignificantName ( )
42
36
select d ,
43
37
"External identifer " + d .getName ( ) + " is nondistinct in first 31 characters, compared to $@." ,
44
38
d2 , d2 .getName ( )
0 commit comments