File tree Expand file tree Collapse file tree 3 files changed +6
-8
lines changed
common/src/codingstandards/cpp Expand file tree Collapse file tree 3 files changed +6
-8
lines changed Original file line number Diff line number Diff 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 ( )
Original file line number Diff line number Diff line change @@ -18,7 +18,6 @@ import cpp
1818import codingstandards.cpp.misra
1919import codingstandards.cpp.Macro
2020import 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
Original file line number Diff line number Diff 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+ }
You can’t perform that action at this time.
0 commit comments