Skip to content

Commit ec4247b

Browse files
authored
Merge pull request #530 from knewbury01/knewbury01/A18-0-1-improvements
A18-0-1: improve query logic
2 parents 7693a3c + 7fa5a5e commit ec4247b

File tree

6 files changed

+16
-2
lines changed

6 files changed

+16
-2
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+
- Fix issue #7 - improve query logic to only match on exact standard library names (e.g., now excludes sys/header.h type headers from the results as those are not C standard libraries).

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ 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",

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>. |
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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,7 @@
3939
#include <ctime> // COMPLIANT
4040
#include <cuchar> // COMPLIANT
4141
#include <cwchar> // COMPLIANT
42-
#include <cwctype> // COMPLIANT
42+
#include <cwctype> // COMPLIANT
43+
44+
#include "lib/example.h" // COMPLIANT
45+
#include "time.h" // NON_COMPLIANT

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#ifndef LIB_TIME_EXAMPLE_H_
2+
#define LIB_TIME_EXAMPLE_H_
3+
// may be a user lib or a std lib checked into a project
4+
#endif

0 commit comments

Comments
 (0)