Skip to content

Commit c603dba

Browse files
committed
Rule 21.10.1 - Formatting and reporting improvements
1 parent e26f32a commit c603dba

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

cpp/misra/src/rules/RULE-21-10-1/NoVariadicFunctionMacros.ql

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import codingstandards.cpp.misra
1818
class VaListType extends Type {
1919
VaListType() {
2020
this.getName() = "va_list" or
21-
this.getName() = "__va_list_tag" or
2221
this.(SpecifiedType).getBaseType() instanceof VaListType or
2322
this.(TypedefType).getBaseType() instanceof VaListType
2423
}
@@ -29,10 +28,15 @@ where
2928
not isExcluded(element, BannedAPIsPackage::noVariadicFunctionMacrosQuery()) and
3029
(
3130
element.(Variable).getType() instanceof VaListType and
32-
message = "Declaration of variable '" + element.(Variable).getName() + "' of type 'va_list'."
33-
or
34-
element.(Parameter).getType() instanceof VaListType and
35-
message = "Declaration of parameter '" + element.(Parameter).getName() + "' of type 'va_list'."
31+
(
32+
if element instanceof Parameter
33+
then
34+
message =
35+
"Declaration of parameter '" + element.(Parameter).getName() + "' of type 'va_list'."
36+
else
37+
message =
38+
"Declaration of variable '" + element.(Variable).getName() + "' of type 'va_list'."
39+
)
3640
or
3741
element instanceof BuiltInVarArgsStart and
3842
message = "Call to 'va_start'."
@@ -50,4 +54,4 @@ where
5054
message =
5155
"Declaration of typedef '" + element.(TypedefType).getName() + "' aliasing 'va_list' type."
5256
)
53-
select element, message
57+
select element, message

cpp/misra/test/rules/RULE-21-10-1/NoVariadicFunctionMacros.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
| test.cpp:31:3:31:12 | __builtin_va_end | Call to 'va_end'. |
1717
| test.cpp:32:3:32:12 | __builtin_va_end | Call to 'va_end'. |
1818
| test.cpp:35:37:35:38 | l1 | Declaration of parameter 'l1' of type 'va_list'. |
19-
| test.cpp:35:37:35:38 | l1 | Declaration of variable 'l1' of type 'va_list'. |
2019
| test.cpp:36:15:36:32 | __builtin_va_arg | Call to 'va_arg'. |
2120
| test.cpp:40:11:40:12 | l2 | Declaration of variable 'l2' of type 'va_list'. |
2221
| test.cpp:41:3:41:18 | __builtin_va_start | Call to 'va_start'. |

0 commit comments

Comments
 (0)