Skip to content

Commit 643aa35

Browse files
committed
RULE-21-11: Avoid double reporting macros
The macros in tgmath.h often expand to other macros in tgmath.h. This cause the query to report multiple macro violations for the one macro invocation. We exclude macro invocations expanded from other macro invocations from the same file to avoid this double reporting, and produce more useful and stable results across compilers.
1 parent 9a8f89f commit 643aa35

File tree

2 files changed

+2
-70
lines changed

2 files changed

+2
-70
lines changed

c/misra/src/rules/RULE-21-11/StandardHeaderFileTgmathhUsed.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ from Macro m, MacroInvocation mi
1717
where
1818
not isExcluded(mi, BannedPackage::standardHeaderFileTgmathhUsedQuery()) and
1919
mi.getMacro() = m and
20-
m.getFile().getBaseName() = "tgmath.h"
20+
m.getFile().getBaseName() = "tgmath.h" and
21+
not mi.getParentInvocation().getMacro().getFile().getBaseName() = "tgmath.h"
2122
select mi, "Call to banned macro " + m.getName() + "."
Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,5 @@
1-
| test.c:5:3:5:9 | __DBLCX(x) | Call to banned macro __DBLCX. |
2-
| test.c:5:3:5:9 | __FLT(x) | Call to banned macro __FLT. |
3-
| test.c:5:3:5:9 | __FLTCX(x) | Call to banned macro __FLTCX. |
4-
| test.c:5:3:5:9 | __IS_CX(x) | Call to banned macro __IS_CX. |
5-
| test.c:5:3:5:9 | __IS_CX(x) | Call to banned macro __IS_CX. |
6-
| test.c:5:3:5:9 | __IS_CX(x) | Call to banned macro __IS_CX. |
7-
| test.c:5:3:5:9 | __IS_FP(x) | Call to banned macro __IS_FP. |
8-
| test.c:5:3:5:9 | __IS_FP(x) | Call to banned macro __IS_FP. |
9-
| test.c:5:3:5:9 | __IS_FP(x) | Call to banned macro __IS_FP. |
10-
| test.c:5:3:5:9 | __IS_FP(x) | Call to banned macro __IS_FP. |
11-
| test.c:5:3:5:9 | __IS_FP(x) | Call to banned macro __IS_FP. |
12-
| test.c:5:3:5:9 | __IS_REAL(x) | Call to banned macro __IS_REAL. |
13-
| test.c:5:3:5:9 | __IS_REAL(x) | Call to banned macro __IS_REAL. |
14-
| test.c:5:3:5:9 | __LDBL(x) | Call to banned macro __LDBL. |
15-
| test.c:5:3:5:9 | __LDBLCX(x) | Call to banned macro __LDBLCX. |
16-
| test.c:5:3:5:9 | __RETCAST(x) | Call to banned macro __RETCAST. |
17-
| test.c:5:3:5:9 | __tg_real_complex(fun,x) | Call to banned macro __tg_real_complex. |
181
| test.c:5:3:5:9 | sqrt(x) | Call to banned macro sqrt. |
19-
| test.c:7:3:7:8 | __DBLCX(x) | Call to banned macro __DBLCX. |
20-
| test.c:7:3:7:8 | __FLT(x) | Call to banned macro __FLT. |
21-
| test.c:7:3:7:8 | __FLTCX(x) | Call to banned macro __FLTCX. |
22-
| test.c:7:3:7:8 | __IS_CX(x) | Call to banned macro __IS_CX. |
23-
| test.c:7:3:7:8 | __IS_CX(x) | Call to banned macro __IS_CX. |
24-
| test.c:7:3:7:8 | __IS_CX(x) | Call to banned macro __IS_CX. |
25-
| test.c:7:3:7:8 | __IS_FP(x) | Call to banned macro __IS_FP. |
26-
| test.c:7:3:7:8 | __IS_FP(x) | Call to banned macro __IS_FP. |
27-
| test.c:7:3:7:8 | __IS_FP(x) | Call to banned macro __IS_FP. |
28-
| test.c:7:3:7:8 | __IS_FP(x) | Call to banned macro __IS_FP. |
29-
| test.c:7:3:7:8 | __IS_FP(x) | Call to banned macro __IS_FP. |
30-
| test.c:7:3:7:8 | __IS_REAL(x) | Call to banned macro __IS_REAL. |
31-
| test.c:7:3:7:8 | __IS_REAL(x) | Call to banned macro __IS_REAL. |
32-
| test.c:7:3:7:8 | __LDBL(x) | Call to banned macro __LDBL. |
33-
| test.c:7:3:7:8 | __LDBLCX(x) | Call to banned macro __LDBLCX. |
34-
| test.c:7:3:7:8 | __RETCAST(x) | Call to banned macro __RETCAST. |
35-
| test.c:7:3:7:8 | __tg_real_complex(fun,x) | Call to banned macro __tg_real_complex. |
362
| test.c:7:3:7:8 | sin(x) | Call to banned macro sin. |
37-
| test.c:10:21:10:28 | __DBLCX(x) | Call to banned macro __DBLCX. |
38-
| test.c:10:21:10:28 | __FLT(x) | Call to banned macro __FLT. |
39-
| test.c:10:21:10:28 | __FLTCX(x) | Call to banned macro __FLTCX. |
40-
| test.c:10:21:10:28 | __IS_CX(x) | Call to banned macro __IS_CX. |
41-
| test.c:10:21:10:28 | __IS_CX(x) | Call to banned macro __IS_CX. |
42-
| test.c:10:21:10:28 | __IS_CX(x) | Call to banned macro __IS_CX. |
43-
| test.c:10:21:10:28 | __IS_FP(x) | Call to banned macro __IS_FP. |
44-
| test.c:10:21:10:28 | __IS_FP(x) | Call to banned macro __IS_FP. |
45-
| test.c:10:21:10:28 | __IS_FP(x) | Call to banned macro __IS_FP. |
46-
| test.c:10:21:10:28 | __IS_FP(x) | Call to banned macro __IS_FP. |
47-
| test.c:10:21:10:28 | __IS_FP(x) | Call to banned macro __IS_FP. |
48-
| test.c:10:21:10:28 | __IS_REAL(x) | Call to banned macro __IS_REAL. |
49-
| test.c:10:21:10:28 | __IS_REAL(x) | Call to banned macro __IS_REAL. |
50-
| test.c:10:21:10:28 | __LDBL(x) | Call to banned macro __LDBL. |
51-
| test.c:10:21:10:28 | __LDBLCX(x) | Call to banned macro __LDBLCX. |
52-
| test.c:10:21:10:28 | __RETCAST(x) | Call to banned macro __RETCAST. |
53-
| test.c:10:21:10:28 | __tg_real_complex(fun,x) | Call to banned macro __tg_real_complex. |
543
| test.c:10:21:10:28 | sqrt(x) | Call to banned macro sqrt. |
55-
| test.c:11:3:11:10 | __FLTCX(x) | Call to banned macro __FLTCX. |
56-
| test.c:11:3:11:10 | __IS_CX(x) | Call to banned macro __IS_CX. |
57-
| test.c:11:3:11:10 | __IS_CX(x) | Call to banned macro __IS_CX. |
58-
| test.c:11:3:11:10 | __IS_FP(x) | Call to banned macro __IS_FP. |
59-
| test.c:11:3:11:10 | __IS_FP(x) | Call to banned macro __IS_FP. |
60-
| test.c:11:3:11:10 | __IS_FP(x) | Call to banned macro __IS_FP. |
61-
| test.c:11:3:11:10 | __LDBLCX(x) | Call to banned macro __LDBLCX. |
62-
| test.c:11:3:11:10 | __RETCAST_REAL(x) | Call to banned macro __RETCAST_REAL. |
63-
| test.c:11:3:11:10 | __tg_complex_retreal(fun,x) | Call to banned macro __tg_complex_retreal. |
644
| test.c:11:3:11:10 | creal(x) | Call to banned macro creal. |
65-
| test.c:12:3:12:10 | __FLTCX(x) | Call to banned macro __FLTCX. |
66-
| test.c:12:3:12:10 | __IS_CX(x) | Call to banned macro __IS_CX. |
67-
| test.c:12:3:12:10 | __IS_CX(x) | Call to banned macro __IS_CX. |
68-
| test.c:12:3:12:10 | __IS_FP(x) | Call to banned macro __IS_FP. |
69-
| test.c:12:3:12:10 | __IS_FP(x) | Call to banned macro __IS_FP. |
70-
| test.c:12:3:12:10 | __IS_FP(x) | Call to banned macro __IS_FP. |
71-
| test.c:12:3:12:10 | __LDBLCX(x) | Call to banned macro __LDBLCX. |
72-
| test.c:12:3:12:10 | __RETCAST_REAL(x) | Call to banned macro __RETCAST_REAL. |
73-
| test.c:12:3:12:10 | __tg_complex_retreal(fun,x) | Call to banned macro __tg_complex_retreal. |
745
| test.c:12:3:12:10 | cimag(x) | Call to banned macro cimag. |

0 commit comments

Comments
 (0)