@@ -21,13 +21,26 @@ import cpp
2121import codingstandards.cpp.autosar
2222import codingstandards.cpp.FunctionLikeMacro
2323
24+ class PermittedInnerDirectiveType extends PreprocessorDirective {
25+ PermittedInnerDirectiveType ( ) {
26+ //permissive listing for directives that can be used in a valid wrapper
27+ this instanceof MacroWrapper or
28+ this instanceof PreprocessorEndif or
29+ this instanceof Include or
30+ this instanceof PermittedMacro or
31+ this instanceof PreprocessorElif or
32+ this instanceof PreprocessorElse
33+ }
34+ }
35+
2436class PermittedDirectiveType extends PreprocessorDirective {
2537 PermittedDirectiveType ( ) {
2638 //permissive listing in case directive types modelled in ql ever expands (example non valid directives)
2739 this instanceof MacroWrapper or
2840 this instanceof PreprocessorEndif or
2941 this instanceof Include or
30- this instanceof PermittedMacro
42+ this instanceof PermittedMacro or
43+ this instanceof PreprocessorElse
3144 }
3245}
3346
@@ -40,9 +53,9 @@ pragma[noinline]
4053predicate isPreprocConditionalRange (
4154 PreprocessorBranch pb , string filepath , int startLine , int endLine
4255) {
43- exists ( PreprocessorEndif end | pb . getEndIf ( ) = end |
44- isPreprocFileAndLine ( pb , filepath , startLine ) and
45- isPreprocFileAndLine ( end , filepath , endLine )
56+ isPreprocFileAndLine ( pb , filepath , startLine ) and
57+ exists ( PreprocessorDirective end |
58+ pb . getNext ( ) = end and isPreprocFileAndLine ( end , filepath , endLine )
4659 )
4760}
4861
@@ -73,7 +86,7 @@ class MacroWrapper extends PreprocessorIfndef {
7386class AcceptableWrapper extends PreprocessorBranch {
7487 AcceptableWrapper ( ) {
7588 forall ( Element inner | not inner instanceof Comment and this = getAGuard ( inner ) |
76- inner instanceof PermittedDirectiveType
89+ inner instanceof PermittedInnerDirectiveType
7790 )
7891 }
7992}
0 commit comments