From 671d17d4cb7c3efad7e9a50d3ce85030f2463304 Mon Sep 17 00:00:00 2001 From: Kristen Newbury Date: Tue, 21 Apr 2026 09:14:55 -0400 Subject: [PATCH 1/2] Fix shared query problems predicate format --- .../BitFieldsShouldNotBeDeclared.qll | 13 +++++-------- .../BitFieldsShouldNotBeDeclared.expected | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/cpp/common/src/codingstandards/cpp/rules/bitfieldsshouldnotbedeclared/BitFieldsShouldNotBeDeclared.qll b/cpp/common/src/codingstandards/cpp/rules/bitfieldsshouldnotbedeclared/BitFieldsShouldNotBeDeclared.qll index 6404a023e..1e45f0c1f 100644 --- a/cpp/common/src/codingstandards/cpp/rules/bitfieldsshouldnotbedeclared/BitFieldsShouldNotBeDeclared.qll +++ b/cpp/common/src/codingstandards/cpp/rules/bitfieldsshouldnotbedeclared/BitFieldsShouldNotBeDeclared.qll @@ -17,20 +17,17 @@ signature module BitFieldsShouldNotBeDeclaredConfigSig { } module BitFieldsShouldNotBeDeclared { - query predicate problems( - BitField bf, Class c, string message, Class linkLocation, string linkDescription - ) { + query predicate problems(BitField bf, string message, Class linkLocation, string linkDescription) { /* * The condition that is allowed that is IF this is a bit-field, then it should be part of a class * that is flagged as a hardware or protocol class. To detect this we look for violations of that form. */ not isExcluded(bf, Config::getQuery()) and - not isExcluded(c, Config::getQuery()) and - bf = c.getAField() and - linkLocation = c and - linkDescription = c.getName() and - not c instanceof HardwareOrProtocolInterfaceClass and + not isExcluded(linkLocation, Config::getQuery()) and + bf = linkLocation.getAField() and + linkDescription = linkLocation.getName() and + not linkLocation instanceof HardwareOrProtocolInterfaceClass and message = "Bit-field used within a class $@ that is not a hardware or protocol class." } } diff --git a/cpp/common/test/rules/bitfieldsshouldnotbedeclared/BitFieldsShouldNotBeDeclared.expected b/cpp/common/test/rules/bitfieldsshouldnotbedeclared/BitFieldsShouldNotBeDeclared.expected index abb3a6379..dce1a44d2 100644 --- a/cpp/common/test/rules/bitfieldsshouldnotbedeclared/BitFieldsShouldNotBeDeclared.expected +++ b/cpp/common/test/rules/bitfieldsshouldnotbedeclared/BitFieldsShouldNotBeDeclared.expected @@ -1 +1 @@ -| test.cpp:57:8:57:8 | c | test.cpp:53:7:53:8 | B2 | Bit-field used within a class $@ that is not a hardware or protocol class. | test.cpp:53:7:53:8 | B2 | B2 | +| test.cpp:57:8:57:8 | c | Bit-field used within a class $@ that is not a hardware or protocol class. | test.cpp:53:7:53:8 | B2 | B2 | From 963ac1e981d1b9d7985397c89e26b5a267e0bed5 Mon Sep 17 00:00:00 2001 From: Kristen Newbury Date: Tue, 21 Apr 2026 12:32:00 -0400 Subject: [PATCH 2/2] Change names for clarity --- .../BitFieldsShouldNotBeDeclared.qll | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cpp/common/src/codingstandards/cpp/rules/bitfieldsshouldnotbedeclared/BitFieldsShouldNotBeDeclared.qll b/cpp/common/src/codingstandards/cpp/rules/bitfieldsshouldnotbedeclared/BitFieldsShouldNotBeDeclared.qll index 1e45f0c1f..c35900d5f 100644 --- a/cpp/common/src/codingstandards/cpp/rules/bitfieldsshouldnotbedeclared/BitFieldsShouldNotBeDeclared.qll +++ b/cpp/common/src/codingstandards/cpp/rules/bitfieldsshouldnotbedeclared/BitFieldsShouldNotBeDeclared.qll @@ -17,17 +17,17 @@ signature module BitFieldsShouldNotBeDeclaredConfigSig { } module BitFieldsShouldNotBeDeclared { - query predicate problems(BitField bf, string message, Class linkLocation, string linkDescription) { + query predicate problems(BitField bf, string message, Class c, string className) { /* * The condition that is allowed that is IF this is a bit-field, then it should be part of a class * that is flagged as a hardware or protocol class. To detect this we look for violations of that form. */ not isExcluded(bf, Config::getQuery()) and - not isExcluded(linkLocation, Config::getQuery()) and - bf = linkLocation.getAField() and - linkDescription = linkLocation.getName() and - not linkLocation instanceof HardwareOrProtocolInterfaceClass and + not isExcluded(c, Config::getQuery()) and + bf = c.getAField() and + className = c.getName() and + not c instanceof HardwareOrProtocolInterfaceClass and message = "Bit-field used within a class $@ that is not a hardware or protocol class." } }