`A7-1-7`: Exclude expression statements in macros
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 38/100
Piste de recherche
Examinez la requête A7-1-7 ainsi que le parenthésage autour des déclarations et des instructions d’expression développées par macro. Utilisez l’exemple C++ fourni foo(a, b) pour examiner comment les emplacements sont attribués lors de l’expansion de macro. La tâche est terminée lorsque l’exemple est exclu comme étant conforme, sans supprimer incorrectement d’autres instructions d’expression sans rapport.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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
}
- Langage dominant
- CodeQL
- Étoiles
- 227
- Forks
- 82
- Merge moyen
- 6 j 7 h
- PR mergées (30 j)
- 9
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de github/codeql-coding-standards
-
false positive/false negative Stardard-MISRA-C++
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
github/codeql-coding-standards#1172 ·
-
Difficulty-Low false positive/false negative false-negative Impact-Low Standard-MISRA-C
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
-
Difficulty-Medium false positive/false negative false-positive Impact-Medium Standard-CERT-C
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
github/codeql-coding-standards#1200 ·
-
`RULE-0-0-1`: "unreachable statement" false positives due to over-pruning of the control-flow graph Ouvertefalse positive/false negative
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
github/codeql-coding-standards#1190 ·
-
false positive/false negative
Difficulté 3/5 1-2 jours Accessibilité débutants 65/100
github/codeql-coding-standards#1175 ·
Toutes les issues de github/codeql-coding-standards
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
nightscout/nocturne#1424 ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Ouvertearea: repo bug perceived difficulty: 2
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
-
impl detach for native Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
paritytech/zombienet-sdk#591 ·
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
mruangutai/harness#1897 ·