Skip to content

Commit 449d90f

Browse files
committed
A18-0-1: improve heuristic and test
1 parent df07198 commit 449d90f

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

cpp/autosar/src/rules/A18-0-1/CLibraryFacilitiesNotAccessedThroughCPPLibraryHeaders.ql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ where
3333
"assert.h", "ctype.h", "errno.h", "fenv.h", "float.h", "inttypes.h", "limits.h", "locale.h",
3434
"math.h", "setjmp.h", "signal.h", "stdarg.h", "stddef.h", "stdint.h", "stdio.h", "stdlib.h",
3535
"string.h", "time.h", "uchar.h", "wchar.h", "wctype.h"
36-
] and
37-
not exists(i.getIncludedFile().getRelativePath())
36+
]
3837
select i,
3938
"C library \"" + filename + "\" is included instead of the corresponding C++ library <c" +
4039
filename.prefix(filename.length() - 2) + ">."

cpp/autosar/test/rules/A18-0-1/CLibraryFacilitiesNotAccessedThroughCPPLibraryHeaders.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@
1919
| test.cpp:19:1:19:18 | #include <uchar.h> | C library "uchar.h" is included instead of the corresponding C++ library <cuchar>. |
2020
| test.cpp:20:1:20:18 | #include <wchar.h> | C library "wchar.h" is included instead of the corresponding C++ library <cwchar>. |
2121
| test.cpp:21:1:21:19 | #include <wctype.h> | C library "wctype.h" is included instead of the corresponding C++ library <cwctype>. |
22+
| test.cpp:45:1:45:17 | #include "time.h" | C library "time.h" is included instead of the corresponding C++ library <ctime>. |

cpp/autosar/test/rules/A18-0-1/test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@
4141
#include <cwchar> // COMPLIANT
4242
#include <cwctype> // COMPLIANT
4343

44-
#include "lib/assert.h" // COMPLIANT
45-
#include "time.h" // COMPLIANT - no way to check if this is a local checked in std lib copy
44+
#include "lib/example.h" // COMPLIANT
45+
#include "time.h" // NON_COMPLIANT

0 commit comments

Comments
 (0)