`A7-1-7`: Exclude expression statements in macros
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 38/100
Línea de trabajo
Inspecciona la consulta A7-1-7 y el agrupamiento con paréntesis alrededor de las declaraciones y sentencias de expresión expandidas por macros. Usa el ejemplo de C++ proporcionado foo(a, b) para examinar cómo se asignan las ubicaciones durante la expansión de macros. Se considera completado cuando el ejemplo se excluye por ser conforme sin eliminar incorrectamente otras sentencias de expresión no relacionadas.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Affected rules
A7-1-7
Description
Macro expansion can cause multiple expressions and statements to appear at the same location. We exclude macro expanded declarations, I think we should do the same for expression statements.
Reviewing the query, I think this is actually caused by a bracketing issue:
not isAffectedByMacro() and
// MISSING OPENING BRACKET HERE
exists(Declaration d |
...
)
or
this instanceof ExprStmt and
not exists(ForStmt f | f.getInitialization().getAChild*() = this) and
not exists(LambdaExpression l | l.getLambdaFunction().getBlock().getAChild*() = this)
// MISSING CLOSED BRACKET HERE
There's also an interesting thing happening here with locations - as we might expect such macro expansions to by the not l1 = l2 line in the select clause:
exists(Location l1, Location l2 |
e1.getLocation() = l1 and
e2.getLocation() = l2 and
not l1 = l2 and
....
The reason this doesn't exclude this case is that when we expand the macro, we may provide different locations for the expressions and statements within, if we can associate them with a specific macro parameter.
Example
#define foo(x, y) \
x++; \
y++;
void test_macro() {
int a = 1;
int b = 1;
foo(a, b); // COMPLIANT
}
- Lenguaje dominante
- CodeQL
- Estrellas
- 227
- Forks
- 82
- Merge medio
- 6 d 7 h
- PR fusionados (30 d)
- 9
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de github/codeql-coding-standards
-
false positive/false negative Stardard-MISRA-C++
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
github/codeql-coding-standards#1172 ·
-
Difficulty-Low false positive/false negative false-negative Impact-Low Standard-MISRA-C
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Difficulty-Medium false positive/false negative false-positive Impact-Medium Standard-CERT-C
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
github/codeql-coding-standards#1200 ·
-
`RULE-0-0-1`: "unreachable statement" false positives due to over-pruning of the control-flow graph Abiertofalse positive/false negative
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
github/codeql-coding-standards#1190 ·
-
false positive/false negative
Dificultad 3/5 1-2 días Aptitud para principiantes 65/100
github/codeql-coding-standards#1175 ·
Todos los issues de github/codeql-coding-standards
Issues similares
-
ZCode 3.14.3 に対応する Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
supermomonga/zcode-acp#24 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 90/100
learningequality/ricecooker#747 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
KhronosGroup/glTF-Blender-IO#2769 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100