Skip to content

Commit b025d4c

Browse files
committed
Refactor DuplicateIncludeGuard to return HeaderFile and update expected test output for include guards
1 parent 22020e7 commit b025d4c

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

‎cpp/common/src/codingstandards/cpp/rules/includeguardsnotused/IncludeGuardsNotUsed.qll‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,11 @@ class BlockedIncludeGuard extends HeaderFile {
3030
/** A header file that shares its include guard name with another header file. */
3131
class DuplicateIncludeGuard extends CorrectIncludeGuard {
3232
/** Gets the first other header file, by path, that uses the same include guard name. */
33-
CorrectIncludeGuard getDuplicate() {
34-
result =
35-
min(CorrectIncludeGuard o |
36-
o != this and o.getIncludeGuardName() = this.getIncludeGuardName()
37-
|
38-
o order by o.getAbsolutePath()
39-
)
33+
HeaderFile getDuplicate() {
34+
result = min(HeaderFile h |
35+
h != this and hasIncludeGuard(h, _, _, this.getIncludeGuardName()) |
36+
h order by h.getAbsolutePath()
37+
)
4038
}
4139
}
4240

‎cpp/misra/test/rules/RULE-19-2-1/NoValidIfdefGuardInHeader.expected‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
| invalid3.h:0:0:0:0 | invalid3.h | Header file invalid3.h is missing expected include guard. | invalid3.h:0:0:0:0 | invalid3.h | |
44
| invalid4.h:0:0:0:0 | invalid4.h | Header file invalid4.h is missing expected include guard. | invalid4.h:0:0:0:0 | invalid4.h | |
55
| invalid5_file2.h:0:0:0:0 | invalid5_file2.h | Header file invalid5_file2.h is missing expected include guard. | invalid5_file2.h:0:0:0:0 | invalid5_file2.h | |
6+
| invalid6_a.h:0:0:0:0 | invalid6_a.h | Header file 'invalid6_a.h' uses an include guard also used by $@. | invalid6_b.h:0:0:0:0 | invalid6_b.h | header file |
67
| invalid6_b.h:0:0:0:0 | invalid6_b.h | Header file invalid6_b.h is never included by reusing the include guard used by $@. | invalid6_a.h:0:0:0:0 | invalid6_a.h | include guard |
78
| invalid7.h:0:0:0:0 | invalid7.h | Header file invalid7.h is missing expected include guard. | invalid7.h:0:0:0:0 | invalid7.h | |
89
| invalid9.h:0:0:0:0 | invalid9.h | Header file invalid9.h is missing expected include guard. | invalid9.h:0:0:0:0 | invalid9.h | |

0 commit comments

Comments
 (0)