Skip to content

Commit 085033d

Browse files
committed
Update shared test query
1 parent bf7a636 commit 085033d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

cpp/common/src/codingstandards/cpp/rules/bitfieldsshouldnotbedeclared/BitFieldsShouldNotBeDeclared.qll

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,23 @@
1010
import cpp
1111
import codingstandards.cpp.Customizations
1212
import codingstandards.cpp.Exclusions
13+
import codingstandards.cpp.HardwareOrProtocolInterface
1314

1415
signature module BitFieldsShouldNotBeDeclaredConfigSig {
1516
Query getQuery();
1617
}
1718

1819
module BitFieldsShouldNotBeDeclared<BitFieldsShouldNotBeDeclaredConfigSig Config> {
19-
query predicate problems(Element e, string message) {
20-
not isExcluded(e, Config::getQuery()) and message = "<replace with problem alert message for >"
20+
query predicate problems(BitField bf, Class c, string message) {
21+
/*
22+
* The condition that is allowed that is IF this is a bit-field, then it should be part of a class
23+
* that is flagged as a hardware or protocol class. To detect this we look for violations of that form.
24+
*/
25+
26+
not isExcluded(bf, Config::getQuery()) and
27+
not isExcluded(c, Config::getQuery()) and
28+
bf = c.getAField() and
29+
not c instanceof HardwareOrProtocolInterfaceClass and
30+
message = "Bit-field used within a class that is not a hardware or protocol class."
2131
}
2232
}

0 commit comments

Comments
 (0)