Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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: 2 additions & 0 deletions change_notes/2024-02-12-improve-a18-0-1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
`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).
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ where
* not use any of 'signal.h's facilities, for example.
*/

filename = i.getIncludedFile().getBaseName() and
filename = i.getIncludeText().substring(1, i.getIncludeText().length() - 1) and
filename in [
"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) + ">."
4 changes: 4 additions & 0 deletions cpp/autosar/test/rules/A18-0-1/lib/assert.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#ifndef LIB_EXAMPLE_H_
#define LIB_EXAMPLE_H_

#endif
4 changes: 3 additions & 1 deletion cpp/autosar/test/rules/A18-0-1/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@
#include <ctime> // COMPLIANT
#include <cuchar> // COMPLIANT
#include <cwchar> // COMPLIANT
#include <cwctype> // COMPLIANT
#include <cwctype> // COMPLIANT

#include "lib/assert.h" // COMPLIANT