Skip to content

Commit 5f10e7c

Browse files
copilot feedback
1 parent 6010732 commit 5f10e7c

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

cpp/common/src/codingstandards/cpp/Macro.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class FunctionLikeMacro extends Macro {
6161
noAfterParen = "(?!\\s*\\))" and
6262
// Parameter at word boundary in optional whitespace
6363
paramMatch = "\\s*\\b" + parameter + "\\b\\s*" and
64-
// A parameter is ##'d if it is preceded or followed by the # operator.
64+
// A parameter is #'d if it is preceded or followed by the # or ## operators.
6565
notHashed = "(?<!#)" + paramMatch and
6666
// Parameter is used without a leading or trailing parenthesis, and without #.
6767
getBody()

cpp/misra/src/rules/RULE-19-3-4/UnparenthesizedMacroArgument.ql

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import cpp
1818
import codingstandards.cpp.misra
1919
import codingstandards.cpp.Macro
2020
import codingstandards.cpp.MatchingParenthesis
21-
import codeql.util.Boolean
2221

2322
/**
2423
* This regex is used to find macro arguments that appear to have critical operators in them, before
@@ -129,8 +128,7 @@ class RiskyMacroInvocation extends MacroInvocation {
129128
* - the operator cannot be the first character in the string (i.e. it should not look like a
130129
* unary - or +)
131130
* - the operator cannot exist inside a generated string literal
132-
* - the operator existence of the operator should not be as a substring of "->", "++", or "--"
133-
* operators.
131+
* - the operator should not be found inside a "->", "++", or "--" operator.
134132
*
135133
* The results of this predicate should be flagged by the query.
136134
*/
@@ -141,7 +139,7 @@ class RiskyMacroInvocation extends MacroInvocation {
141139
int opIndex
142140
|
143141
parsedRoot.getInputString() = value and
144-
(topLevelText.getParent() = parsedRoot or topLevelText = parsedRoot) and
142+
parsedRoot = topLevelText.getParent() and
145143
text = topLevelText.getText().trim() and
146144
opExpr = getAGeneratedElement() and
147145
operator = opExpr.getOperator() and

cpp/misra/test/rules/RULE-19-3-4/test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ void f6() {
241241
// compliant, though an argument could be made the other way.
242242
// Regardless, this case is difficult for us to detect.
243243
#define M14(X) M1(X *X)
244-
M14(1); // NON-COMPLIANT[False negative] -- The definition of M13 is
244+
M14(1); // NON-COMPLIANT[False negative] -- The definition of M14 is
245245
// non-compliant, but we don't detect the generated elements.
246246

247247
// Trickier case of # operator to handle. In this case, we do not produce a
@@ -258,6 +258,6 @@ void f6() {
258258
#define M18(X) ( X )
259259
M18(1 * 1); // COMPLIANT
260260
#define M19(X) M15(( X ), # X)
261-
M16(1 * 1); // COMPLIANT -- all expansions of X are precedence protected.
261+
M19(1 * 1); // COMPLIANT -- all expansions of X are precedence protected.
262262
/* clang-format on */
263-
}
263+
}

0 commit comments

Comments
 (0)