File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed
Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -133,11 +133,7 @@ where not hf instanceof IncludeGuardedHeader
133133 // Exclude files which contain no declaration entries or top level
134134 // declarations (e.g. just preprocessor directives; or non-top level
135135 // code).
136- and (
137- exists ( DeclarationEntry de | de .getFile ( ) = hf ) or
138- exists ( Declaration d | d .getFile ( ) = hf and d .isTopLevel ( ) ) or
139- exists ( UsingEntry ue | ue .getFile ( ) = hf )
140- )
136+ and not hf .noTopLevelCode ( )
141137 // Exclude files which look like they contain 'x-macros'
142138 and not hasXMacro ( hf )
143139 // Exclude files which are always #imported.
Original file line number Diff line number Diff line change @@ -453,6 +453,20 @@ class HeaderFile extends File {
453453 exists ( Include i | i .getIncludedFile ( ) = this )
454454 }
455455
456+ /**
457+ * Holds if this header file does not contain any declaration entries or top level
458+ * declarations. For example it might be:
459+ * - a file containing only preprocessor directives and/or comments
460+ * - an empty file
461+ * - a file that contains non-top level code or data that's included in an
462+ * unusual way
463+ */
464+ predicate noTopLevelCode ( )
465+ {
466+ not exists ( DeclarationEntry de | de .getFile ( ) = this ) and
467+ not exists ( Declaration d | d .getFile ( ) = this and d .isTopLevel ( ) ) and
468+ not exists ( UsingEntry ue | ue .getFile ( ) = this )
469+ }
456470}
457471
458472/**
You can’t perform that action at this time.
0 commit comments