@@ -12,35 +12,35 @@ abstract class IdentifierHiddenSharedQuery extends Query { }
1212Query getQuery ( ) { result instanceof IdentifierHiddenSharedQuery }
1313
1414/**
15- * There is a lambda that contains a declaration
16- * that hides something that is captured
17- * and the lambda exists in the function where this lamda is enclosed
15+ * Holds if declaration `innerDecl`, declared in a lambda, hides a declaration `outerDecl` captured by the lambda.
1816 */
19- predicate hiddenInLambda ( UserDeclaration v2 , UserDeclaration v1 ) {
17+ predicate hiddenInLambda ( UserVariable outerDecl , UserVariable innerDecl ) {
2018 exists ( Scope s , Closure le |
21- s .getADeclaration ( ) = v2 and
19+ //innerDecl declared inside of the lambda
20+ s .getADeclaration ( ) = innerDecl and
2221 s .getAnAncestor ( ) = le and
23- le .getEnclosingFunction ( ) .getBasicBlock ( ) .( Scope ) = v1 .getParentScope ( ) and
24- exists ( LambdaCapture cap , Variable v |
25- v .getAnAccess ( ) = cap .getInitializer ( ) .( VariableAccess ) and
26- v = v1 and
22+ le .getEnclosingFunction ( ) .getBasicBlock ( ) .( Scope ) = outerDecl .getParentScope ( ) and
23+ exists ( LambdaCapture cap |
24+ outerDecl .getAnAccess ( ) = cap .getInitializer ( ) .( VariableAccess ) and
2725 le .getLambdaExpression ( ) .getACapture ( ) = cap
2826 ) and
29- v2 .getName ( ) = v1 .getName ( )
27+ innerDecl .getName ( ) = outerDecl .getName ( )
3028 )
3129}
3230
33- query predicate problems ( UserDeclaration v2 , string message , UserDeclaration v1 , string varName ) {
34- not isExcluded ( v1 , getQuery ( ) ) and
35- not isExcluded ( v2 , getQuery ( ) ) and
31+ query predicate problems (
32+ UserDeclaration innerDecl , string message , UserDeclaration outerDecl , string varName
33+ ) {
34+ not isExcluded ( outerDecl , getQuery ( ) ) and
35+ not isExcluded ( innerDecl , getQuery ( ) ) and
3636 //ignore template variables for this rule
37- not v1 instanceof TemplateVariable and
38- not v2 instanceof TemplateVariable and
39- //ignore types for this rule
40- not v2 instanceof Type and
41- not v1 instanceof Type and
42- ( hidesStrict ( v1 , v2 ) or hiddenInLambda ( v2 , v1 ) ) and
43- not excludedViaNestedNamespaces ( v2 , v1 ) and
44- varName = v1 .getName ( ) and
37+ not outerDecl instanceof TemplateVariable and
38+ not innerDecl instanceof TemplateVariable and
39+ //ignore types for this rule as the Misra C/C++ 23 version of this rule (rule 6.4.1 and 6.4.2) focuses solely on variables and functions
40+ not innerDecl instanceof Type and
41+ not outerDecl instanceof Type and
42+ ( hidesStrict ( outerDecl , innerDecl ) or hiddenInLambda ( outerDecl , innerDecl ) ) and
43+ not excludedViaNestedNamespaces ( outerDecl , innerDecl ) and
44+ varName = outerDecl .getName ( ) and
4545 message = "Declaration is hiding declaration $@."
4646}
0 commit comments