-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathStandardHeaderFileUsedSetjmph.ql
More file actions
44 lines (40 loc) · 1.06 KB
/
StandardHeaderFileUsedSetjmph.ql
File metadata and controls
44 lines (40 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* @id c/misra/standard-header-file-used-setjmph
* @name RULE-21-4: The standard header file shall not be used 'setjmp.h'
* @description The use of features of 'setjmp.h' may result in undefined behavior.
* @kind problem
* @precision very-high
* @problem.severity error
* @tags external/misra/id/rule-21-4
* correctness
* external/misra/obligation/required
*/
import cpp
import codingstandards.c.misra
class SetJmp extends Macro {
SetJmp() {
this.hasName("setjmp") and
this.getFile().getAbsolutePath().matches("%setjmp.h")
}
}
class LongJmp extends Function {
LongJmp() {
this.hasName("longjmp") and
this.getFile().getAbsolutePath().matches("%setjmp.h")
}
}
from Locatable use, string name
where
not isExcluded(use, BannedPackage::standardHeaderFileUsedSetjmphQuery()) and
(
exists(SetJmp setjmp |
use = setjmp.getAnInvocation() and
name = "setjmp"
)
or
exists(LongJmp longjmp |
use = longjmp.getACallToThisFunction() and
name = "longjmp"
)
)
select use, "Use of " + name + "."