1717import cpp
1818import codingstandards.cpp.autosar
1919
20+ private predicate isInFunctionScope ( Declaration d ) {
21+ // Type declared in function
22+ exists ( d .( UserType ) .getEnclosingFunction ( ) )
23+ or
24+ // Member declared in type which is in function scope
25+ isInFunctionScope ( d .getDeclaringType ( ) )
26+ }
27+
2028/**
2129 * A declaration which is required to be preceded by documentation by AUTOSAR A2-7-3.
2230 */
@@ -42,10 +50,8 @@ class DocumentableDeclaration extends Declaration {
4250 declarationType = "member variable" and
4351 // Exclude memeber variables in instantiated templates, which cannot reasonably be documented.
4452 not this .( MemberVariable ) .isFromTemplateInstantiation ( _) and
45- // Exclude anonymous lambda functions.
46- // TODO: replace with the following when support is added.
47- // not this.(MemberVariable).isCompilerGenerated()
48- not exists ( LambdaExpression lc | lc .getACapture ( ) .getField ( ) = this )
53+ // Exclude compiler generated variables, such as those for anonymous lambda functions
54+ not this .( MemberVariable ) .isCompilerGenerated ( )
4955 }
5056
5157 /** Gets a `DeclarationEntry` for this declaration that should be documented. */
@@ -96,6 +102,7 @@ from DocumentableDeclaration d, DeclarationEntry de
96102where
97103 not isExcluded ( de , CommentsPackage:: undocumentedUserDefinedTypeQuery ( ) ) and
98104 not isExcluded ( d , CommentsPackage:: undocumentedUserDefinedTypeQuery ( ) ) and
105+ not isInFunctionScope ( d ) and
99106 d .getAnUndocumentedDeclarationEntry ( ) = de
100107select de ,
101108 "Declaration entry for " + d .getDeclarationType ( ) + " " + d .getName ( ) +
0 commit comments