@@ -18,27 +18,21 @@ import codingstandards.cpp.Linkage
1818
1919class ExternalIdentifiers extends Declaration {
2020 ExternalIdentifiers ( ) { hasExternalLinkage ( this ) }
21- }
2221
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+ }
3028}
3129
3230from ExternalIdentifiers d , ExternalIdentifiers d2
3331where
3432 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 ( )
4236select d ,
4337 "External identifer " + d .getName ( ) + " is nondistinct in first 31 characters, compared to $@." ,
4438 d2 , d2 .getName ( )
0 commit comments