Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion change_notes/2024-02-12-improve-a18-0-1.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
`A18-0-1` - `CLibraryFacilitiesNotAccessedThroughCPPLibraryHeaders.ql`:
- `A18-0-1` - `CLibraryFacilitiesNotAccessedThroughCPPLibraryHeaders.ql`:
- Fix issue #7 - improve query logic to only match on exact standard library names (exclude local files with same names. Now excludes sys/header.h type headers as well from the results as those are not C standard libraries).
Comment thread
knewbury01 marked this conversation as resolved.
Outdated
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ where
"assert.h", "ctype.h", "errno.h", "fenv.h", "float.h", "inttypes.h", "limits.h", "locale.h",
"math.h", "setjmp.h", "signal.h", "stdarg.h", "stddef.h", "stdint.h", "stdio.h", "stdlib.h",
"string.h", "time.h", "uchar.h", "wchar.h", "wctype.h"
] and
not exists(i.getIncludedFile().getRelativePath())
]
select i,
"C library \"" + filename + "\" is included instead of the corresponding C++ library <c" +
filename.prefix(filename.length() - 2) + ">."
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
| test.cpp:19:1:19:18 | #include <uchar.h> | C library "uchar.h" is included instead of the corresponding C++ library <cuchar>. |
| test.cpp:20:1:20:18 | #include <wchar.h> | C library "wchar.h" is included instead of the corresponding C++ library <cwchar>. |
| test.cpp:21:1:21:19 | #include <wctype.h> | C library "wctype.h" is included instead of the corresponding C++ library <cwctype>. |
| test.cpp:45:1:45:17 | #include "time.h" | C library "time.h" is included instead of the corresponding C++ library <ctime>. |
3 changes: 2 additions & 1 deletion cpp/autosar/test/rules/A18-0-1/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@
#include <cwchar> // COMPLIANT
#include <cwctype> // COMPLIANT

#include "lib/assert.h" // COMPLIANT
#include "lib/example.h" // COMPLIANT
#include "time.h" // NON_COMPLIANT
4 changes: 4 additions & 0 deletions cpp/autosar/test/rules/A18-0-1/time.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#ifndef LIB_TIME_EXAMPLE_H_
#define LIB_TIME_EXAMPLE_H_
// may be a user lib or a std lib checked into a project
#endif