Skip to content

Commit b6a4f67

Browse files
committed
A18-0-1: improve query logic
1 parent 5ff2a10 commit b6a4f67

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
`A18-0-1` - `CLibraryFacilitiesNotAccessedThroughCPPLibraryHeaders.ql`:
2+
- 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).

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ where
2828
* not use any of 'signal.h's facilities, for example.
2929
*/
3030

31-
filename = i.getIncludedFile().getBaseName() and
31+
filename = i.getIncludeText().substring(1, i.getIncludeText().length() - 1) and
3232
filename in [
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-
]
36+
] and
37+
not exists(i.getIncludedFile().getRelativePath())
3738
select i,
3839
"C library \"" + filename + "\" is included instead of the corresponding C++ library <c" +
3940
filename.prefix(filename.length() - 2) + ">."
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#ifndef LIB_EXAMPLE_H_
2+
#define LIB_EXAMPLE_H_
3+
4+
#endif

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,6 @@
3939
#include <ctime> // COMPLIANT
4040
#include <cuchar> // COMPLIANT
4141
#include <cwchar> // COMPLIANT
42-
#include <cwctype> // COMPLIANT
42+
#include <cwctype> // COMPLIANT
43+
44+
#include "lib/assert.h" // COMPLIANT

0 commit comments

Comments
 (0)